瀏覽代碼

feature 代码提交

xiahan 3 周之前
父節點
當前提交
a5dd5101b4

+ 6 - 3
zhsw-wechat-common/src/main/java/com/rongwei/wechat/system/service/impl/SwBillingRecordServiceImpl.java

@@ -287,8 +287,11 @@ public class SwBillingRecordServiceImpl extends ServiceImpl<SwBillingRecordDao,
      * @param user
      */
     public void calculateFees(List<SwBillManagementUnpaidDo> list, SwBillingRecordDo billingRecordDo, SwUserManagementDo user) {
-        // 对数据按照抄表日期排序
-        list = list.stream().sorted(Comparator.comparing(SwBillManagementUnpaidDo::getThismeterreadingdate)).collect(Collectors.toList());
+        if (list != null && !list.isEmpty()) {
+            // 对数据按照抄表日期排序
+            list = list.stream().sorted(Comparator.comparing(SwBillManagementUnpaidDo::getThismeterreadingdate)).collect(Collectors.toList());
+        }
+
 
         // 用户 账户余额
         BigDecimal accountbalance = user.getAccountbalance() == null ? BigDecimal.ZERO : user.getAccountbalance();
@@ -365,7 +368,7 @@ public class SwBillingRecordServiceImpl extends ServiceImpl<SwBillingRecordDao,
         // 账户余额= 划扣之后的账户余额=剩余的余额+扣款之后的剩余缴费金额
         billingRecordDo.setAccountbalance(accountbalance.add(paidin));
         //原余额(元) =划扣之前的账户余额
-        billingRecordDo.setOriginalbalance(user.getAccountbalance());
+        billingRecordDo.setOriginalbalance( user.getAccountbalance() != null ?user.getAccountbalance() : BigDecimal.ZERO);
         // 实际划扣的金额
         billingRecordDo.setBalancededuction(billingRecordDo.getOriginalbalance().subtract(accountbalance));
 

+ 4 - 2
zhsw-wechat-common/src/main/java/com/rongwei/wechat/system/wechat/impl/PaymentRecordServiceImpl.java

@@ -140,6 +140,9 @@ public class PaymentRecordServiceImpl implements PaymentRecordService {
             SwUserManagementDo swUserManagementDo = swUserManagementService.getOne(new LambdaQueryWrapper<SwUserManagementDo>()
                     .eq(SwUserManagementDo::getUsernumber, userNUMBER)
                     .eq(BaseDo::getDeleted, "0"));
+            if(swUserManagementDo==null){
+                throw new Exception("无法获取到用户信息");
+            }
             List<SwBillManagementUnpaidDo> unpaidDoList = new ArrayList<>();
             String zdId = createPaymentRecordVo.getZdId();
             if (StringUtils.isNotBlank(zdId)) {
@@ -155,8 +158,7 @@ public class PaymentRecordServiceImpl implements PaymentRecordService {
             List<SwBillManagementPaidDo> bills = swBillingRecordService.createBills(unpaidDoList, swBillingRecordDo);
             dataUpdate(swBillingRecordDo, swUserManagementDo, bills, unpaidDoList);
         } catch (Exception e) {
-            e.printStackTrace();
-            log.error("缴费记录生成失败原因为:{}", e.getMessage());
+            log.error("缴费记录生成失败原因为 户号:{},账单:{},金额:{} - 原因: {} | 异常类型: {}", createPaymentRecordVo.getUserNumber(), createPaymentRecordVo.getZdId(), createPaymentRecordVo.getPaymentAmount(), e.getMessage(), e.getClass().getSimpleName(), e);
         }
 
         return R.ok();