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

1、增加欠费无优惠配置文件2、增加收费项目添加折扣时间日期设置

xiaogang лет назад: 5
Родитель
Сommit
057e334a28

+ 20 - 0
java110-bean/src/main/java/com/java110/dto/payFeeConfigDiscount/PayFeeConfigDiscountDto.java

@@ -28,6 +28,10 @@ public class PayFeeConfigDiscountDto extends PageDto implements Serializable {
 
     private Date createTime;
 
+    private Date startTime;
+
+    private Date endTime;
+
     private String statusCd = "0";
 
 
@@ -103,4 +107,20 @@ public class PayFeeConfigDiscountDto extends PageDto implements Serializable {
     public void setFeeDiscountSpecs(List<FeeDiscountSpecDto> feeDiscountSpecs) {
         this.feeDiscountSpecs = feeDiscountSpecs;
     }
+
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
 }

+ 47 - 34
java110-bean/src/main/java/com/java110/po/payFeeConfigDiscount/PayFeeConfigDiscountPo.java

@@ -6,41 +6,54 @@ import java.util.Date;
 public class PayFeeConfigDiscountPo implements Serializable {
 
     private String configDiscountId;
-private String configId;
-private String statusCd = "0";
-private String discountId;
-private String communityId;
-public String getConfigDiscountId() {
-        return configDiscountId;
-    }
-public void setConfigDiscountId(String configDiscountId) {
-        this.configDiscountId = configDiscountId;
-    }
-public String getConfigId() {
-        return configId;
-    }
-public void setConfigId(String configId) {
-        this.configId = configId;
-    }
-public String getStatusCd() {
-        return statusCd;
-    }
-public void setStatusCd(String statusCd) {
-        this.statusCd = statusCd;
-    }
-public String getDiscountId() {
-        return discountId;
-    }
-public void setDiscountId(String discountId) {
-        this.discountId = discountId;
-    }
-public String getCommunityId() {
-        return communityId;
-    }
-public void setCommunityId(String communityId) {
-        this.communityId = communityId;
+    private String configId;
+    private String statusCd = "0";
+    private String discountId;
+    private String communityId;
+    private String startTime;
+    private String endTime;
+    public String getConfigDiscountId() {
+            return configDiscountId;
+        }
+    public void setConfigDiscountId(String configDiscountId) {
+            this.configDiscountId = configDiscountId;
+        }
+    public String getConfigId() {
+            return configId;
+        }
+    public void setConfigId(String configId) {
+            this.configId = configId;
+        }
+    public String getStatusCd() {
+            return statusCd;
+        }
+    public void setStatusCd(String statusCd) {
+            this.statusCd = statusCd;
+        }
+    public String getDiscountId() {
+            return discountId;
+        }
+    public void setDiscountId(String discountId) {
+            this.discountId = discountId;
+        }
+    public String getCommunityId() {
+            return communityId;
+        }
+    public void setCommunityId(String communityId) {
+            this.communityId = communityId;
+        }
+    public String getStartTime() {
+        return startTime;
+    }
+    public void setStartTime(String startTime) {
+        this.startTime = startTime;
     }
 
+    public String getEndTime() {
+        return endTime;
+    }
 
-
+    public void setEndTime(String endTime) {
+        this.endTime = endTime;
+    }
 }

+ 3 - 3
java110-db/src/main/resources/mapper/fee/PayFeeConfigDiscountServiceDaoImplMapper.xml

@@ -8,9 +8,9 @@
     <!-- 保存费用项折扣信息 add by wuxw 2018-07-03 -->
     <insert id="savePayFeeConfigDiscountInfo" parameterType="Map">
         insert into pay_fee_config_discount(
-        config_discount_id,config_id,discount_id,community_id
+        config_discount_id,config_id,discount_id,community_id,start_time,end_time
         ) values (
-        #{configDiscountId},#{configId},#{discountId},#{communityId}
+        #{configDiscountId},#{configId},#{discountId},#{communityId},#{startTime},#{endTime}
         )
     </insert>
 
@@ -19,7 +19,7 @@
     <select id="getPayFeeConfigDiscountInfo" parameterType="Map" resultType="Map">
         select t.config_discount_id,t.config_discount_id configDiscountId,t.config_id,t.config_id
         configId,t.status_cd,t.status_cd statusCd,t.discount_id,t.discount_id discountId,t.community_id,t.community_id
-        communityId,fd.discount_name discountName,fd.discount_type discountType
+        communityId,fd.discount_name discountName,fd.discount_type discountType,t.start_time startTime,t.end_time endTime
         from pay_fee_config_discount t
         left join fee_discount fd on t.discount_id = fd.discount_id and t.community_id = fd.community_id and fd.status_cd = '0'
         where 1 =1

+ 2 - 0
service-fee/src/main/java/com/java110/fee/api/PayFeeConfigDiscountApi.java

@@ -42,6 +42,8 @@ public class PayFeeConfigDiscountApi {
         Assert.hasKeyAndValue(reqJson, "configId", "请求报文中未包含configId");
         Assert.hasKeyAndValue(reqJson, "discountId", "请求报文中未包含discountId");
         Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
+        Assert.hasKeyAndValue(reqJson, "startTime", "请求报文中未包含startTime");
+        Assert.hasKeyAndValue(reqJson, "endTime", "请求报文中未包含endTime");
 
 
         PayFeeConfigDiscountPo payFeeConfigDiscountPo = BeanConvertUtil.covertBean(reqJson, PayFeeConfigDiscountPo.class);

+ 124 - 0
service-fee/src/main/java/com/java110/fee/discount/impl/DiscountWithoutArrearsRule.java

@@ -0,0 +1,124 @@
+package com.java110.fee.discount.impl;
+
+import com.java110.core.smo.IComputeFeeSMO;
+import com.java110.dto.fee.FeeDto;
+import com.java110.dto.feeDiscount.ComputeDiscountDto;
+import com.java110.dto.feeDiscount.FeeDiscountDto;
+import com.java110.dto.feeDiscountSpec.FeeDiscountSpecDto;
+import com.java110.fee.discount.IComputeDiscount;
+import com.java110.intf.fee.IFeeInnerServiceSMO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 打折无欠费规则
+ *
+ * @author fqz
+ * @date 2020-2-11 9:18
+ */
+@Component(value = "discountWithoutArrearsRule")
+public class DiscountWithoutArrearsRule implements IComputeDiscount {
+
+    /**
+     * 89002020980007	102020005	月份
+     * 89002020980008	102020005	打折率
+     * 89002020980009   102020005   欠费时长
+     */
+    private static final String SPEC_MONTH = "89002020980007"; //月份
+    private static final String SPEC_RATE = "89002020980008"; // 打折率
+    private static final String LENGTH_OF_ARREARS = "89002020980009"; //欠费时长(天)
+
+    @Autowired
+    private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
+
+    @Autowired
+    private IComputeFeeSMO computeFeeSMOImpl;
+
+    @Override
+    public ComputeDiscountDto compute(FeeDiscountDto feeDiscountDto) {
+        List<FeeDiscountSpecDto> feeDiscountSpecDtos = feeDiscountDto.getFeeDiscountSpecs();
+
+        if (feeDiscountSpecDtos.size() < 1) {
+            return null;
+        }
+        //月份
+        double month = 0.0;
+        //打折率
+        double rate = 0.0;
+        //欠费时长(天)
+        int arrearsDay = 0;
+        for (FeeDiscountSpecDto feeDiscountSpecDto : feeDiscountSpecDtos) {
+            //取得月份
+            if (SPEC_MONTH.equals(feeDiscountSpecDto.getSpecId())) {
+                month = Double.parseDouble(feeDiscountSpecDto.getSpecValue());
+            }
+            //取得打折率
+            if (SPEC_RATE.equals(feeDiscountSpecDto.getSpecId())) {
+                rate = Double.parseDouble(feeDiscountSpecDto.getSpecValue());
+            }
+            //取得欠费时长
+            if (LENGTH_OF_ARREARS.equals(feeDiscountSpecDto.getSpecId())) {
+                arrearsDay = Integer.parseInt(feeDiscountSpecDto.getSpecValue());
+            }
+        }
+
+        //判断周期是否小于打折无欠费规则的月份
+        if (feeDiscountDto.getCycles() < month) {
+            ComputeDiscountDto computeDiscountDto = new ComputeDiscountDto();
+            computeDiscountDto.setDiscountId(feeDiscountDto.getDiscountId());
+            computeDiscountDto.setDiscountType(FeeDiscountDto.DISCOUNT_TYPE_D);
+            computeDiscountDto.setRuleId(feeDiscountDto.getRuleId());
+            computeDiscountDto.setRuleName(feeDiscountDto.getRuleName());
+            computeDiscountDto.setDiscountName(feeDiscountDto.getDiscountName());
+            computeDiscountDto.setDiscountPrice(0.0);
+            computeDiscountDto.setFeeDiscountSpecs(feeDiscountSpecDtos);
+            return computeDiscountDto;
+        }
+
+        //查询费用
+        FeeDto feeDto = new FeeDto();
+        feeDto.setCommunityId(feeDiscountDto.getCommunityId());
+        feeDto.setFeeId(feeDiscountDto.getFeeId());
+        List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
+
+        //查看用户是否欠费
+        Date endTime = feeDtos.get(0).getEndTime();
+        //获取当前时间
+        Date date = new Date();
+        //计算相差的天数
+        long day = 0;
+        if (date.getTime() >= endTime.getTime()) {
+            //天数不大于1天时按1天来算
+            day = (date.getTime() - endTime.getTime()) / (1000 * 60 * 60 * 24) + 1;
+        }
+        if (day >= arrearsDay) {
+            ComputeDiscountDto computeDiscountDto = new ComputeDiscountDto();
+            computeDiscountDto.setDiscountId(feeDiscountDto.getDiscountId());
+            computeDiscountDto.setDiscountType(FeeDiscountDto.DISCOUNT_TYPE_D);
+            computeDiscountDto.setRuleId(feeDiscountDto.getRuleId());
+            computeDiscountDto.setRuleName(feeDiscountDto.getRuleName());
+            computeDiscountDto.setDiscountName(feeDiscountDto.getDiscountName());
+            computeDiscountDto.setDiscountPrice(0.0);
+            computeDiscountDto.setFeeDiscountSpecs(feeDiscountSpecDtos);
+            return computeDiscountDto;
+        }
+        double price = computeFeeSMOImpl.getFeePrice(feeDtos.get(0));
+        BigDecimal priceDec = new BigDecimal(price);
+        BigDecimal cycleDec = new BigDecimal(feeDiscountDto.getCycles());
+        double discountPrice = priceDec.multiply(cycleDec).multiply(new BigDecimal(1.0 - rate)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+
+        ComputeDiscountDto computeDiscountDto = new ComputeDiscountDto();
+        computeDiscountDto.setDiscountId(feeDiscountDto.getDiscountId());
+        computeDiscountDto.setDiscountType(FeeDiscountDto.DISCOUNT_TYPE_D);
+        computeDiscountDto.setRuleId(feeDiscountDto.getRuleId());
+        computeDiscountDto.setRuleName(feeDiscountDto.getRuleName());
+        computeDiscountDto.setDiscountName(feeDiscountDto.getDiscountName());
+        computeDiscountDto.setDiscountPrice(discountPrice);
+        computeDiscountDto.setFeeDiscountSpecs(feeDiscountSpecDtos);
+        return computeDiscountDto;
+    }
+}