浏览代码

feature 代码提交

xiahan 4 月之前
父节点
当前提交
b60e509b8b

+ 39 - 12
zhsw-common/src/main/java/com/rongwei/zhsw/system/service/impl/SwBillManagementUnpaidServiceImpl.java

@@ -260,24 +260,51 @@ public class SwBillManagementUnpaidServiceImpl extends ServiceImpl<SwBillManagem
         SysUserVo currentUser = ZHSWCommonUtils.getCurrentUser();
         String paymentBatchId = SecurityUtil.getUUID();
         // 实际应缴为0的账单信息
-        List<SwBillManagementUnpaidDo> ZeroDueData = swBillManagementUnpaidDos.stream()
+        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);
-
-            // 记录待删除ID
-            transferAccountDo.getDelUnpaidIds().add(zeroDueDatum.getId());
+        if(!zeroDueData.isEmpty()){
+            // 生成缴费记录
+            SwBillingRecordDo record = swBillingRecordService.buildBaseBillingRecord(currentUser, user);
+            record.setId(SecurityUtil.getUUID());
+            record.setDatasource("2");
+            record.setPaidin(BigDecimal.ZERO);
+            BigDecimal actualDue = zeroDueData.stream().map(SwBillManagementUnpaidDo::getActualdue).reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal yyj = zeroDueData.stream().map(SwBillManagementUnpaidDo::getOughttohavepaid).reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal znj = zeroDueData.stream().map(SwBillManagementUnpaidDo::getLatefees).reduce(BigDecimal.ZERO, BigDecimal::add);
+            //总减免
+            record.setAllfeewaiver(actualDue);
+            //原应缴
+            record.setOughttohavepaid(yyj);
+            //滞纳金
+            record.setLatefees(znj);
+            // record= 划扣之后的账户余额=剩余的余额+扣款之后的剩余缴费金额
+            record.setAccountbalance(user.getAccountbalance());
+            //原余额(元) =划扣之前的账户余额
+            record.setOriginalbalance(user.getAccountbalance());
+            // 实际划扣的金额
+            record.setBalancededuction(BigDecimal.ZERO);
+            // 【实际应缴(元)】
+            record.setActualdue(BigDecimal.ZERO);
+            //【实缴后余额(元)】=【账户余额】+ 【本次实缴(元-整)】- 【实际应缴(元)】
+            record.setAfterpaymentbalance(user.getAccountbalance());
+            swBillingRecordService.save(record);
+            for (SwBillManagementUnpaidDo zeroDueDatum : zeroDueData) {
+                // 实体生成
+                paid = new SwBillManagementPaidDo();
+                BeanUtils.copyProperties(zeroDueDatum, paid);
+                paid.setStatus(PAIDINSTATUS);
+                paid.setPaymentrecordid(record.getId());
+                ZHSWCommonUtils.initModelGeneralParameters(paid, null);
+                transferAccountDo.getPaidDoList().add(paid);
+                // 记录待删除ID
+                transferAccountDo.getDelUnpaidIds().add(zeroDueDatum.getId());
+            }
         }
+
         /**************实际应缴大于0的数据**********************/
         List<SwBillManagementUnpaidDo> NoZeroDueData = swBillManagementUnpaidDos.stream()
                 .filter(data -> data.getActualdue().compareTo(BigDecimal.ZERO) > 0)