wuxw пре 3 година
родитељ
комит
1b19ebac0e

+ 32 - 13
java110-bean/src/main/java/com/java110/dto/couponRuleCpps/CouponRuleCppsDto.java

@@ -1,6 +1,7 @@
 package com.java110.dto.couponRuleCpps;
 
 import com.java110.dto.PageDto;
+
 import java.io.Serializable;
 import java.util.Date;
 
@@ -15,10 +16,11 @@ import java.util.Date;
 public class CouponRuleCppsDto extends PageDto implements Serializable {
 
     private String quantity;
-private String crcId;
-private String cppId;
-private String ruleId;
-private String communityId;
+    private String crcId;
+    private String cppId;
+    private String couponName;
+    private String ruleId;
+    private String communityId;
 
 
     private Date createTime;
@@ -29,31 +31,40 @@ private String communityId;
     public String getQuantity() {
         return quantity;
     }
-public void setQuantity(String quantity) {
+
+    public void setQuantity(String quantity) {
         this.quantity = quantity;
     }
-public String getCrcId() {
+
+    public String getCrcId() {
         return crcId;
     }
-public void setCrcId(String crcId) {
+
+    public void setCrcId(String crcId) {
         this.crcId = crcId;
     }
-public String getCppId() {
+
+    public String getCppId() {
         return cppId;
     }
-public void setCppId(String cppId) {
+
+    public void setCppId(String cppId) {
         this.cppId = cppId;
     }
-public String getRuleId() {
+
+    public String getRuleId() {
         return ruleId;
     }
-public void setRuleId(String ruleId) {
+
+    public void setRuleId(String ruleId) {
         this.ruleId = ruleId;
     }
-public String getCommunityId() {
+
+    public String getCommunityId() {
         return communityId;
     }
-public void setCommunityId(String communityId) {
+
+    public void setCommunityId(String communityId) {
         this.communityId = communityId;
     }
 
@@ -73,4 +84,12 @@ public void setCommunityId(String communityId) {
     public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
+
+    public String getCouponName() {
+        return couponName;
+    }
+
+    public void setCouponName(String couponName) {
+        this.couponName = couponName;
+    }
 }

+ 74 - 77
java110-db/src/main/resources/mapper/acct/CouponRuleCppsV1ServiceDaoImplMapper.xml

@@ -5,102 +5,99 @@
 <mapper namespace="couponRuleCppsV1ServiceDaoImpl">
 
 
-
-
-
     <!-- 保存规则优惠券信息 add by wuxw 2018-07-03 -->
     <insert id="saveCouponRuleCppsInfo" parameterType="Map">
         insert into coupon_rule_cpps(
-quantity,crc_id,cpp_id,rule_id,community_id
-) values (
-#{quantity},#{crcId},#{cppId},#{ruleId},#{communityId}
-)
+        quantity,crc_id,cpp_id,rule_id,community_id
+        ) values (
+        #{quantity},#{crcId},#{cppId},#{ruleId},#{communityId}
+        )
     </insert>
 
 
-
     <!-- 查询规则优惠券信息 add by wuxw 2018-07-03 -->
     <select id="getCouponRuleCppsInfo" parameterType="Map" resultType="Map">
-        select  t.quantity,t.crc_id,t.crc_id crcId,t.cpp_id,t.cpp_id cppId,t.status_cd,t.status_cd statusCd,t.rule_id,t.rule_id ruleId,t.community_id,t.community_id communityId 
-from coupon_rule_cpps t 
-where 1 =1 
-<if test="quantity !=null and quantity != ''">
-   and t.quantity= #{quantity}
-</if> 
-<if test="crcId !=null and crcId != ''">
-   and t.crc_id= #{crcId}
-</if> 
-<if test="cppId !=null and cppId != ''">
-   and t.cpp_id= #{cppId}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="ruleId !=null and ruleId != ''">
-   and t.rule_id= #{ruleId}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-order by t.create_time desc
-<if test="page != -1 and page != null ">
-   limit #{page}, #{row}
-</if> 
+        select t.quantity,t.crc_id,t.crc_id crcId,t.cpp_id,t.cpp_id cppId,t.status_cd,t.status_cd
+        statusCd,t.rule_id,t.rule_id ruleId,t.community_id,t.community_id communityId,cpp.coupon_name couponName
+        from coupon_rule_cpps t
+        left join coupon_property_pool cpp on t.cpp_id = cpp.cpp_id and cpp.status_cd = '0'
+        where 1 =1
+        <if test="quantity !=null and quantity != ''">
+            and t.quantity= #{quantity}
+        </if>
+        <if test="crcId !=null and crcId != ''">
+            and t.crc_id= #{crcId}
+        </if>
+        <if test="cppId !=null and cppId != ''">
+            and t.cpp_id= #{cppId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="ruleId !=null and ruleId != ''">
+            and t.rule_id= #{ruleId}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </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="updateCouponRuleCppsInfo" parameterType="Map">
-        update  coupon_rule_cpps t set t.status_cd = #{statusCd}
-<if test="newBId != null and newBId != ''">
-,t.b_id = #{newBId}
-</if> 
-<if test="quantity !=null and quantity != ''">
-, t.quantity= #{quantity}
-</if> 
-<if test="cppId !=null and cppId != ''">
-, t.cpp_id= #{cppId}
-</if> 
-<if test="ruleId !=null and ruleId != ''">
-, t.rule_id= #{ruleId}
-</if> 
-<if test="communityId !=null and communityId != ''">
-, t.community_id= #{communityId}
-</if> 
- where 1=1 <if test="crcId !=null and crcId != ''">
-and t.crc_id= #{crcId}
-</if> 
+        update coupon_rule_cpps t set t.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,t.b_id = #{newBId}
+        </if>
+        <if test="quantity !=null and quantity != ''">
+            , t.quantity= #{quantity}
+        </if>
+        <if test="cppId !=null and cppId != ''">
+            , t.cpp_id= #{cppId}
+        </if>
+        <if test="ruleId !=null and ruleId != ''">
+            , t.rule_id= #{ruleId}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            , t.community_id= #{communityId}
+        </if>
+        where 1=1
+        <if test="crcId !=null and crcId != ''">
+            and t.crc_id= #{crcId}
+        </if>
 
     </update>
 
     <!-- 查询规则优惠券数量 add by wuxw 2018-07-03 -->
-     <select id="queryCouponRuleCppssCount" parameterType="Map" resultType="Map">
-        select  count(1) count 
-from coupon_rule_cpps t 
-where 1 =1 
-<if test="quantity !=null and quantity != ''">
-   and t.quantity= #{quantity}
-</if> 
-<if test="crcId !=null and crcId != ''">
-   and t.crc_id= #{crcId}
-</if> 
-<if test="cppId !=null and cppId != ''">
-   and t.cpp_id= #{cppId}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="ruleId !=null and ruleId != ''">
-   and t.rule_id= #{ruleId}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
+    <select id="queryCouponRuleCppssCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from coupon_rule_cpps t
+        where 1 =1
+        <if test="quantity !=null and quantity != ''">
+            and t.quantity= #{quantity}
+        </if>
+        <if test="crcId !=null and crcId != ''">
+            and t.crc_id= #{crcId}
+        </if>
+        <if test="cppId !=null and cppId != ''">
+            and t.cpp_id= #{cppId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="ruleId !=null and ruleId != ''">
+            and t.rule_id= #{ruleId}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
 
 
-     </select>
+    </select>
 
 </mapper>

+ 5 - 5
service-acct/src/main/java/com/java110/acct/cmd/couponRule/DeleteCouponRuleCppsCmd.java

@@ -21,16 +21,16 @@ 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.ICouponRuleCppsV1InnerServiceSMO;
 import com.java110.po.couponRuleCpps.CouponRuleCppsPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
 import com.java110.vo.ResultVo;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
 /**
  * 类表述:删除
  * 服务编码:couponRuleCpps.deleteCouponRuleCpps
@@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory;
  */
 @Java110Cmd(serviceCode = "couponRule.deleteCouponRuleCpps")
 public class DeleteCouponRuleCppsCmd extends Cmd {
-  private static Logger logger = LoggerFactory.getLogger(DeleteCouponRuleCppsCmd.class);
+    private static Logger logger = LoggerFactory.getLogger(DeleteCouponRuleCppsCmd.class);
 
     @Autowired
     private ICouponRuleCppsV1InnerServiceSMO couponRuleCppsV1InnerServiceSMOImpl;
@@ -51,7 +51,7 @@ public class DeleteCouponRuleCppsCmd extends Cmd {
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "crcId", "crcId不能为空");
-Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
+        Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
 
     }
 
@@ -59,7 +59,7 @@ Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
     @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
 
-       CouponRuleCppsPo couponRuleCppsPo = BeanConvertUtil.covertBean(reqJson, CouponRuleCppsPo.class);
+        CouponRuleCppsPo couponRuleCppsPo = BeanConvertUtil.covertBean(reqJson, CouponRuleCppsPo.class);
         int flag = couponRuleCppsV1InnerServiceSMOImpl.deleteCouponRuleCpps(couponRuleCppsPo);
 
         if (flag < 1) {

+ 17 - 5
service-acct/src/main/java/com/java110/acct/cmd/couponRule/SaveCouponRuleCppsCmd.java

@@ -22,15 +22,16 @@ 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.dto.couponRuleCpps.CouponRuleCppsDto;
 import com.java110.intf.acct.ICouponRuleCppsV1InnerServiceSMO;
 import com.java110.po.couponRuleCpps.CouponRuleCppsPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
 import com.java110.vo.ResultVo;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 
 /**
  * 类表述:保存
@@ -55,9 +56,20 @@ public class SaveCouponRuleCppsCmd extends Cmd {
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "ruleId", "请求报文中未包含ruleId");
-Assert.hasKeyAndValue(reqJson, "cppId", "请求报文中未包含cppId");
-Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
-Assert.hasKeyAndValue(reqJson, "quantity", "请求报文中未包含quantity");
+        Assert.hasKeyAndValue(reqJson, "cppId", "请求报文中未包含cppId");
+        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
+        Assert.hasKeyAndValue(reqJson, "quantity", "请求报文中未包含quantity");
+
+        //查询 规则是否已经关联过 优惠券
+
+        CouponRuleCppsDto couponRuleCppsDto = new CouponRuleCppsDto();
+        couponRuleCppsDto.setRuleId(reqJson.getString("ruleId"));
+        couponRuleCppsDto.setCppId(reqJson.getString("cppId"));
+        int count = couponRuleCppsV1InnerServiceSMOImpl.queryCouponRuleCppssCount(couponRuleCppsDto);
+
+        if(count > 0){
+            throw new CmdException("该优惠券已经关联过");
+        }
 
     }
 
@@ -65,7 +77,7 @@ Assert.hasKeyAndValue(reqJson, "quantity", "请求报文中未包含quantity");
     @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
 
-       CouponRuleCppsPo couponRuleCppsPo = BeanConvertUtil.covertBean(reqJson, CouponRuleCppsPo.class);
+        CouponRuleCppsPo couponRuleCppsPo = BeanConvertUtil.covertBean(reqJson, CouponRuleCppsPo.class);
         couponRuleCppsPo.setCrcId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
         int flag = couponRuleCppsV1InnerServiceSMOImpl.saveCouponRuleCpps(couponRuleCppsPo);