TRX 1 жил өмнө
parent
commit
1ed159c10d

+ 3 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/payment/ExpenseFlowServiceImpl.java

@@ -401,9 +401,12 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
         if (!orderPayModel.isSuccess()) {
             return ResultContent.buildFail(orderPayModel.getPayMsg());
         }
+
+        // 调用支付
         ResultContent<ExpenseFlow> resultContent = payCallService.payOrder(expenseFlow);
         expenseFlow = resultContent.getContent();
 
+        // 支付失败
         if (expenseFlow.getIsPaySuccess() == null || !resultContent.isSuccess()) {
             return ResultContent.buildFail(expenseFlow.getPaymentStatus());
         }

+ 36 - 20
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/payment/PayCallService.java

@@ -314,7 +314,11 @@ public class PayCallService extends SuperService {
         payAmount = payAmount.stripTrailingZeros();
 
         log.info("开始支付时间:{}", DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyySSS));
+
+        // 创建分账信息
         List<SatInfoModel> satInfoModel = buildShare(entity, paymentProcess.getPaymentType());
+
+        // 调用支付
         com.github.microservice.net.ResultContent resultContent = chinaumsSenselessPayService.senselessPay(
                 entity.getProjectOid(), entity.getShopOid(), entity.getUserId(),
                 payAmount, entity.getPaymentNo(), entity.getRemark(), satInfoModel);
@@ -779,29 +783,41 @@ public class PayCallService extends SuperService {
         List<SatInfoModel> satInfoModel = new ArrayList<>();
         ProjectMainPaySetting paySetting = projectMainPaySettingService.getProjectMainPaySetting(entity.getProjectOid(), paymentType);
         if (ObjectUtils.isNotEmpty(paySetting)) {
-            // 消费的金额
+            // 消费的金额 (单位分)
             BigDecimal payAmount = entity.getPayAmount();
+
             Long minSharing = paySetting.getMinSharing();
-            if (minSharing != null && minSharing > 0 && BigDecimal.valueOf(minSharing).compareTo(payAmount) <= 0) {
-                ProjectOrgPaySettingInfo childPaySettingInfo = paySetting.getChildPaySettingInfo();
-                if (ObjectUtils.isNotEmpty(childPaySettingInfo)) {
-                    String mainOid = childPaySettingInfo.getBelongOig();
-                    String shopOid = entity.getShopOid();
-
-                    BigDecimal projectScale = paySetting.getProjectScale();
-                    if (projectScale != null) {
-                        BigDecimal orgScale = paySetting.getOrgScale();
-                        SatInfoModel plat = new SatInfoModel();
-                        plat.setOid(mainOid);
-                        plat.setRatio(projectScale);
-
-                        SatInfoModel shop = new SatInfoModel();
-                        shop.setOid(shopOid);
-                        shop.setRatio(orgScale);
-
-                        satInfoModel.add(plat);
-                        satInfoModel.add(shop);
+            if (minSharing != null && minSharing > 0) {
+                String shopOid = entity.getShopOid();
+
+                // 如果消费金额比最小的分账金额大,就进行分账
+                if (BigDecimal.valueOf(minSharing).compareTo(payAmount) <= 0) {
+                    ProjectOrgPaySettingInfo childPaySettingInfo = paySetting.getChildPaySettingInfo();
+                    if (ObjectUtils.isNotEmpty(childPaySettingInfo)) {
+                        String mainOid = childPaySettingInfo.getBelongOig();
+
+                        BigDecimal projectScale = paySetting.getProjectScale();
+                        if (projectScale != null) {
+                            BigDecimal orgScale = paySetting.getOrgScale();
+                            SatInfoModel plat = new SatInfoModel();
+                            plat.setOid(mainOid);
+                            plat.setRatio(projectScale);
+
+                            SatInfoModel shop = new SatInfoModel();
+                            shop.setOid(shopOid);
+                            shop.setRatio(orgScale);
+
+                            satInfoModel.add(plat);
+                            satInfoModel.add(shop);
+                        }
                     }
+                } else {
+                    // 不进行分账,全部分给 商户 (设备绑定的)
+                    SatInfoModel shop = new SatInfoModel();
+                    shop.setOid(shopOid);
+                    shop.setRatio(BigDecimal.valueOf(100));
+
+                    satInfoModel.add(shop);
                 }
             }
         }