Sfoglia il codice sorgente

加入赠送积分功能

java110 3 anni fa
parent
commit
11124384e1

+ 19 - 0
java110-bean/src/main/java/com/java110/dto/integralRuleConfig/IntegralRuleConfigDto.java

@@ -37,6 +37,7 @@ public class IntegralRuleConfigDto extends PageDto implements Serializable {
     private String scaleName;
     private String ircId;
     private String ruleId;
+    private String ruleName;
     private String[] ruleIds;
 
     private String communityId;
@@ -46,6 +47,8 @@ public class IntegralRuleConfigDto extends PageDto implements Serializable {
 
     private String statusCd = "0";
 
+    private String quantity;
+
 
     public String getConfigId() {
         return configId;
@@ -159,4 +162,20 @@ public class IntegralRuleConfigDto extends PageDto implements Serializable {
     public void setRuleIds(String[] ruleIds) {
         this.ruleIds = ruleIds;
     }
+
+    public String getQuantity() {
+        return quantity;
+    }
+
+    public void setQuantity(String quantity) {
+        this.quantity = quantity;
+    }
+
+    public String getRuleName() {
+        return ruleName;
+    }
+
+    public void setRuleName(String ruleName) {
+        this.ruleName = ruleName;
+    }
 }

+ 4 - 0
java110-core/src/main/java/com/java110/core/smo/IComputeFeeSMO.java

@@ -1,7 +1,9 @@
 package com.java110.core.smo;
 
+import com.alibaba.fastjson.JSONObject;
 import com.java110.dto.RoomDto;
 import com.java110.dto.fee.FeeDto;
+import com.java110.dto.integralRuleConfig.IntegralRuleConfigDto;
 import com.java110.dto.machine.CarInoutDetailDto;
 import com.java110.dto.machine.CarInoutDto;
 import com.java110.dto.owner.OwnerCarDto;
@@ -185,4 +187,6 @@ public interface IComputeFeeSMO {
      * @param custEndTime
      */
     void dealRentRateCustEndTime(FeeDto feeDto, Date custEndTime);
+
+    long computeOneIntegralQuantity(IntegralRuleConfigDto integralRuleConfigDto, JSONObject reqJson);
 }

+ 158 - 131
java110-core/src/main/java/com/java110/core/smo/impl/ComputeFeeSMOImpl.java

@@ -1,5 +1,6 @@
 package com.java110.core.smo.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.java110.config.properties.code.Java110Properties;
 import com.java110.core.context.Environment;
 import com.java110.core.log.LoggerFactory;
@@ -10,6 +11,7 @@ import com.java110.dto.community.CommunityDto;
 import com.java110.dto.contract.ContractDto;
 import com.java110.dto.contractRoom.ContractRoomDto;
 import com.java110.dto.fee.*;
+import com.java110.dto.integralRuleConfig.IntegralRuleConfigDto;
 import com.java110.dto.machine.CarInoutDetailDto;
 import com.java110.dto.machine.CarInoutDto;
 import com.java110.dto.owner.OwnerCarDto;
@@ -44,12 +46,10 @@ import org.springframework.stereotype.Service;
 import javax.script.ScriptEngine;
 import javax.script.ScriptEngineManager;
 import java.math.BigDecimal;
-import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
 import java.util.*;
 
 /**
@@ -289,7 +289,7 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
             } else if ("1101".equals(computingFormula)) { // 租金
                 feeReceiptDetailPo.setArea("");
                 feeReceiptDetailPo.setSquarePrice(roomDto.getRoomRent());
-            }  else if ("1102".equals(computingFormula)) { // 租金
+            } else if ("1102".equals(computingFormula)) { // 租金
                 feeReceiptDetailPo.setArea("");
                 feeReceiptDetailPo.setSquarePrice(roomDto.getRoomRent());
             } else if ("4004".equals(computingFormula)) {
@@ -330,7 +330,7 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
             } else if ("1102".equals(computingFormula)) { //租金
                 feeReceiptDetailPo.setArea(roomDtos.get(0).getBuiltUpArea());
                 feeReceiptDetailPo.setSquarePrice(roomDtos.get(0).getRoomRent());
-            }else {
+            } else {
             }
         } else if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDto.getPayerObjType())) {//车位相关
             String computingFormula = feeDto.getComputingFormula();
@@ -445,7 +445,7 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 }
                 feeReceiptDetailPo.setArea("");
                 feeReceiptDetailPo.setSquarePrice(builtUpArea.doubleValue() + "");
-            }else if ("4004".equals(computingFormula)) {
+            } else if ("4004".equals(computingFormula)) {
             } else if ("5005".equals(computingFormula)) {
                 if (StringUtil.isEmpty(feeDto.getCurDegrees())) {
                 } else {
@@ -765,7 +765,7 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
         endCalender.add(Calendar.HOUR, hours);
         if (FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())) {
             return FeeDto.STATE_FINISH;
-        } else if(FeeDto.FEE_FLAG_CYCLE_ONCE.equals(feeDto.getFeeFlag())){
+        } else if (FeeDto.FEE_FLAG_CYCLE_ONCE.equals(feeDto.getFeeFlag())) {
             if ((endCalender.getTime()).after(feeDto.getDeadlineTime())) {
                 return FeeDto.STATE_FINISH;
             }
@@ -800,8 +800,8 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
             } else {
                 endCalender.setTime(feeDto.getImportFeeEndTime());
             }
-        } else if(FeeDto.FEE_FLAG_CYCLE_ONCE.equals(feeDto.getFeeFlag())){
-            if(feeDto.getDeadlineTime() == null){
+        } else if (FeeDto.FEE_FLAG_CYCLE_ONCE.equals(feeDto.getFeeFlag())) {
+            if (feeDto.getDeadlineTime() == null) {
                 throw new IllegalArgumentException("间接性费用未设置结束时间");
             }
             if ((endCalender.getTime()).after(feeDto.getDeadlineTime())) {
@@ -846,7 +846,7 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
             } else if ("1101".equals(computingFormula)) { // 租金
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getRoomRent()));
                 feePrice = additionalAmount.setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
-            }  else if ("1102".equals(computingFormula)) { // 租金
+            } else if ("1102".equals(computingFormula)) { // 租金
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getRoomRent()));
                 feePrice = additionalAmount.setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
             } else if ("4004".equals(computingFormula)) {
@@ -901,9 +901,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 feePrice = new BigDecimal(0);
             } else if ("1101".equals(computingFormula)) { // 租金
                 feePrice = new BigDecimal(0);
-            }  else if ("1102".equals(computingFormula)) { // 租金
+            } else if ("1102".equals(computingFormula)) { // 租金
                 feePrice = new BigDecimal(0);
-            }else if ("4004".equals(computingFormula)) {
+            } else if ("4004".equals(computingFormula)) {
                 feePrice = new BigDecimal(Double.parseDouble(tmpReportFeeDto.getAmount()));
             } else if ("5005".equals(computingFormula)) {
                 if (StringUtil.isEmpty(tmpReportFeeDto.getCurDegrees())) {
@@ -948,43 +948,44 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
     }
 
     /**
-     *                  //计算周期
-     //                    Map<String, Object> cycleResults = dateDiff(feeDto.getEndTime(), feeDto.getCustEndTime());
-     //                    //月份大于0
-     //                    Integer months = Integer.valueOf(cycleResults.get("months").toString());
-     //                    Integer days = Integer.valueOf(cycleResults.get("days").toString());
-     //                    Integer startMonthDays = Integer.valueOf(cycleResults.get("startMonthDays").toString());
-     //                    Integer endMonthDays = Integer.valueOf(cycleResults.get("endMonthDays").toString());
-     //                    String isOneMonth = cycleResults.get("isOneMonth").toString();
-     //                    //整数月
-     //                    if (months > 0 && days == 0) {
-     //                        BigDecimal cycle = new BigDecimal(months);
-     //                        feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle).setScale(3, BigDecimal.ROUND_HALF_UP);
-     //                    }
-     //                    //几个月几天   (单价*面积+附加费)*月份+((单价*面积+附加费)/总天数)*实际天数
-     //                    if (months > 0 && days > 0) {
-     //                        BigDecimal cycle = new BigDecimal(months);
-     //                        BigDecimal endMonthDayss = new BigDecimal(endMonthDays);
-     //                        BigDecimal dayss = new BigDecimal(days);
-     //                        BigDecimal monthPrice = squarePrice.multiply(builtUpArea).add(additionalAmount);
-     //                        feeTotalPrice = (monthPrice).multiply(cycle).add(monthPrice.divide(endMonthDayss).multiply(dayss)).setScale(3, BigDecimal.ROUND_HALF_UP);
-     //                    }
-     //                    //跨月份 不足一月  ((单价*面积+附加费)/开始月份总天数)*实际天数+((单价*面积+附加费)/结束月份总天数)*实际天数
-     //                    if (months == 0 && days > 0 && "true".equals(isOneMonth)) {
-     //                        BigDecimal startEndOfMonth = new BigDecimal(cycleResults.get("startEndOfMonth").toString());
-     //                        BigDecimal endBeginningOfMonth = new BigDecimal(cycleResults.get("endBeginningOfMonth").toString());
-     //                        BigDecimal endMonthDayss = new BigDecimal(endMonthDays);
-     //                        BigDecimal startMonthDayss = new BigDecimal(startMonthDays);
-     //                        BigDecimal monthPrice = squarePrice.multiply(builtUpArea).add(additionalAmount);
-     //                        feeTotalPrice = monthPrice.divide(startMonthDayss, 4, BigDecimal.ROUND_HALF_UP).multiply(startEndOfMonth).add(monthPrice.divide(endMonthDayss, 4, BigDecimal.ROUND_HALF_UP).multiply(endBeginningOfMonth)).setScale(3, BigDecimal.ROUND_HALF_UP);
-     //                    }
-     //                    //不跨月份 不足一月  (单价*面积+附加费/开始月份总天数)*实际天数
-     //                    if (months == 0 && days > 0 && "false".equals(isOneMonth)) {
-     //                        BigDecimal cycle = new BigDecimal(days);
-     //                        BigDecimal startMonthDayss = new BigDecimal(startMonthDays);
-     //                        BigDecimal monthPrice = squarePrice.multiply(builtUpArea).add(additionalAmount);
-     //                        feeTotalPrice = monthPrice.divide(startMonthDayss, 4, BigDecimal.ROUND_HALF_UP).multiply(cycle).setScale(3, BigDecimal.ROUND_HALF_UP);
-     //                    }
+     * //计算周期
+     * //                    Map<String, Object> cycleResults = dateDiff(feeDto.getEndTime(), feeDto.getCustEndTime());
+     * //                    //月份大于0
+     * //                    Integer months = Integer.valueOf(cycleResults.get("months").toString());
+     * //                    Integer days = Integer.valueOf(cycleResults.get("days").toString());
+     * //                    Integer startMonthDays = Integer.valueOf(cycleResults.get("startMonthDays").toString());
+     * //                    Integer endMonthDays = Integer.valueOf(cycleResults.get("endMonthDays").toString());
+     * //                    String isOneMonth = cycleResults.get("isOneMonth").toString();
+     * //                    //整数月
+     * //                    if (months > 0 && days == 0) {
+     * //                        BigDecimal cycle = new BigDecimal(months);
+     * //                        feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle).setScale(3, BigDecimal.ROUND_HALF_UP);
+     * //                    }
+     * //                    //几个月几天   (单价*面积+附加费)*月份+((单价*面积+附加费)/总天数)*实际天数
+     * //                    if (months > 0 && days > 0) {
+     * //                        BigDecimal cycle = new BigDecimal(months);
+     * //                        BigDecimal endMonthDayss = new BigDecimal(endMonthDays);
+     * //                        BigDecimal dayss = new BigDecimal(days);
+     * //                        BigDecimal monthPrice = squarePrice.multiply(builtUpArea).add(additionalAmount);
+     * //                        feeTotalPrice = (monthPrice).multiply(cycle).add(monthPrice.divide(endMonthDayss).multiply(dayss)).setScale(3, BigDecimal.ROUND_HALF_UP);
+     * //                    }
+     * //                    //跨月份 不足一月  ((单价*面积+附加费)/开始月份总天数)*实际天数+((单价*面积+附加费)/结束月份总天数)*实际天数
+     * //                    if (months == 0 && days > 0 && "true".equals(isOneMonth)) {
+     * //                        BigDecimal startEndOfMonth = new BigDecimal(cycleResults.get("startEndOfMonth").toString());
+     * //                        BigDecimal endBeginningOfMonth = new BigDecimal(cycleResults.get("endBeginningOfMonth").toString());
+     * //                        BigDecimal endMonthDayss = new BigDecimal(endMonthDays);
+     * //                        BigDecimal startMonthDayss = new BigDecimal(startMonthDays);
+     * //                        BigDecimal monthPrice = squarePrice.multiply(builtUpArea).add(additionalAmount);
+     * //                        feeTotalPrice = monthPrice.divide(startMonthDayss, 4, BigDecimal.ROUND_HALF_UP).multiply(startEndOfMonth).add(monthPrice.divide(endMonthDayss, 4, BigDecimal.ROUND_HALF_UP).multiply(endBeginningOfMonth)).setScale(3, BigDecimal.ROUND_HALF_UP);
+     * //                    }
+     * //                    //不跨月份 不足一月  (单价*面积+附加费/开始月份总天数)*实际天数
+     * //                    if (months == 0 && days > 0 && "false".equals(isOneMonth)) {
+     * //                        BigDecimal cycle = new BigDecimal(days);
+     * //                        BigDecimal startMonthDayss = new BigDecimal(startMonthDays);
+     * //                        BigDecimal monthPrice = squarePrice.multiply(builtUpArea).add(additionalAmount);
+     * //                        feeTotalPrice = monthPrice.divide(startMonthDayss, 4, BigDecimal.ROUND_HALF_UP).multiply(cycle).setScale(3, BigDecimal.ROUND_HALF_UP);
+     * //                    }
+     *
      * @param feeDto
      * @param roomDto
      * @return
@@ -1022,9 +1023,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("2002".equals(computingFormula)) { // 固定费用
@@ -1038,9 +1039,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = additionalAmount.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("3003".equals(computingFormula)) { // 固定费用
@@ -1055,9 +1056,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("1101".equals(computingFormula)) { // 租金
@@ -1070,12 +1071,12 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = additionalAmount.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
-            }else if ("1102".equals(computingFormula)) { // 租金
+            } else if ("1102".equals(computingFormula)) { // 租金
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(roomDto.getRoomRent()));
                 feePrice = additionalAmount.setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 BigDecimal cycle = null;
@@ -1085,9 +1086,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = additionalAmount.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("4004".equals(computingFormula)) {  //动态费用
@@ -1099,9 +1100,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = feePrice.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("5005".equals(computingFormula)) {  //(本期度数-上期度数)*单价+附加费
@@ -1124,9 +1125,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                     if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                         cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                     }
-                    if(cycle == null){
+                    if (cycle == null) {
                         feeTotalPrice = new BigDecimal(0);
-                    }else {
+                    } else {
                         feeTotalPrice = (sub.multiply(squarePrice).add(additionalAmount)).multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                     }
                 }
@@ -1140,9 +1141,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = feePrice.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("7007".equals(computingFormula)) { //自定义公式
@@ -1164,9 +1165,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = feePrice.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("8008".equals(computingFormula)) {  //手动动态费用
@@ -1178,9 +1179,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = feePrice.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("9009".equals(computingFormula)) {  //(本期度数-上期度数)*动态单价+附加费
@@ -1202,9 +1203,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                     if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                         cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                     }
-                    if(cycle == null){
+                    if (cycle == null) {
                         feeTotalPrice = new BigDecimal(0);
-                    }else {
+                    } else {
                         feeTotalPrice = (sub.multiply(squarePrice).add(additionalAmount)).multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                     }
                 }
@@ -1239,9 +1240,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("2002".equals(computingFormula)) { // 固定费用
@@ -1256,9 +1257,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = additionalAmount.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("3003".equals(computingFormula)) { // 固定费用
@@ -1274,9 +1275,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("1101".equals(computingFormula)) { // 租金
@@ -1290,12 +1291,12 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = additionalAmount.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
-            }  else if ("1102".equals(computingFormula)) { // 租金
+            } else if ("1102".equals(computingFormula)) { // 租金
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(roomDto.getRoomRent()));
                 feePrice = additionalAmount.setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
 
@@ -1306,12 +1307,12 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = additionalAmount.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
-            }else if ("4004".equals(computingFormula)) {
+            } else if ("4004".equals(computingFormula)) {
                 feePrice = new BigDecimal(Double.parseDouble(feeDto.getAmount()));
                 BigDecimal cycle = null;
                 if (!StringUtil.isEmpty(feeDto.getCycle())) {
@@ -1320,9 +1321,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = feePrice.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("5005".equals(computingFormula)) {
@@ -1345,9 +1346,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                     if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                         cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                     }
-                    if(cycle == null){
+                    if (cycle == null) {
                         feeTotalPrice = new BigDecimal(0);
-                    }else {
+                    } else {
                         feeTotalPrice = (sub.multiply(squarePrice).add(additionalAmount)).multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                     }
                 }
@@ -1361,9 +1362,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = feePrice.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("7007".equals(computingFormula)) { //自定义公式
@@ -1376,9 +1377,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = feePrice.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("9009".equals(computingFormula)) {  //(本期度数-上期度数)*动态单价+附加费
@@ -1401,9 +1402,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                     if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                         cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                     }
-                    if(cycle == null){
+                    if (cycle == null) {
                         feeTotalPrice = new BigDecimal(0);
-                    }else {
+                    } else {
                         feeTotalPrice = (sub.multiply(squarePrice).add(additionalAmount)).multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                     }
                 }
@@ -1436,9 +1437,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("2002".equals(computingFormula)) { // 固定费用
@@ -1455,9 +1456,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = additionalAmount.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("3003".equals(computingFormula)) { // 固定费用
@@ -1473,9 +1474,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = (squarePrice.multiply(builtUpArea).add(additionalAmount)).multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("1101".equals(computingFormula)) { // 租金
@@ -1489,12 +1490,12 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = additionalAmount.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
-            }else if ("1102".equals(computingFormula)) { // 租金
+            } else if ("1102".equals(computingFormula)) { // 租金
                 BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(roomDto.getRoomRent()));
                 feePrice = additionalAmount.setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
 
@@ -1505,9 +1506,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = additionalAmount.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("4004".equals(computingFormula)) {  //动态费用
@@ -1520,9 +1521,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = feePrice.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("5005".equals(computingFormula)) {  //(本期度数-上期度数)*单价+附加费
@@ -1546,9 +1547,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                     if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                         cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                     }
-                    if(cycle == null){
+                    if (cycle == null) {
                         feeTotalPrice = new BigDecimal(0);
-                    }else {
+                    } else {
                         feeTotalPrice = (sub.multiply(squarePrice).add(additionalAmount)).multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                     }
                 }
@@ -1562,9 +1563,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = feePrice.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("7007".equals(computingFormula)) { //自定义公式
@@ -1577,9 +1578,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = feePrice.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("8008".equals(computingFormula)) {  //手动动态费用
@@ -1592,9 +1593,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                 if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                     cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                 }
-                if(cycle == null){
+                if (cycle == null) {
                     feeTotalPrice = new BigDecimal(0);
-                }else {
+                } else {
                     feeTotalPrice = feePrice.multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                 }
             } else if ("9009".equals(computingFormula)) {  //(本期度数-上期度数)*动态单价+附加费
@@ -1617,9 +1618,9 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
                     if (!StringUtil.isEmpty(feeDto.getCustEndTime())) {
                         cycle = new BigDecimal(dayCompare(feeDto.getEndTime(), DateUtil.getDateFromStringB(feeDto.getCustEndTime())));
                     }
-                    if(cycle == null){
+                    if (cycle == null) {
                         feeTotalPrice = new BigDecimal(0);
-                    }else {
+                    } else {
                         feeTotalPrice = sub.multiply(squarePrice).add(additionalAmount).multiply(cycle).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP);
                     }
                 }
@@ -1725,7 +1726,7 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
 
         String value = feeDto.getComputingFormulaText();
 
-        if(StringUtil.isEmpty(value)){
+        if (StringUtil.isEmpty(value)) {
             return new BigDecimal(0);
         }
 
@@ -1746,11 +1747,11 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
             value = value.replace("F", roomDto.getFloorArea());
         } else if (value.contains("U")) { //处理单元
             value = value.replace("U", roomDto.getUnitArea());
-        } else if (value.contains("RL")){
+        } else if (value.contains("RL")) {
             List<RoomAttrDto> roomAttrDtos = roomDto.getRoomAttrDto();
-            if(roomAttrDtos != null && roomAttrDtos.size() > 0){
-                for(RoomAttrDto roomAttrDto : roomAttrDtos){
-                    value = value.replace("RL"+roomAttrDto.getSpecCd(), roomAttrDto.getValue());
+            if (roomAttrDtos != null && roomAttrDtos.size() > 0) {
+                for (RoomAttrDto roomAttrDto : roomAttrDtos) {
+                    value = value.replace("RL" + roomAttrDto.getSpecCd(), roomAttrDto.getValue());
                 }
             }
         } else if (value.contains("R")) { //处理 房屋面积
@@ -1814,8 +1815,8 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
             }
             //判断当前费用是不是导入费用
             oweMonth = 1.0;
-        }else if(FeeDto.FEE_FLAG_CYCLE_ONCE.equals(feeDto.getFeeFlag())){
-            if(feeDto.getDeadlineTime() != null) {
+        } else if (FeeDto.FEE_FLAG_CYCLE_ONCE.equals(feeDto.getFeeFlag())) {
+            if (feeDto.getDeadlineTime() != null) {
                 maxEndTime = feeDto.getDeadlineTime();
             }
             Date billEndTime = DateUtil.getCurrentDate();
@@ -2167,29 +2168,27 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
     }
 
     /**
-     *
      * @param feeDto
      * @param cycle
      */
-    public void dealRentRateCycle(FeeDto feeDto,double cycle){
+    public void dealRentRateCycle(FeeDto feeDto, double cycle) {
 
         if (!FeeConfigDto.COMPUTING_FORMULA_RANT_RATE.equals(feeDto.getComputingFormula())) {
             return;
         }
 
         Date endTime = feeDto.getEndTime();
-        Date date = getTargetEndTime(cycle,endTime);
+        Date date = getTargetEndTime(cycle, endTime);
         feeDto.setDeadlineTime(date);
         dealRentRate(feeDto);
 
     }
 
     /**
-     *
      * @param feeDto
      * @param custEndTime
      */
-    public void dealRentRateCustEndTime(FeeDto feeDto,Date custEndTime){
+    public void dealRentRateCustEndTime(FeeDto feeDto, Date custEndTime) {
 
         if (!FeeConfigDto.COMPUTING_FORMULA_RANT_RATE.equals(feeDto.getComputingFormula())) {
             return;
@@ -2200,6 +2199,34 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
 
     }
 
+    @Override
+    public long computeOneIntegralQuantity(IntegralRuleConfigDto integralRuleConfigDto, JSONObject reqJson) {
+        String computingFormula = integralRuleConfigDto.getComputingFormula();
+        BigDecimal amountDec = null;
+        long amount = 0;
+        if (IntegralRuleConfigDto.COMPUTING_FORMULA_AREA.equals(computingFormula)) { //面积乘以单价
+            BigDecimal areaDec = new BigDecimal(Double.parseDouble(reqJson.getString("area")));
+            BigDecimal squarePriceDec = new BigDecimal(Double.parseDouble(integralRuleConfigDto.getSquarePrice()));
+            amountDec = areaDec.multiply(squarePriceDec).setScale(2, BigDecimal.ROUND_HALF_UP);
+        } else if (IntegralRuleConfigDto.COMPUTING_FORMULA_MONEY.equals(computingFormula)) { // 金额乘以单价
+            BigDecimal aDec = new BigDecimal(Double.parseDouble(reqJson.getString("amount")));
+            BigDecimal squarePriceDec = new BigDecimal(Double.parseDouble(integralRuleConfigDto.getSquarePrice()));
+            amountDec = aDec.multiply(squarePriceDec).setScale(2, BigDecimal.ROUND_HALF_UP);
+        } else if (IntegralRuleConfigDto.COMPUTING_FORMULA_FIXED.equals(computingFormula)) { // 固定积分
+            amountDec = new BigDecimal(Double.parseDouble(integralRuleConfigDto.getAdditionalAmount()));
+        } else {
+            amountDec = new BigDecimal(0);
+        }
+
+        if (IntegralRuleConfigDto.SCALE_UP.equals(integralRuleConfigDto.getScale())) {
+            amount = new Double(Math.ceil(amountDec.doubleValue())).longValue();
+        } else {
+            amount = new Double(Math.floor(amountDec.doubleValue())).longValue();
+        }
+        integralRuleConfigDto.setQuantity(amount + "");
+        return amount;
+    }
+
     /**
      * 租金处理
      *
@@ -2268,7 +2295,7 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
         double maxCycle = Math.ceil(curOweMonth / rateCycle);
 
         // 增长前的欠费
-        BigDecimal addTotalAmount = oweAmountDec ;
+        BigDecimal addTotalAmount = oweAmountDec;
         BigDecimal preCycleAmount = curFeePrice.multiply(new BigDecimal(rateCycle));
         BigDecimal rateDec = null; //递增周期所收费用
         BigDecimal lastRateAmountDec = null;
@@ -2284,7 +2311,7 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
             // 计算本轮的 计费起始时间
             Calendar curEndTimeCalender = Calendar.getInstance();
             curEndTimeCalender.setTime(rateStartTime);
-            curEndTimeCalender.add(Calendar.MONTH,new Double(curCycle).intValue());
+            curEndTimeCalender.add(Calendar.MONTH, new Double(curCycle).intValue());
             curEndTime = curEndTimeCalender.getTime();
             if (curCycle > curOweMonth) {
                 //不足增长周期增长率
@@ -2296,7 +2323,7 @@ public class ComputeFeeSMOImpl implements IComputeFeeSMO {
             //本期金额
             curAmount = rateDec.add(preCycleAmount);// 增长部分 + 上本期费用
             //如果计费起始时间 大于 递增开始时间 那么本轮 不计入
-            if(feeDto.getEndTime().getTime()< curEndTime.getTime()){
+            if (feeDto.getEndTime().getTime() < curEndTime.getTime()) {
                 addTotalAmount = addTotalAmount.add(curAmount); // 计入总的 费用中
             }
             preCycleAmount = curAmount;

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

@@ -20,9 +20,11 @@
         select t.config_id,t.config_id configId,t.irc_id,t.irc_id ircId,t.status_cd,t.status_cd
         statusCd,t.rule_id,t.rule_id ruleId,t.community_id,t.community_id communityId,
         ic.square_price squarePrice,ic.config_name
-        configName,ic.computing_formula computingFormula,ic.additional_amount additionalAmount,ic.scale,td.name computingFormulaName,td1.`name` scaleName
+        configName,ic.computing_formula computingFormula,ic.additional_amount additionalAmount,ic.scale,td.name computingFormulaName,td1.`name` scaleName,
+        ir.rule_name ruleName
         from integral_rule_config t
         left join integral_config ic on t.config_id = ic.config_id and ic.status_cd = '0'
+        left join integral_rule ir on t.rule_id = ir.rule_id and ir.status_cd = '0'
         left join t_dict td on ic.computing_formula = td.status_cd and td.table_name = 'integral_config' and td.table_columns = 'computing_formula'
         left join t_dict td1 on ic.scale = td1.status_cd and td1.table_name = 'integral_config' and td1.table_columns = 'scale'
         where 1 =1

+ 6 - 6
java110-db/src/main/resources/mapper/acct/IntegralRuleFeeV1ServiceDaoImplMapper.xml

@@ -74,9 +74,6 @@
         <if test="payMonth !=null and payMonth != ''">
             , t.pay_month= #{payMonth}
         </if>
-        <if test="irfId !=null and irfId != ''">
-            , t.irf_id= #{irfId}
-        </if>
         <if test="feeConfigName !=null and feeConfigName != ''">
             , t.fee_config_name= #{feeConfigName}
         </if>
@@ -89,13 +86,16 @@
         <if test="ruleId !=null and ruleId != ''">
             , t.rule_id= #{ruleId}
         </if>
-        <if test="communityId !=null and communityId != ''">
-            , t.community_id= #{communityId}
-        </if>
         <if test="feeConfigId !=null and feeConfigId != ''">
             , t.fee_config_id= #{feeConfigId}
         </if>
         where 1=1
+        <if test="irfId !=null and irfId != ''">
+            and t.irf_id= #{irfId}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
     </update>
 
     <!-- 查询积分规则费用数量 add by wuxw 2018-07-03 -->

+ 6 - 31
service-acct/src/main/java/com/java110/acct/cmd/integral/ComputePayFeeIntegralCmd.java

@@ -7,6 +7,7 @@ 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.core.smo.IComputeFeeSMO;
 import com.java110.doc.annotation.*;
 import com.java110.dto.couponRuleCpps.CouponRuleCppsDto;
 import com.java110.dto.couponRuleFee.CouponRuleFeeDto;
@@ -70,6 +71,9 @@ public class ComputePayFeeIntegralCmd extends Cmd {
     @Autowired
     private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
 
+    @Autowired
+    private IComputeFeeSMO computeFeeSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
 
@@ -125,39 +129,10 @@ public class ComputePayFeeIntegralCmd extends Cmd {
 
         long quantity = 0;
         for(IntegralRuleConfigDto integralRuleConfigDto:integralRuleConfigDtos){
-            quantity += computeOneIntegralQuantity(integralRuleConfigDto,reqJson);
+            quantity += computeFeeSMOImpl.computeOneIntegralQuantity(integralRuleConfigDto,reqJson);
         }
         return quantity;
     }
 
-    /**
-     * 计算计算积分
-     * @param integralRuleConfigDto
-     * @return
-     */
-    private long computeOneIntegralQuantity(IntegralRuleConfigDto integralRuleConfigDto,JSONObject reqJson) {
-       String computingFormula = integralRuleConfigDto.getComputingFormula();
-       BigDecimal amountDec = null;
-       long amount = 0;
-       if(IntegralRuleConfigDto.COMPUTING_FORMULA_AREA.equals(computingFormula)){ //面积乘以单价
-           BigDecimal areaDec = new BigDecimal(Double.parseDouble(reqJson.getString("area")));
-           BigDecimal squarePriceDec = new BigDecimal(Double.parseDouble(integralRuleConfigDto.getSquarePrice()));
-           amountDec = areaDec.multiply(squarePriceDec).setScale(2,BigDecimal.ROUND_HALF_UP);
-       }else if(IntegralRuleConfigDto.COMPUTING_FORMULA_MONEY.equals(computingFormula)){ // 金额乘以单价
-           BigDecimal aDec = new BigDecimal(Double.parseDouble(reqJson.getString("amount")));
-           BigDecimal squarePriceDec = new BigDecimal(Double.parseDouble(integralRuleConfigDto.getSquarePrice()));
-           amountDec = aDec.multiply(squarePriceDec).setScale(2,BigDecimal.ROUND_HALF_UP);
-       }else if(IntegralRuleConfigDto.COMPUTING_FORMULA_FIXED.equals(computingFormula)){ // 固定积分
-           amountDec = new BigDecimal(Double.parseDouble(integralRuleConfigDto.getAdditionalAmount()));
-       }else{
-           amountDec = new BigDecimal(0);
-       }
-
-       if(IntegralRuleConfigDto.SCALE_UP.equals(integralRuleConfigDto.getScale())){
-           amount = new Double(Math.ceil(amountDec.doubleValue())).longValue();
-       }else{
-           amount = new Double(Math.floor(amountDec.doubleValue())).longValue();
-       }
-       return amount;
-    }
+
 }

+ 325 - 0
service-job/src/main/java/com/java110/job/adapt/payment/integral/PayFeeGiftIntegralAdapt.java

@@ -0,0 +1,325 @@
+package com.java110.job.adapt.payment.integral;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.core.log.LoggerFactory;
+import com.java110.core.smo.IComputeFeeSMO;
+import com.java110.dto.RoomDto;
+import com.java110.dto.account.AccountDto;
+import com.java110.dto.couponPropertyPool.CouponPropertyPoolDto;
+import com.java110.dto.couponPropertyPoolConfig.CouponPropertyPoolConfigDto;
+import com.java110.dto.couponPropertyUser.CouponPropertyUserDto;
+import com.java110.dto.fee.FeeAttrDto;
+import com.java110.dto.fee.FeeDetailDto;
+import com.java110.dto.fee.FeeDto;
+import com.java110.dto.integralRuleConfig.IntegralRuleConfigDto;
+import com.java110.dto.integralRuleFee.IntegralRuleFeeDto;
+import com.java110.dto.logSystemError.LogSystemErrorDto;
+import com.java110.dto.owner.OwnerDto;
+import com.java110.entity.order.Business;
+import com.java110.intf.acct.*;
+import com.java110.intf.community.ICommunityInnerServiceSMO;
+import com.java110.intf.community.IRoomV1InnerServiceSMO;
+import com.java110.intf.fee.IFeeAttrInnerServiceSMO;
+import com.java110.intf.fee.IFeeDetailInnerServiceSMO;
+import com.java110.intf.fee.IFeeInnerServiceSMO;
+import com.java110.intf.user.IOwnerV1InnerServiceSMO;
+import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.po.account.AccountPo;
+import com.java110.po.accountDetail.AccountDetailPo;
+import com.java110.po.couponPropertyPool.CouponPropertyPoolPo;
+import com.java110.po.couponPropertyPoolDetail.CouponPropertyPoolDetailPo;
+import com.java110.po.couponPropertyUser.CouponPropertyUserPo;
+import com.java110.po.fee.PayFeeDetailPo;
+import com.java110.po.integralGiftDetail.IntegralGiftDetailPo;
+import com.java110.po.logSystemError.LogSystemErrorPo;
+import com.java110.service.smo.ISaveSystemErrorSMO;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.lock.DistributedLock;
+import com.java110.utils.util.*;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 缴费 赠送 积分
+ *
+ * @author fqz
+ * @date 2020-12-11  18:54
+ */
+@Component(value = "payFeeGiftIntegralAdapt")
+public class PayFeeGiftIntegralAdapt extends DatabusAdaptImpl {
+
+    private static Logger logger = LoggerFactory.getLogger(PayFeeGiftIntegralAdapt.class);
+
+    @Autowired
+    private ICommunityInnerServiceSMO communityInnerServiceSMO;
+
+    @Autowired
+    private ISaveSystemErrorSMO saveSystemErrorSMOImpl;
+
+    @Autowired
+    private IRoomV1InnerServiceSMO roomV1InnerServiceSMOImpl;
+
+
+    @Autowired
+    private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
+
+    @Autowired
+    private IFeeAttrInnerServiceSMO feeAttrInnerServiceSMOImpl;
+
+    @Autowired
+    private IFeeDetailInnerServiceSMO feeDetailInnerServiceSMOImpl;
+
+    @Autowired
+    private IIntegralRuleFeeV1InnerServiceSMO integralRuleFeeV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IIntegralRuleConfigV1InnerServiceSMO integralRuleConfigV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IAccountInnerServiceSMO accountInnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerV1InnerServiceSMO ownerInnerServiceSMOImpl;
+
+
+    @Autowired
+    private IIntegralGiftDetailV1InnerServiceSMO integralGiftDetailV1InnerServiceSMOImpl;
+
+
+    @Autowired
+    private IComputeFeeSMO computeFeeSMOImpl;
+
+    //模板信息推送地址
+    private static String sendMsgUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";
+
+    @Override
+    public void execute(Business business, List<Business> businesses) {
+        JSONObject data = business.getData();
+
+        if (data != null) {
+            logger.debug("请求日志:{}", data);
+        }
+        JSONArray businessPayFeeDetails = null;
+        if (data == null) {
+            FeeDetailDto feeDetailDto = new FeeDetailDto();
+            feeDetailDto.setbId(business.getbId());
+            List<FeeDetailDto> feeDetailDtos = feeDetailInnerServiceSMOImpl.queryFeeDetails(feeDetailDto);
+            Assert.listOnlyOne(feeDetailDtos, "未查询到缴费记录");
+            businessPayFeeDetails = JSONArray.parseArray(JSONArray.toJSONString(feeDetailDtos, SerializerFeature.WriteDateUseDateFormat));
+        } else if (data.containsKey(PayFeeDetailPo.class.getSimpleName())) {
+            Object bObj = data.get(PayFeeDetailPo.class.getSimpleName());
+            if (bObj instanceof JSONObject) {
+                businessPayFeeDetails = new JSONArray();
+                businessPayFeeDetails.add(bObj);
+            } else if (bObj instanceof Map) {
+                businessPayFeeDetails = new JSONArray();
+                businessPayFeeDetails.add(JSONObject.parseObject(JSONObject.toJSONString(bObj)));
+            } else if (bObj instanceof List) {
+                businessPayFeeDetails = JSONArray.parseArray(JSONObject.toJSONString(bObj));
+            } else {
+                businessPayFeeDetails = (JSONArray) bObj;
+            }
+        } else {
+            if (data instanceof JSONObject) {
+                businessPayFeeDetails = new JSONArray();
+                businessPayFeeDetails.add(data);
+            }
+        }
+
+        if (businessPayFeeDetails == null) {
+            return;
+        }
+        for (int bPayFeeDetailIndex = 0; bPayFeeDetailIndex < businessPayFeeDetails.size(); bPayFeeDetailIndex++) {
+            JSONObject businessPayFeeDetail = businessPayFeeDetails.getJSONObject(bPayFeeDetailIndex);
+            doPayFeeDetail(business, businessPayFeeDetail);
+        }
+    }
+
+    private void doPayFeeDetail(Business business, JSONObject businessPayFeeDetail) {
+        try {
+            //查询缴费明细
+            PayFeeDetailPo payFeeDetailPo = BeanConvertUtil.covertBean(businessPayFeeDetail, PayFeeDetailPo.class);
+            FeeDto feeDto = new FeeDto();
+            feeDto.setFeeId(payFeeDetailPo.getFeeId());
+            feeDto.setCommunityId(payFeeDetailPo.getCommunityId());
+            List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
+
+            Assert.listOnlyOne(feeDtos, "未查询到费用信息");
+
+            IntegralRuleFeeDto integralRuleFeeDto = new IntegralRuleFeeDto();
+            integralRuleFeeDto.setFeeConfigId(feeDtos.get(0).getConfigId());
+            integralRuleFeeDto.setCurTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+            integralRuleFeeDto.setCommunityId(payFeeDetailPo.getCommunityId());
+            integralRuleFeeDto.setCycle(payFeeDetailPo.getCycles());
+            List<IntegralRuleFeeDto> integralRuleFeeDtos = integralRuleFeeV1InnerServiceSMOImpl.queryIntegralRuleFees(integralRuleFeeDto);
+
+            if (integralRuleFeeDtos == null || integralRuleFeeDtos.size() < 1) {
+                return;
+            }
+
+            List<String> ruleIds = new ArrayList<>();
+            for (IntegralRuleFeeDto tmpCouponRuleFeeDto : integralRuleFeeDtos) {
+                ruleIds.add(tmpCouponRuleFeeDto.getRuleId());
+            }
+
+            IntegralRuleConfigDto integralRuleConfigDto = new IntegralRuleConfigDto();
+            integralRuleConfigDto.setRuleIds(ruleIds.toArray(new String[ruleIds.size()]));
+            List<IntegralRuleConfigDto> integralRuleConfigDtos = integralRuleConfigV1InnerServiceSMOImpl.queryIntegralRuleConfigs(integralRuleConfigDto);
+
+            if (integralRuleConfigDtos == null || integralRuleConfigDtos.size() < 1) {
+                return;
+            }
+
+            // 计算赠送 积分公式
+            long quantity = computeIntegralQuantity(integralRuleConfigDtos, feeDtos.get(0), payFeeDetailPo.getReceivedAmount());
+
+            if (quantity <= 0) {
+                return;
+            }
+            //赠送优惠券
+            giftIntegral(integralRuleConfigDtos, feeDtos.get(0), payFeeDetailPo, quantity);
+        } catch (Exception e) {
+            LogSystemErrorPo logSystemErrorPo = new LogSystemErrorPo();
+            logSystemErrorPo.setErrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_errId));
+            logSystemErrorPo.setErrType(LogSystemErrorDto.ERR_TYPE_COUPON);
+            logSystemErrorPo.setMsg(ExceptionUtil.getStackTrace(e));
+            saveSystemErrorSMOImpl.saveLog(logSystemErrorPo);
+            logger.error("通知异常", e);
+        }
+    }
+
+    private long computeIntegralQuantity(List<IntegralRuleConfigDto> integralRuleConfigDtos, FeeDto feeDto, String receivedAmount) {
+        JSONObject reqJson = new JSONObject();
+        reqJson.put("amount", receivedAmount);
+        reqJson.put("area", "1");
+        if (FeeDto.PAYER_OBJ_TYPE_ROOM.equals(feeDto.getPayerObjType())) {
+            RoomDto roomDto = new RoomDto();
+            roomDto.setRoomId(feeDto.getPayerObjId());
+            List<RoomDto> roomDtos = roomV1InnerServiceSMOImpl.queryRooms(roomDto);
+            Assert.listOnlyOne(roomDtos, "房屋不存在");
+            reqJson.put("area", roomDtos.get(0).getBuiltUpArea());
+        }
+
+        long quantity = 0;
+        for (IntegralRuleConfigDto integralRuleConfigDto : integralRuleConfigDtos) {
+            quantity += computeFeeSMOImpl.computeOneIntegralQuantity(integralRuleConfigDto, reqJson);
+        }
+        return quantity;
+    }
+
+    /**
+     * 赠送积分
+     *
+     * @param integralRuleConfigDtos
+     * @param feeDto
+     * @param payFeeDetailPo
+     */
+    private void giftIntegral(List<IntegralRuleConfigDto> integralRuleConfigDtos, FeeDto feeDto, PayFeeDetailPo payFeeDetailPo, long quantity) {
+
+
+        String ownerId = FeeAttrDto.getFeeAttrValue(feeDto, FeeAttrDto.SPEC_CD_OWNER_ID);
+
+        if (StringUtil.isEmpty(ownerId)) {
+            return;
+        }
+
+        //向积分账户中充值积分
+        AccountDto accountDto = new AccountDto();
+        accountDto.setObjId(ownerId);
+        accountDto.setObjType(AccountDto.ACCT_TYPE_INTEGRAL);
+        List<AccountDto> accountDtos = accountInnerServiceSMOImpl.queryAccounts(accountDto);
+
+        if (accountDtos == null || accountDtos.size() < 1) {
+            accountDtos = addAccountDto(accountDto);
+        }
+
+        AccountDetailPo accountDetailPo = new AccountDetailPo();
+        accountDetailPo.setAcctId(accountDtos.get(0).getAcctId());
+        accountDetailPo.setObjId(accountDtos.get(0).getObjId());
+        accountDetailPo.setObjType(accountDtos.get(0).getObjType());
+        accountDetailPo.setAmount(quantity + "");
+        int flag = accountInnerServiceSMOImpl.prestoreAccount(accountDetailPo);
+
+        if (flag < 1) {
+            throw new CmdException("扣款失败");
+        }
+
+        for (IntegralRuleConfigDto integralRuleConfigDto : integralRuleConfigDtos) {
+            try {
+                doGiftIntegral(integralRuleConfigDto, feeDto,accountDtos.get(0));
+            } catch (Exception e) {
+                LogSystemErrorPo logSystemErrorPo = new LogSystemErrorPo();
+                logSystemErrorPo.setErrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_errId));
+                logSystemErrorPo.setErrType(LogSystemErrorDto.ERR_TYPE_COUPON);
+                logSystemErrorPo.setMsg(ExceptionUtil.getStackTrace(e));
+                saveSystemErrorSMOImpl.saveLog(logSystemErrorPo);
+                logger.error("通知异常", e);
+            }
+        }
+
+    }
+
+    private List<AccountDto> addAccountDto(AccountDto accountDto) {
+        if (StringUtil.isEmpty(accountDto.getObjId())) {
+            return new ArrayList<>();
+        }
+        //开始锁代码
+        String requestId = DistributedLock.getLockUUID();
+        String key = this.getClass().getSimpleName() + "AddCountDto" + accountDto.getObjId();
+        try {
+            DistributedLock.waitGetDistributedLock(key, requestId);
+
+            AccountPo accountPo = new AccountPo();
+            accountPo.setAmount("0");
+            accountPo.setAcctId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_acctId));
+            accountPo.setObjId(accountDto.getObjId());
+            accountPo.setObjType(AccountDto.OBJ_TYPE_PERSON);
+            accountPo.setAcctType(AccountDto.ACCT_TYPE_INTEGRAL);
+            OwnerDto tmpOwnerDto = new OwnerDto();
+            tmpOwnerDto.setMemberId(accountDto.getObjId());
+            tmpOwnerDto.setCommunityId(accountDto.getObjId());
+            List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwners(tmpOwnerDto);
+            Assert.listOnlyOne(ownerDtos, "业主不存在");
+            accountPo.setAcctName(ownerDtos.get(0).getName());
+            accountPo.setPartId(ownerDtos.get(0).getCommunityId());
+            accountInnerServiceSMOImpl.saveAccount(accountPo);
+            List<AccountDto> accountDtos = accountInnerServiceSMOImpl.queryAccounts(accountDto);
+            return accountDtos;
+        } finally {
+            DistributedLock.releaseDistributedLock(requestId, key);
+        }
+    }
+
+    private void doGiftIntegral(IntegralRuleConfigDto integralRuleConfigDto, FeeDto feeDto,AccountDto accountDto) {
+
+        //先加明细
+        IntegralGiftDetailPo integralGiftDetailPo = new IntegralGiftDetailPo();
+        integralGiftDetailPo.setCommunityId(integralRuleConfigDto.getCommunityId());
+        integralGiftDetailPo.setAcctId(accountDto.getAcctId());
+        integralGiftDetailPo.setAcctName(accountDto.getAcctName());
+        integralGiftDetailPo.setAcctDetailId("-1");
+        integralGiftDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId("11"));
+        integralGiftDetailPo.setConfigId(integralRuleConfigDto.getConfigId());
+        integralGiftDetailPo.setConfigName(integralRuleConfigDto.getConfigName());
+        integralGiftDetailPo.setRuleId(integralRuleConfigDto.getRuleId());
+        integralGiftDetailPo.setRuleName(integralRuleConfigDto.getRuleName());
+        integralGiftDetailPo.setQuantity(integralRuleConfigDto.getQuantity());
+        integralGiftDetailPo.setCreateUserId(FeeAttrDto.getFeeAttrValue(feeDto, FeeAttrDto.SPEC_CD_OWNER_ID));
+        integralGiftDetailPo.setUserName(FeeAttrDto.getFeeAttrValue(feeDto, FeeAttrDto.SPEC_CD_OWNER_NAME));
+        integralGiftDetailPo.setTel(FeeAttrDto.getFeeAttrValue(feeDto, FeeAttrDto.SPEC_CD_OWNER_LINK));
+        integralGiftDetailV1InnerServiceSMOImpl.saveIntegralGiftDetail(integralGiftDetailPo);
+
+    }
+
+
+}

+ 5 - 0
service-job/src/main/java/com/java110/job/adapt/payment/integral/package-info.java

@@ -0,0 +1,5 @@
+/**
+ * 该包处理
+ * 缴费赠送 积分给业主
+ */
+package com.java110.job.adapt.payment.integral;