Quellcode durchsuchen

feature 解决缺少属性导致得报错问题

xiahan vor 2 Monaten
Ursprung
Commit
6eaf11f8bc

+ 1 - 1
zhsw-common/src/main/java/com/rongwei/zhsw/system/utils/SaveConstans.java

@@ -11,7 +11,7 @@ public class SaveConstans {
     /**
      * 用户默认的token缓存时长
      */
-    public static final Integer DEFAULT_OWNER_CACHE_SECONDS=7200;
+    public static final Integer DEFAULT_OWNER_CACHE_SECONDS=86400;
     /**
      * 区域前缀
      */

+ 22 - 14
zhsw-common/src/main/java/com/rongwei/zhsw/system/wechat/impl/PaymentRecordServiceImpl.java

@@ -7,7 +7,6 @@ import com.rongwe.zhsw.system.domain.SwBillingRecordDo;
 import com.rongwe.zhsw.system.domain.SwUserManagementDo;
 import com.rongwe.zhsw.system.vo.CreatePaymentRecordVo;
 import com.rongwe.zhsw.system.vo.PaymentRocordVo;
-import com.rongwei.commonservice.service.impl.RedisServiceImpl;
 import com.rongwei.rwcommon.base.BaseDo;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.base.exception.CustomException;
@@ -129,7 +128,9 @@ public class PaymentRecordServiceImpl implements PaymentRecordService {
      * @return
      */
     @Override
+    @Transactional
     public R createRecord(CreatePaymentRecordVo createPaymentRecordVo) {
+        try {
         // 微信的openId
         String currentWeChatOpenId = WeChatUtils.getCurrentWeChatOpenId();
         String userNUMBER = createPaymentRecordVo.getUserNumber();
@@ -145,29 +146,36 @@ public class PaymentRecordServiceImpl implements PaymentRecordService {
         if (StringUtils.isNotBlank(zdId)) {
             unpaidDoList = swBillManagementUnpaidService.getBaseMapper().selectBatchIds(Arrays.asList(zdId.split(",")));
         }
-        // 生成缴费记录
-        SwBillingRecordDo swBillingRecordDo = generateRecord(swUserManagementDo, unpaidDoList, createPaymentRecordVo.getPaymentAmount(),
-                createPaymentRecordVo.getOrderNo(), currentWeChatOpenId);
 
-        // 待缴账单转为已缴账单
-        List<SwBillManagementPaidDo> bills = swBillingRecordService.createBills(unpaidDoList, swBillingRecordDo);
-        dataUpdate(swBillingRecordDo,swUserManagementDo,bills,unpaidDoList);
+
+
+            // 生成缴费记录
+            SwBillingRecordDo swBillingRecordDo = generateRecord(swUserManagementDo, unpaidDoList, createPaymentRecordVo.getPaymentAmount(),
+                    createPaymentRecordVo.getOrderNo(), currentWeChatOpenId);
+            // 待缴账单转为已缴账单
+            List<SwBillManagementPaidDo> bills = swBillingRecordService.createBills(unpaidDoList, swBillingRecordDo);
+            dataUpdate(swBillingRecordDo, swUserManagementDo, bills, unpaidDoList);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("缴费记录生成失败原因为:{}",e.getMessage());
+        }
+
         return R.ok();
     }
 
     /**
      * 数据更新
      */
-    @Transactional
-    public void dataUpdate(SwBillingRecordDo swBillingRecordDo,SwUserManagementDo swUserManagementDo,List<SwBillManagementPaidDo> bills,
-            List<SwBillManagementUnpaidDo> unpaidDoList){
+
+    public void dataUpdate(SwBillingRecordDo swBillingRecordDo, SwUserManagementDo swUserManagementDo, List<SwBillManagementPaidDo> bills,
+                           List<SwBillManagementUnpaidDo> unpaidDoList) {
         BigDecimal balanceChange = swBillingRecordDo.getAfterpaymentbalance().subtract(swUserManagementDo.getAccountbalance());
         swUserManagementService.balanceAdd(swUserManagementDo.getId(), balanceChange);
         swBillingRecordService.save(swBillingRecordDo);
-        if(!bills.isEmpty()){
+        if (!bills.isEmpty()) {
             swBillManagementPaidService.saveBatch(bills);
         }
-        if(!unpaidDoList.isEmpty()){
+        if (!unpaidDoList.isEmpty()) {
             swBillManagementUnpaidService.getBaseMapper().deleteByIds(unpaidDoList.stream().map(SwBillManagementUnpaidDo::getId).collect(Collectors.toList()));
         }
 
@@ -175,7 +183,7 @@ public class PaymentRecordServiceImpl implements PaymentRecordService {
 
 
     public SwBillingRecordDo generateRecord(SwUserManagementDo swUserManagementDo, List<SwBillManagementUnpaidDo> unpaidDoList,
-                                            BigDecimal paymentAmount,String orderNo,String openId) {
+                                            BigDecimal paymentAmount, String orderNo, String openId) {
         Date now = new Date();
         Calendar instance = Calendar.getInstance();
         instance.setTime(now);
@@ -198,7 +206,7 @@ public class PaymentRecordServiceImpl implements PaymentRecordService {
         swBillingRecordDo.setUsertype(swUserManagementDo.getUsertypeid());
         /******************实缴******************/
         swBillingRecordDo.setPaidin(paymentAmount);
-        swBillingRecordService.calculateFees(unpaidDoList, swBillingRecordDo,swUserManagementDo);
+        swBillingRecordService.calculateFees(unpaidDoList, swBillingRecordDo, swUserManagementDo);
         swBillingRecordDo.setPaymentmethod("微信");
         // 微信支付
         swBillingRecordDo.setDatasource("3");

+ 14 - 5
zhsw-entity/src/main/java/com/rongwe/zhsw/system/vo/WeChatPayTransactionVo.java

@@ -1,5 +1,6 @@
 package com.rongwe.zhsw.system.vo;
 
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Data;
 
@@ -13,6 +14,7 @@ import java.util.List;
  * @date 2025/03/25
  */
 @Data
+@JsonIgnoreProperties(ignoreUnknown = true)
 public class WeChatPayTransactionVo {
     @JsonProperty("transaction_id")
     private String transactionId;
@@ -40,7 +42,8 @@ public class WeChatPayTransactionVo {
     private SceneInfo sceneInfo;
 
     @Data
-    class Amount {
+    @JsonIgnoreProperties(ignoreUnknown = true)
+    static  class Amount {
         @JsonProperty("payer_total")
         private int payerTotal;
         private int total;
@@ -51,7 +54,8 @@ public class WeChatPayTransactionVo {
         // Getters and Setters
     }
     @Data
-    class PromotionDetail {
+    @JsonIgnoreProperties(ignoreUnknown = true)
+    static  class PromotionDetail {
         private int amount;
         @JsonProperty("wechatpay_contribute")
         private int wechatpayContribute;
@@ -69,10 +73,13 @@ public class WeChatPayTransactionVo {
         @JsonProperty("goods_detail")
         private List<GoodsDetail> goodsDetails;
 
+        private String type;
+
         // Getters and Setters
     }
     @Data
-    class GoodsDetail {
+    @JsonIgnoreProperties(ignoreUnknown = true)
+    static  class GoodsDetail {
         @JsonProperty("goods_remark")
         private String goodsRemark;
         private int quantity;
@@ -86,12 +93,14 @@ public class WeChatPayTransactionVo {
         // Getters and Setters
     }
     @Data
-    class Payer {
+    @JsonIgnoreProperties(ignoreUnknown = true)
+    static  class Payer {
         private String openid;
     }
 
     @Data
-    class SceneInfo {
+    @JsonIgnoreProperties(ignoreUnknown = true)
+    static  class SceneInfo {
         @JsonProperty("device_id")
         private String deviceId;
     }

+ 2 - 0
zhsw-server/src/main/java/com/rongwei/zhsw/system/controller/weChat/PayMentController.java

@@ -36,6 +36,7 @@ public class PayMentController {
      */
     @PostMapping("/record/create")
     private R createRecord(@RequestBody CreatePaymentRecordVo createPaymentRecordVo) {
+        log.debug("开始生成微信缴费记录.参数为:{}",createPaymentRecordVo);
         return paymentRecordService.createRecord(createPaymentRecordVo);
     }
 
@@ -47,6 +48,7 @@ public class PayMentController {
      */
     @PostMapping("/prepayOrder")
     public R prepayOrder(@RequestBody WxPrepayOrderVo vo) {
+        log.debug("开始生成微信缴费预下单.参数为:{}",vo);
         return payMentService.paymentInitiation(vo);
     }