|
@@ -7,6 +7,7 @@ import com.rongwe.zhsw.system.domain.SwWaterUsageEntryDo;
|
|
|
import com.rongwei.commonservice.service.RedisService;
|
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
import com.rongwei.rwcommon.base.BaseDo;
|
|
|
+import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.zhsw.system.config.ContextHolder;
|
|
|
import com.rongwei.zhsw.system.utils.ZHSWCommonUtils;
|
|
@@ -142,7 +143,7 @@ public class BillGenerationServiceImpl {
|
|
|
// 校验是否可以生成账单
|
|
|
if (swUserManagementDo.getLastmeterreaddate() != null &&
|
|
|
swUserManagementDo.getLastmeterreaddate().compareTo(swWaterUsageEntry.getCurrentreadingdate()) > 0) {
|
|
|
- log.error("本次抄表日期:{}小于用户表最后一次抄表日期:{}",swWaterUsageEntry.getCurrentreadingdate(),swUserManagementDo.getLastmeterreaddate());
|
|
|
+ log.error("本次抄表日期:{}小于用户表最后一次抄表日期:{}", swWaterUsageEntry.getCurrentreadingdate(), swUserManagementDo.getLastmeterreaddate());
|
|
|
usageEntryDo.setState("3");
|
|
|
saveUsageEntryList.add(usageEntryDo);
|
|
|
continue;
|
|
@@ -259,6 +260,15 @@ public class BillGenerationServiceImpl {
|
|
|
BigDecimal thisreading = swWaterUsageEntryDo.getThisreading();
|
|
|
//当前用水
|
|
|
BigDecimal waterConsumption;
|
|
|
+ // 获取水价
|
|
|
+ BigDecimal waterPrice = swUserManagementDo.getWaterprice();
|
|
|
+ if (waterPrice == null || waterPrice.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ throw new CustomException("当前用户水价异常:" + waterPrice);
|
|
|
+ }
|
|
|
+ BigDecimal meterMaxValue = swUserManagementDo.getMetermaxvalue();
|
|
|
+ if (meterMaxValue == null || meterMaxValue.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ throw new CustomException("当前用户表具最大度数异常:" + meterMaxValue);
|
|
|
+ }
|
|
|
// 本次大于上次
|
|
|
if (thisreading.compareTo(lastreading) >= 0) {
|
|
|
waterConsumption = thisreading.subtract(lastreading);
|
|
@@ -266,8 +276,7 @@ public class BillGenerationServiceImpl {
|
|
|
// 本次抄表数小于上次抄表数 用表具的最大值-上次抄表数+本次抄表数
|
|
|
waterConsumption = swUserManagementDo.getMetermaxvalue().subtract(lastreading).add(thisreading).add(BigDecimal.ONE);
|
|
|
}
|
|
|
- // 获取水价
|
|
|
- BigDecimal waterprice = swUserManagementDo.getWaterprice();
|
|
|
+
|
|
|
Date currentreadingdate = swWaterUsageEntryDo.getCurrentreadingdate();
|
|
|
// 账单实例
|
|
|
SwBillManagementUnpaidDo swBillManagementUnpaidDo = new SwBillManagementUnpaidDo();
|
|
@@ -283,7 +292,7 @@ public class BillGenerationServiceImpl {
|
|
|
swBillManagementUnpaidDo.setUsername(swUserManagementDo.getUsername());
|
|
|
swBillManagementUnpaidDo.setUsertype(swUserManagementDo.getUsertypeid());
|
|
|
swBillManagementUnpaidDo.setAddress(swUserManagementDo.getAddress());
|
|
|
- swBillManagementUnpaidDo.setUnitprice(waterprice);
|
|
|
+ swBillManagementUnpaidDo.setUnitprice(waterPrice);
|
|
|
swBillManagementUnpaidDo.setCurrentwateruse(waterConsumption);
|
|
|
|
|
|
swBillManagementUnpaidDo.setLastmeterreadingdate(swWaterUsageEntryDo.getLastreadingdate());
|
|
@@ -317,16 +326,16 @@ public class BillGenerationServiceImpl {
|
|
|
// 优先金额减免
|
|
|
if (exemptionAmount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
// 计算减免用水
|
|
|
- exemptionWater = exemptionAmount.divide(waterprice, 2, RoundingMode.HALF_UP);
|
|
|
+ exemptionWater = exemptionAmount.divide(waterPrice, 2, RoundingMode.HALF_UP);
|
|
|
} else {
|
|
|
- exemptionAmount = exemptionWater.multiply(waterprice);
|
|
|
+ exemptionAmount = exemptionWater.multiply(waterPrice);
|
|
|
}
|
|
|
}
|
|
|
// log.debug("用户 {} 的减免计算:monthDiff={}, exemptionAmount={}, exemptionWater={}",
|
|
|
// swUserManagementDo.getUsernumber(), monthDiff, exemptionAmount, exemptionWater);
|
|
|
swBillManagementUnpaidDo.setReducedwateruse(exemptionWater);
|
|
|
swBillManagementUnpaidDo.setFeewaiver(exemptionAmount);
|
|
|
- swBillManagementUnpaidDo.setOughttohavepaid(waterprice.multiply(waterConsumption));
|
|
|
+ swBillManagementUnpaidDo.setOughttohavepaid(waterPrice.multiply(waterConsumption));
|
|
|
swBillManagementUnpaidDo.setWatertype(swUserManagementDo.getWatertype());
|
|
|
// 实际应缴=原应缴-减免
|
|
|
BigDecimal subtract = swBillManagementUnpaidDo.getOughttohavepaid().subtract(swBillManagementUnpaidDo.getFeewaiver());
|