|
@@ -116,8 +116,8 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
// 原应缴
|
|
// 原应缴
|
|
BigDecimal oughttohavepaid = unpaidDo.getUnitprice().multiply(currentUsing);
|
|
BigDecimal oughttohavepaid = unpaidDo.getUnitprice().multiply(currentUsing);
|
|
BigDecimal actualDue = oughttohavepaid.subtract(unpaidDo.getFeewaiver()).add(unpaidDo.getLatefees());
|
|
BigDecimal actualDue = oughttohavepaid.subtract(unpaidDo.getFeewaiver()).add(unpaidDo.getLatefees());
|
|
- if(actualDue.compareTo(BigDecimal.ZERO)<=0){
|
|
|
|
- actualDue=BigDecimal.ZERO;
|
|
|
|
|
|
+ if (actualDue.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
|
+ actualDue = BigDecimal.ZERO;
|
|
}
|
|
}
|
|
swBillManagementUnpaidService.update(new LambdaUpdateWrapper<SwBillManagementUnpaidDo>()
|
|
swBillManagementUnpaidService.update(new LambdaUpdateWrapper<SwBillManagementUnpaidDo>()
|
|
.eq(SwBillManagementUnpaidDo::getId, billId)
|
|
.eq(SwBillManagementUnpaidDo::getId, billId)
|
|
@@ -221,12 +221,12 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
throw new CustomException("预收账单数量为空!");
|
|
throw new CustomException("预收账单数量为空!");
|
|
}
|
|
}
|
|
|
|
|
|
- //1. 预收账单根据户号分组 创建时间正序
|
|
|
|
|
|
+ //1. 预收账单根据户号分组 抄表时间品牌需
|
|
return unpaidDoList.stream()
|
|
return unpaidDoList.stream()
|
|
.collect(Collectors.groupingBy(SwBillManagementUnpaidDo::getUsernumber,
|
|
.collect(Collectors.groupingBy(SwBillManagementUnpaidDo::getUsernumber,
|
|
Collectors.collectingAndThen(
|
|
Collectors.collectingAndThen(
|
|
Collectors.toList(), list -> list.stream()
|
|
Collectors.toList(), list -> list.stream()
|
|
- .sorted(Comparator.comparing(SwBillManagementUnpaidDo::getCreatedate))
|
|
|
|
|
|
+ .sorted(Comparator.comparing(SwBillManagementUnpaidDo::getThismeterreadingdate))
|
|
.collect(Collectors.toList())
|
|
.collect(Collectors.toList())
|
|
)
|
|
)
|
|
));
|
|
));
|
|
@@ -252,39 +252,48 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
|
|
|
|
|
|
BigDecimal billAmount = BigDecimal.ZERO;
|
|
BigDecimal billAmount = BigDecimal.ZERO;
|
|
List<SwBillManagementUnpaidDo> unpaidDos = new ArrayList<>();
|
|
List<SwBillManagementUnpaidDo> unpaidDos = new ArrayList<>();
|
|
|
|
+ // 生成的已缴账单实体
|
|
SwBillManagementPaidDo paid;
|
|
SwBillManagementPaidDo paid;
|
|
|
|
|
|
|
|
|
|
// 获取当前用户和批次信息
|
|
// 获取当前用户和批次信息
|
|
SysUserVo currentUser = ZHSWCommonUtils.getCurrentUser();
|
|
SysUserVo currentUser = ZHSWCommonUtils.getCurrentUser();
|
|
String paymentBatchId = SecurityUtil.getUUID();
|
|
String paymentBatchId = SecurityUtil.getUUID();
|
|
|
|
+ // 实际应缴为0的账单信息
|
|
|
|
+ List<SwBillManagementUnpaidDo> ZeroDueData = swBillManagementUnpaidDos.stream()
|
|
|
|
+ .filter(data -> data.getActualdue().compareTo(BigDecimal.ZERO) <= 0)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ // 需要被删除的代缴账单信息
|
|
|
|
+ /**************实际应缴为0的数据**********************/
|
|
|
|
+ // List<SwBillManagementUnpaidDo> removeUnpaidDatas=new ArrayList<>();
|
|
|
|
+ for (SwBillManagementUnpaidDo zeroDueDatum : ZeroDueData) {
|
|
|
|
+ // 实体生成
|
|
|
|
+ paid = new SwBillManagementPaidDo();
|
|
|
|
+ BeanUtils.copyProperties(zeroDueDatum, paid);
|
|
|
|
+ paid.setStatus(PAIDINSTATUS);
|
|
|
|
+ paid.setPaymentrecordid(paymentBatchId);
|
|
|
|
+ ZHSWCommonUtils.initModelGeneralParameters(paid, null);
|
|
|
|
+ transferAccountDo.getPaidDoList().add(paid);
|
|
|
|
+ }
|
|
|
|
+ /**************实际应缴大于0的数据**********************/
|
|
|
|
+ List<SwBillManagementUnpaidDo> NoZeroDueData = swBillManagementUnpaidDos.stream()
|
|
|
|
+ .filter(data -> data.getActualdue().compareTo(BigDecimal.ZERO) > 0)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
-
|
|
|
|
- //合并并排序账单
|
|
|
|
- List<SwBillManagementUnpaidDo> sortedBills = mergeAndSortBills(swBillManagementUnpaidDos);
|
|
|
|
-
|
|
|
|
- for (SwBillManagementUnpaidDo unpaidDo : sortedBills) {
|
|
|
|
-
|
|
|
|
- if (unpaidDo == null) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ for (SwBillManagementUnpaidDo unpaidDo : NoZeroDueData) {
|
|
if (isBalanceExceeded) {
|
|
if (isBalanceExceeded) {
|
|
transferAccountDo.getOfficeIds().add(unpaidDo.getId());
|
|
transferAccountDo.getOfficeIds().add(unpaidDo.getId());
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
-
|
|
|
|
//当累计的账单的 【原应缴(元)】-【总减免(元)】 +【滞纳金(元)】 <= 账户余额,生成计费记录
|
|
//当累计的账单的 【原应缴(元)】-【总减免(元)】 +【滞纳金(元)】 <= 账户余额,生成计费记录
|
|
billAmount = billAmount.add(unpaidDo.getOughttohavepaid()).subtract(unpaidDo.getFeewaiver()).add(unpaidDo.getLatefees());
|
|
billAmount = billAmount.add(unpaidDo.getOughttohavepaid()).subtract(unpaidDo.getFeewaiver()).add(unpaidDo.getLatefees());
|
|
-
|
|
|
|
if (billAmount.compareTo(user.getAccountbalance()) <= 0) {
|
|
if (billAmount.compareTo(user.getAccountbalance()) <= 0) {
|
|
//转正式账单后 生成缴费记录,生成 已缴费账单,删除待缴费记录,更新用户余额
|
|
//转正式账单后 生成缴费记录,生成 已缴费账单,删除待缴费记录,更新用户余额
|
|
|
|
|
|
// 记录待删除ID
|
|
// 记录待删除ID
|
|
transferAccountDo.getDelUnpaidIds().add(unpaidDo.getId());
|
|
transferAccountDo.getDelUnpaidIds().add(unpaidDo.getId());
|
|
|
|
|
|
- //2.生成已缴费记录
|
|
|
|
|
|
+ //2.生成已缴账单
|
|
paid = new SwBillManagementPaidDo();
|
|
paid = new SwBillManagementPaidDo();
|
|
BeanUtils.copyProperties(unpaidDo, paid);
|
|
BeanUtils.copyProperties(unpaidDo, paid);
|
|
paid.setStatus(PAIDINSTATUS);
|
|
paid.setStatus(PAIDINSTATUS);
|