Просмотр исходного кода

缴费页面 计算赠送优惠券

wuxw лет назад: 3
Родитель
Сommit
e3cac05515

+ 27 - 0
java110-bean/src/main/java/com/java110/dto/couponRuleCpps/CouponRuleCppsDto.java

@@ -20,7 +20,10 @@ public class CouponRuleCppsDto extends PageDto implements Serializable {
     private String cppId;
     private String couponName;
     private String ruleId;
+    private String ruleName;
+    private String toTypeName;
     private String communityId;
+    private String[] ruleIds;
 
 
     private Date createTime;
@@ -92,4 +95,28 @@ public class CouponRuleCppsDto extends PageDto implements Serializable {
     public void setCouponName(String couponName) {
         this.couponName = couponName;
     }
+
+    public String[] getRuleIds() {
+        return ruleIds;
+    }
+
+    public void setRuleIds(String[] ruleIds) {
+        this.ruleIds = ruleIds;
+    }
+
+    public String getRuleName() {
+        return ruleName;
+    }
+
+    public void setRuleName(String ruleName) {
+        this.ruleName = ruleName;
+    }
+
+    public String getToTypeName() {
+        return toTypeName;
+    }
+
+    public void setToTypeName(String toTypeName) {
+        this.toTypeName = toTypeName;
+    }
 }

+ 18 - 0
java110-bean/src/main/java/com/java110/dto/couponRuleFee/CouponRuleFeeDto.java

@@ -23,6 +23,8 @@ public class CouponRuleFeeDto extends PageDto implements Serializable {
     private String communityId;
     private String feeConfigId;
     private String feeConfigName;
+    private String curTime;
+    private String cycle;
 
 
     private Date createTime;
@@ -110,4 +112,20 @@ public class CouponRuleFeeDto extends PageDto implements Serializable {
     public void setFeeConfigName(String feeConfigName) {
         this.feeConfigName = feeConfigName;
     }
+
+    public String getCurTime() {
+        return curTime;
+    }
+
+    public void setCurTime(String curTime) {
+        this.curTime = curTime;
+    }
+
+    public String getCycle() {
+        return cycle;
+    }
+
+    public void setCycle(String cycle) {
+        this.cycle = cycle;
+    }
 }

+ 10 - 1
java110-db/src/main/resources/mapper/acct/CouponRuleCppsV1ServiceDaoImplMapper.xml

@@ -17,10 +17,13 @@
 
     <!-- 查询规则优惠券信息 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,cpp.coupon_name couponName
+        statusCd,t.rule_id,t.rule_id ruleId,t.community_id,t.community_id communityId,cpp.coupon_name couponName,cr.rule_name ruleName,td.`name` toTypeName
         from coupon_rule_cpps t
         left join coupon_property_pool cpp on t.cpp_id = cpp.cpp_id and cpp.status_cd = '0'
+        left join t_dict td on td.status_cd = cpp.to_type and td.table_name = 'coupon_property_pool' and td.table_columns = 'to_type'
+        left join coupon_rule cr on t.rule_id = cr.rule_id and cr.status_cd = '0'
         where 1 =1
         <if test="quantity !=null and quantity != ''">
             and t.quantity= #{quantity}
@@ -37,6 +40,12 @@
         <if test="ruleId !=null and ruleId != ''">
             and t.rule_id= #{ruleId}
         </if>
+        <if test="ruleIds !=null ">
+            and t.rule_id in
+            <foreach collection="ruleIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
         <if test="communityId !=null and communityId != ''">
             and t.community_id= #{communityId}
         </if>

+ 7 - 0
java110-db/src/main/resources/mapper/acct/CouponRuleFeeV1ServiceDaoImplMapper.xml

@@ -26,12 +26,19 @@
         <if test="payMonth !=null and payMonth != ''">
             and t.pay_month= #{payMonth}
         </if>
+        <if test="cycle !=null and cycle != ''">
+            and t.pay_month &lt;= #{cycle}
+        </if>
         <if test="payStartTime !=null and payStartTime != ''">
             and t.pay_start_time= #{payStartTime}
         </if>
         <if test="payEndTime !=null and payEndTime != ''">
             and t.pay_end_time= #{payEndTime}
         </if>
+        <if test="curTime !=null and curTime != ''">
+            and t.pay_start_time &lt; #{curTime}
+            and t.pay_end_time &gt; #{curTime}
+        </if>
         <if test="crfId !=null and crfId != ''">
             and t.crf_id= #{crfId}
         </if>

+ 55 - 1
service-acct/src/main/java/com/java110/acct/cmd/coupon/ComputePayFeeCouponCmd.java

@@ -1,19 +1,31 @@
 package com.java110.acct.cmd.coupon;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 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.doc.annotation.*;
+import com.java110.dto.couponRuleCpps.CouponRuleCppsDto;
+import com.java110.dto.couponRuleFee.CouponRuleFeeDto;
+import com.java110.dto.fee.FeeDto;
+import com.java110.intf.acct.ICouponRuleCppsV1InnerServiceSMO;
+import com.java110.intf.acct.ICouponRuleFeeV1InnerServiceSMO;
+import com.java110.intf.fee.IFeeInnerServiceSMO;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
+import com.java110.utils.util.DateUtil;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
 
 @Java110CmdDoc(title = "根据费用计算优惠券",
         description = "缴费时计算费用 是否有优惠券",
-        httpMethod = "post",
+        httpMethod = "get",
         url = "http://{ip}:{port}/app/coupon.computePayFeeCoupon",
         resource = "acctDoc",
         author = "吴学文",
@@ -42,6 +54,16 @@ import java.text.ParseException;
 )
 @Java110Cmd(serviceCode = "coupon.computePayFeeCoupon")
 public class ComputePayFeeCouponCmd extends Cmd {
+
+    @Autowired
+    private ICouponRuleFeeV1InnerServiceSMO couponRuleFeeV1InnerServiceSMOImpl;
+
+    @Autowired
+    private ICouponRuleCppsV1InnerServiceSMO couponRuleCppsV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
 
@@ -53,6 +75,38 @@ public class ComputePayFeeCouponCmd extends Cmd {
 
     @Override
     public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+        FeeDto feeDto = new FeeDto();
+        feeDto.setFeeId(reqJson.getString("feeId"));
+        List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
+
+        Assert.listOnlyOne(feeDtos,"费用不存在");
+
+        CouponRuleFeeDto couponRuleFeeDto = new CouponRuleFeeDto();
+        couponRuleFeeDto.setFeeConfigId(feeDtos.get(0).getConfigId());
+        couponRuleFeeDto.setCurTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+        couponRuleFeeDto.setCommunityId(reqJson.getString("communityId"));
+        couponRuleFeeDto.setCycle(reqJson.getString("cycle"));
+        List<CouponRuleFeeDto> couponRuleFeeDtos = couponRuleFeeV1InnerServiceSMOImpl.queryCouponRuleFees(couponRuleFeeDto);
+
+        if(couponRuleFeeDtos == null || couponRuleFeeDtos.size()<1){
+            context.setResponseEntity(ResultVo.createResponseEntity(new JSONArray()));
+            return ;
+        }
+
+        List<String> ruleIds = new ArrayList<>();
+        for(CouponRuleFeeDto tmpCouponRuleFeeDto: couponRuleFeeDtos){
+            ruleIds.add(tmpCouponRuleFeeDto.getRuleId());
+        }
+
+        CouponRuleCppsDto couponRuleCppsDto = new CouponRuleCppsDto();
+        couponRuleCppsDto.setRuleIds(ruleIds.toArray(new String[ruleIds.size()]));
+        List<CouponRuleCppsDto> couponRuleCppsDtos = couponRuleCppsV1InnerServiceSMOImpl.queryCouponRuleCppss(couponRuleCppsDto);
+
+        if(couponRuleCppsDtos == null || couponRuleCppsDtos.size() < 1){
+            context.setResponseEntity(ResultVo.createResponseEntity(new JSONArray()));
+            return ;
+        }
 
+        context.setResponseEntity(ResultVo.createResponseEntity(couponRuleCppsDtos));
     }
 }