Procházet zdrojové kódy

优化 优惠券功能

wuxw před 3 roky
rodič
revize
74d095b1ab

+ 30 - 0
java110-bean/src/main/java/com/java110/dto/couponPropertyPool/CouponPropertyPoolDto.java

@@ -1,9 +1,11 @@
 package com.java110.dto.couponPropertyPool;
 
 import com.java110.dto.PageDto;
+import com.java110.dto.couponPropertyPoolConfig.CouponPropertyPoolConfigDto;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @ClassName FloorDto
@@ -21,7 +23,9 @@ public class CouponPropertyPoolDto extends PageDto implements Serializable {
 
     private String couponName;
     private String toType;
+    private String toTypeName;
     private String fromType;
+    private String fromTypeName;
     private String validityDay;
     private String cppId;
     private String communityName;
@@ -35,6 +39,8 @@ public class CouponPropertyPoolDto extends PageDto implements Serializable {
 
     private String statusCd = "0";
 
+    List<CouponPropertyPoolConfigDto> configs;
+
 
     public String getCouponName() {
         return couponName;
@@ -132,4 +138,28 @@ public class CouponPropertyPoolDto extends PageDto implements Serializable {
     public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
+
+    public String getToTypeName() {
+        return toTypeName;
+    }
+
+    public void setToTypeName(String toTypeName) {
+        this.toTypeName = toTypeName;
+    }
+
+    public String getFromTypeName() {
+        return fromTypeName;
+    }
+
+    public void setFromTypeName(String fromTypeName) {
+        this.fromTypeName = fromTypeName;
+    }
+
+    public List<CouponPropertyPoolConfigDto> getConfigs() {
+        return configs;
+    }
+
+    public void setConfigs(List<CouponPropertyPoolConfigDto> configs) {
+        this.configs = configs;
+    }
 }

+ 27 - 10
java110-bean/src/main/java/com/java110/dto/couponPropertyPoolConfig/CouponPropertyPoolConfigDto.java

@@ -1,6 +1,7 @@
 package com.java110.dto.couponPropertyPoolConfig;
 
 import com.java110.dto.PageDto;
+
 import java.io.Serializable;
 import java.util.Date;
 
@@ -15,9 +16,10 @@ import java.util.Date;
 public class CouponPropertyPoolConfigDto extends PageDto implements Serializable {
 
     private String configId;
-private String couponId;
-private String columnValue;
-private String columnKey;
+    private String couponId;
+    private String[] couponIds;
+    private String columnValue;
+    private String columnKey;
 
 
     private Date createTime;
@@ -28,25 +30,32 @@ private String columnKey;
     public String getConfigId() {
         return configId;
     }
-public void setConfigId(String configId) {
+
+    public void setConfigId(String configId) {
         this.configId = configId;
     }
-public String getCouponId() {
+
+    public String getCouponId() {
         return couponId;
     }
-public void setCouponId(String couponId) {
+
+    public void setCouponId(String couponId) {
         this.couponId = couponId;
     }
-public String getColumnValue() {
+
+    public String getColumnValue() {
         return columnValue;
     }
-public void setColumnValue(String columnValue) {
+
+    public void setColumnValue(String columnValue) {
         this.columnValue = columnValue;
     }
-public String getColumnKey() {
+
+    public String getColumnKey() {
         return columnKey;
     }
-public void setColumnKey(String columnKey) {
+
+    public void setColumnKey(String columnKey) {
         this.columnKey = columnKey;
     }
 
@@ -66,4 +75,12 @@ public void setColumnKey(String columnKey) {
     public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
+
+    public String[] getCouponIds() {
+        return couponIds;
+    }
+
+    public void setCouponIds(String[] couponIds) {
+        this.couponIds = couponIds;
+    }
 }

+ 71 - 68
java110-db/src/main/resources/mapper/acct/CouponPropertyPoolConfigV1ServiceDaoImplMapper.xml

@@ -5,93 +5,96 @@
 <mapper namespace="couponPropertyPoolConfigV1ServiceDaoImpl">
 
 
-
-
-
     <!-- 保存优惠券配置信息 add by wuxw 2018-07-03 -->
     <insert id="saveCouponPropertyPoolConfigInfo" parameterType="Map">
         insert into coupon_property_pool_config(
-config_id,coupon_id,column_value,column_key
-) values (
-#{configId},#{couponId},#{columnValue},#{columnKey}
-)
+        config_id,coupon_id,column_value,column_key
+        ) values (
+        #{configId},#{couponId},#{columnValue},#{columnKey}
+        )
     </insert>
 
 
-
     <!-- 查询优惠券配置信息 add by wuxw 2018-07-03 -->
     <select id="getCouponPropertyPoolConfigInfo" parameterType="Map" resultType="Map">
-        select  t.config_id,t.config_id configId,t.status_cd,t.status_cd statusCd,t.coupon_id,t.coupon_id couponId,t.column_value,t.column_value columnValue,t.column_key,t.column_key columnKey 
-from coupon_property_pool_config t 
-where 1 =1 
-<if test="configId !=null and configId != ''">
-   and t.config_id= #{configId}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="couponId !=null and couponId != ''">
-   and t.coupon_id= #{couponId}
-</if> 
-<if test="columnValue !=null and columnValue != ''">
-   and t.column_value= #{columnValue}
-</if> 
-<if test="columnKey !=null and columnKey != ''">
-   and t.column_key= #{columnKey}
-</if> 
-order by t.create_time desc
-<if test="page != -1 and page != null ">
-   limit #{page}, #{row}
-</if> 
+        select t.config_id,t.config_id configId,t.status_cd,t.status_cd statusCd,t.coupon_id,t.coupon_id
+        couponId,t.column_value,t.column_value columnValue,t.column_key,t.column_key columnKey
+        from coupon_property_pool_config t
+        where 1 =1
+        <if test="configId !=null and configId != ''">
+            and t.config_id= #{configId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="couponId !=null and couponId != ''">
+            and t.coupon_id= #{couponId}
+        </if>
+        <if test="couponIds !=null">
+            and t.coupon_id in
+            <foreach collection="couponIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="columnValue !=null and columnValue != ''">
+            and t.column_value= #{columnValue}
+        </if>
+        <if test="columnKey !=null and columnKey != ''">
+            and t.column_key= #{columnKey}
+        </if>
+        order by t.create_time desc
+        <if test="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
 
     </select>
 
 
-
-
     <!-- 修改优惠券配置信息 add by wuxw 2018-07-03 -->
     <update id="updateCouponPropertyPoolConfigInfo" parameterType="Map">
-        update  coupon_property_pool_config t set t.status_cd = #{statusCd}
-<if test="newBId != null and newBId != ''">
-,t.b_id = #{newBId}
-</if> 
-<if test="couponId !=null and couponId != ''">
-, t.coupon_id= #{couponId}
-</if> 
-<if test="columnValue !=null and columnValue != ''">
-, t.column_value= #{columnValue}
-</if> 
-<if test="columnKey !=null and columnKey != ''">
-, t.column_key= #{columnKey}
-</if> 
- where 1=1 <if test="configId !=null and configId != ''">
-and t.config_id= #{configId}
-</if> 
+        update coupon_property_pool_config t set t.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,t.b_id = #{newBId}
+        </if>
+
+        <if test="columnValue !=null and columnValue != ''">
+            , t.column_value= #{columnValue}
+        </if>
+        <if test="columnKey !=null and columnKey != ''">
+            , t.column_key= #{columnKey}
+        </if>
+        where 1=1
+        <if test="configId !=null and configId != ''">
+            and t.config_id= #{configId}
+        </if>
+        <if test="couponId !=null and couponId != ''">
+            and t.coupon_id= #{couponId}
+        </if>
 
     </update>
 
     <!-- 查询优惠券配置数量 add by wuxw 2018-07-03 -->
-     <select id="queryCouponPropertyPoolConfigsCount" parameterType="Map" resultType="Map">
-        select  count(1) count 
-from coupon_property_pool_config t 
-where 1 =1 
-<if test="configId !=null and configId != ''">
-   and t.config_id= #{configId}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="couponId !=null and couponId != ''">
-   and t.coupon_id= #{couponId}
-</if> 
-<if test="columnValue !=null and columnValue != ''">
-   and t.column_value= #{columnValue}
-</if> 
-<if test="columnKey !=null and columnKey != ''">
-   and t.column_key= #{columnKey}
-</if> 
+    <select id="queryCouponPropertyPoolConfigsCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from coupon_property_pool_config t
+        where 1 =1
+        <if test="configId !=null and configId != ''">
+            and t.config_id= #{configId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="couponId !=null and couponId != ''">
+            and t.coupon_id= #{couponId}
+        </if>
+        <if test="columnValue !=null and columnValue != ''">
+            and t.column_value= #{columnValue}
+        </if>
+        <if test="columnKey !=null and columnKey != ''">
+            and t.column_key= #{columnKey}
+        </if>
 
 
-     </select>
+    </select>
 
 </mapper>

+ 3 - 1
java110-db/src/main/resources/mapper/acct/CouponPropertyPoolV1ServiceDaoImplMapper.xml

@@ -20,8 +20,10 @@
         select t.coupon_name,t.coupon_name couponName,t.to_type,t.to_type toType,t.from_type,t.from_type
         fromType,t.validity_day,t.validity_day validityDay,t.cpp_id,t.cpp_id cppId,t.community_name,t.community_name
         communityName,t.status_cd,t.status_cd statusCd,t.state,t.community_id,t.community_id
-        communityId,t.stock,t.from_id,t.from_id fromId
+        communityId,t.stock,t.from_id,t.from_id fromId,td.name fromTypeName,td1.`name` toTypeName
         from coupon_property_pool t
+        left join t_dict td on td.status_cd = t.from_type and td.table_name = 'coupon_property_pool' and td.table_columns = 'from_type'
+        left join t_dict td1 on td1.status_cd = t.to_type and td1.table_name = 'coupon_property_pool' and td1.table_columns = 'to_type'
         where 1 =1
         <if test="couponName !=null and couponName != ''">
             and t.coupon_name= #{couponName}

+ 34 - 0
service-acct/src/main/java/com/java110/acct/cmd/couponProperty/ListCouponPropertyPoolCmd.java

@@ -20,6 +20,8 @@ import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
+import com.java110.dto.couponPropertyPoolConfig.CouponPropertyPoolConfigDto;
+import com.java110.intf.acct.ICouponPropertyPoolConfigV1InnerServiceSMO;
 import com.java110.intf.acct.ICouponPropertyPoolV1InnerServiceSMO;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.BeanConvertUtil;
@@ -51,6 +53,9 @@ public class ListCouponPropertyPoolCmd extends Cmd {
     @Autowired
     private ICouponPropertyPoolV1InnerServiceSMO couponPropertyPoolV1InnerServiceSMOImpl;
 
+    @Autowired
+    private ICouponPropertyPoolConfigV1InnerServiceSMO couponPropertyPoolConfigV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         super.validatePageInfo(reqJson);
@@ -67,6 +72,7 @@ public class ListCouponPropertyPoolCmd extends Cmd {
 
            if (count > 0) {
                couponPropertyPoolDtos = couponPropertyPoolV1InnerServiceSMOImpl.queryCouponPropertyPools(couponPropertyPoolDto);
+               queryConfigs(couponPropertyPoolDtos);
            } else {
                couponPropertyPoolDtos = new ArrayList<>();
            }
@@ -77,4 +83,32 @@ public class ListCouponPropertyPoolCmd extends Cmd {
 
            cmdDataFlowContext.setResponseEntity(responseEntity);
     }
+
+    private void queryConfigs(List<CouponPropertyPoolDto> couponPropertyPoolDtos) {
+
+        if(couponPropertyPoolDtos == null || couponPropertyPoolDtos.size()<1){
+            return ;
+        }
+        List<String> cppIds = new ArrayList<>();
+
+        for(CouponPropertyPoolDto couponPropertyPoolDto: couponPropertyPoolDtos){
+            cppIds.add(couponPropertyPoolDto.getCppId());
+        }
+
+        CouponPropertyPoolConfigDto couponPropertyPoolConfigDto = new CouponPropertyPoolConfigDto();
+        couponPropertyPoolConfigDto.setCouponIds(cppIds.toArray(new String[cppIds.size()]));
+        List<CouponPropertyPoolConfigDto> couponPropertyPoolConfigDtos
+                = couponPropertyPoolConfigV1InnerServiceSMOImpl.queryCouponPropertyPoolConfigs(couponPropertyPoolConfigDto);
+        List<CouponPropertyPoolConfigDto> tmpCouponPropertyPoolConfigDtos = null;
+        for(CouponPropertyPoolDto couponPropertyPoolDto: couponPropertyPoolDtos){
+            tmpCouponPropertyPoolConfigDtos = new ArrayList<>();
+            for(CouponPropertyPoolConfigDto couponPropertyPoolConfigDto1: couponPropertyPoolConfigDtos){
+                if(couponPropertyPoolDto.getCppId().equals(couponPropertyPoolConfigDto1.getCouponId())){
+                    tmpCouponPropertyPoolConfigDtos.add(couponPropertyPoolConfigDto1);
+                }
+            }
+            couponPropertyPoolDto.setConfigs(tmpCouponPropertyPoolConfigDtos);
+        }
+
+    }
 }

+ 19 - 0
service-acct/src/main/java/com/java110/acct/cmd/couponProperty/SaveCouponPropertyPoolCmd.java

@@ -25,14 +25,18 @@ import com.java110.core.event.cmd.CmdEvent;
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.dto.community.CommunityDto;
 import com.java110.dto.couponPropertyPool.CouponPropertyPoolDto;
+import com.java110.dto.couponPropertyPoolConfig.CouponPropertyPoolConfigDto;
+import com.java110.intf.acct.ICouponPropertyPoolConfigV1InnerServiceSMO;
 import com.java110.intf.acct.ICouponPropertyPoolV1InnerServiceSMO;
 import com.java110.intf.community.ICommunityV1InnerServiceSMO;
 import com.java110.po.couponPropertyPool.CouponPropertyPoolPo;
+import com.java110.po.couponPropertyPoolConfig.CouponPropertyPoolConfigPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
 import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
+import com.sun.tools.javah.Gen;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -59,6 +63,9 @@ public class SaveCouponPropertyPoolCmd extends Cmd {
     @Autowired
     private ICouponPropertyPoolV1InnerServiceSMO couponPropertyPoolV1InnerServiceSMOImpl;
 
+    @Autowired
+    private ICouponPropertyPoolConfigV1InnerServiceSMO couponPropertyPoolConfigV1InnerServiceSMOImpl;
+
     @Autowired
     private ICommunityV1InnerServiceSMO communityV1InnerServiceSMOImpl;
 
@@ -116,7 +123,19 @@ public class SaveCouponPropertyPoolCmd extends Cmd {
             throw new CmdException("保存数据失败");
         }
 
+        JSONArray toTypes = reqJson.getJSONArray("toTypes");
 
+        JSONObject typeObj = null;
+        CouponPropertyPoolConfigPo couponPropertyPoolConfigPo = null;
+        for(int typeIndex = 0;typeIndex < toTypes.size(); typeIndex++){
+            typeObj = toTypes.getJSONObject(typeIndex);
+            couponPropertyPoolConfigPo = new CouponPropertyPoolConfigPo();
+            couponPropertyPoolConfigPo.setColumnKey(typeObj.getString("columnKey"));
+            couponPropertyPoolConfigPo.setColumnValue(typeObj.getString("columnValue"));
+            couponPropertyPoolConfigPo.setConfigId(GenerateCodeFactory.getGeneratorId("11"));
+            couponPropertyPoolConfigPo.setCouponId(couponPropertyPoolPo.getCppId());
+            couponPropertyPoolConfigV1InnerServiceSMOImpl.saveCouponPropertyPoolConfig(couponPropertyPoolConfigPo);
+        }
 
         cmdDataFlowContext.setResponseEntity(ResultVo.success());
     }

+ 50 - 0
service-acct/src/main/java/com/java110/acct/cmd/couponProperty/UpdateCouponPropertyPoolCmd.java

@@ -15,17 +15,22 @@
  */
 package com.java110.acct.cmd.couponProperty;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.annotation.Java110Transactional;
 import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.intf.acct.ICouponPropertyPoolConfigV1InnerServiceSMO;
 import com.java110.intf.acct.ICouponPropertyPoolV1InnerServiceSMO;
 import com.java110.po.couponPropertyPool.CouponPropertyPoolPo;
+import com.java110.po.couponPropertyPoolConfig.CouponPropertyPoolConfigPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -51,10 +56,36 @@ public class UpdateCouponPropertyPoolCmd extends Cmd {
     @Autowired
     private ICouponPropertyPoolV1InnerServiceSMO couponPropertyPoolV1InnerServiceSMOImpl;
 
+    @Autowired
+    private ICouponPropertyPoolConfigV1InnerServiceSMO couponPropertyPoolConfigV1InnerServiceSMOImpl;
+
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "cppId", "cppId不能为空");
 
+        if(!reqJson.containsKey("toTypes")){
+            throw new CmdException("未包含用途");
+        }
+
+        JSONArray toTypes = reqJson.getJSONArray("toTypes");
+
+        if(toTypes == null || toTypes.size()< 1){
+            throw new CmdException("未包含用途");
+        }
+
+        JSONObject typeObj = null;
+        for(int typeIndex = 0;typeIndex < toTypes.size(); typeIndex++){
+            typeObj = toTypes.getJSONObject(typeIndex);
+            if(!typeObj.containsKey("columnValue")){
+                throw new CmdException(typeObj.getString("name")+"未填写值");
+            }
+
+            if(StringUtil.isEmpty(typeObj.getString("columnValue"))){
+                throw new CmdException(typeObj.getString("name")+"未填写值");
+            }
+        }
+
     }
 
     @Override
@@ -67,6 +98,25 @@ public class UpdateCouponPropertyPoolCmd extends Cmd {
         if (flag < 1) {
             throw new CmdException("更新数据失败");
         }
+        CouponPropertyPoolConfigPo couponPropertyPoolConfigPo = null;
+        couponPropertyPoolConfigPo = new CouponPropertyPoolConfigPo();
+        couponPropertyPoolConfigPo.setCouponId(couponPropertyPoolPo.getCppId());
+
+        couponPropertyPoolConfigV1InnerServiceSMOImpl.deleteCouponPropertyPoolConfig(couponPropertyPoolConfigPo);
+
+        JSONArray toTypes = reqJson.getJSONArray("toTypes");
+
+        JSONObject typeObj = null;
+
+        for(int typeIndex = 0;typeIndex < toTypes.size(); typeIndex++){
+            typeObj = toTypes.getJSONObject(typeIndex);
+            couponPropertyPoolConfigPo = new CouponPropertyPoolConfigPo();
+            couponPropertyPoolConfigPo.setColumnKey(typeObj.getString("columnKey"));
+            couponPropertyPoolConfigPo.setColumnValue(typeObj.getString("columnValue"));
+            couponPropertyPoolConfigPo.setConfigId(GenerateCodeFactory.getGeneratorId("11"));
+            couponPropertyPoolConfigPo.setCouponId(couponPropertyPoolPo.getCppId());
+            couponPropertyPoolConfigV1InnerServiceSMOImpl.saveCouponPropertyPoolConfig(couponPropertyPoolConfigPo);
+        }
 
         cmdDataFlowContext.setResponseEntity(ResultVo.success());
     }