Эх сурвалжийг харах

fix(payment):修正微信支付分账逻辑中的金额计算问题

- 在计算分账金额时加入保险费用扣除
- 调整平台所得金额的计算方式,确保包含保险费用
- 增加多个日志输出点以方便调试和追踪金额计算过程- 确保门店、商户及平台的分账金额计算准确无误
wzq 3 өдөр өмнө
parent
commit
b4660e3254

+ 7 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/WeChatPayService.java

@@ -289,6 +289,7 @@ public class WeChatPayService {
             BigDecimal reduce = orderProInfoList.stream().map(AppOrderProInfo::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
             insurePrice = insurePrice.add(reduce);
         }
+        log.info("------------------------------------------------保险金额:{}", insurePrice);
         //创建预分账详情
         String orgCode = appOrder.getOrgCode();
         SysDepart depart = sysDepartMapper.selectOne(Wrappers.lambdaQuery(SysDepart.class).eq(SysDepart::getOrgCode, orgCode).last("limit 1"));
@@ -308,7 +309,8 @@ public class WeChatPayService {
             //微信手续费,不足1分按1分算(当计算值小于0.01时强制提升至0.01)
             BigDecimal FEE = calculate(price, new BigDecimal("0.006"));
 
-            price = price.subtract(FEE);
+            price = price.subtract(FEE).subtract(insurePrice);
+            log.info("------------------------------------------------分账金额:{}", price);
 
             //商户(分账给平台)
             if (depart.getSystemType() == 1) {
@@ -327,6 +329,7 @@ public class WeChatPayService {
 
                 //平台所得金额(金额*比例-微信手续费)
                 Integer procedureFee = RatiosUtil.amount_fee(allocate[2].add(insurePrice));
+                log.info("------------------------------------------------平台所得金额:{},{}", allocate[2], procedureFee);
                 AppProfitSharingInfo PTAppProfitSharingInfo = getPtAppProfitSharingInfo(appOrder, PT, procedureFee, insurePrice);
                 if (allocate[2] != null && ((allocate[2].add(insurePrice)).compareTo(BigDecimal.ZERO) == 0)) {
                     PTAppProfitSharingInfo.setAmount(RatiosUtil.amount_fee(BigDecimal.ZERO));
@@ -347,6 +350,7 @@ public class WeChatPayService {
                 MDAppProfitSharingInfo.setType(1);
                 MDAppProfitSharingInfo.setRatio(MD);
                 MDAppProfitSharingInfo.setPreAmount(RatiosUtil.amount_fee(allocate[0]));
+                log.info("------------------------------------------------门店所得金额:{}", allocate[0]);
                 MDAppProfitSharingInfo.setCumulative(addProfitSharingInfos(MDAppProfitSharingInfo.getOrgCode()));
                 appProfitSharingInfoMapper.insert(MDAppProfitSharingInfo);
                 //商户所得金额
@@ -359,6 +363,7 @@ public class WeChatPayService {
                 SHAppProfitSharingInfo.setType(2);
                 SHAppProfitSharingInfo.setRatio(SH);
                 SHAppProfitSharingInfo.setPreAmount(RatiosUtil.amount_fee(allocate[1]));
+                log.info("------------------------------------------------商户所得金额:{}", allocate[1]);
                 if (allocate[1] != null && allocate[1].compareTo(BigDecimal.ZERO) == 0) {
                     SHAppProfitSharingInfo.setAmount(RatiosUtil.amount_fee(BigDecimal.ZERO));
                     SHAppProfitSharingInfo.setDescription("分账金额为0,请自行处理");
@@ -368,6 +373,7 @@ public class WeChatPayService {
 
                 //平台所得金额(金额*比例-微信手续费)
                 Integer procedureFee = RatiosUtil.amount_fee(allocate[2].add(insurePrice));
+                log.info("------------------------------------------------平台所得金额:{},{}", allocate[2], procedureFee);
                 AppProfitSharingInfo PTAppProfitSharingInfo = getPtAppProfitSharingInfo(appOrder, PT, procedureFee, insurePrice);
                 if (allocate[2] != null && ((allocate[2].add(insurePrice)).compareTo(BigDecimal.ZERO) == 0)) {
                     PTAppProfitSharingInfo.setAmount(RatiosUtil.amount_fee(BigDecimal.ZERO));