Răsfoiți Sursa

判断是否需要分账补偿

wujiefeng 1 an în urmă
părinte
comite
769b19c3f6

+ 13 - 5
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/pay/ChinaumsSenselessPayService.java

@@ -41,6 +41,7 @@ import com.zhongshu.card.server.core.util.CommonUtil;
 import io.micrometer.common.util.StringUtils;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
+import org.junit.Ignore;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StopWatch;
@@ -49,6 +50,7 @@ import java.math.BigDecimal;
 import java.math.MathContext;
 import java.math.RoundingMode;
 import java.util.*;
+import java.util.stream.Collectors;
 
 @Slf4j
 @Service
@@ -375,13 +377,19 @@ public class ChinaumsSenselessPayService extends SuperService {
             shareOrder.setShareOrderNo(shareOrderNo);
             shareOrderDao.save(shareOrder);
             return satInfo;
-        }).toList();
+        }).collect(Collectors.toList());
 
         if (satInfos.size()>1){
-            SatInfo satInfo = satInfos.get(0);
-            BigDecimal upSatAmt = new BigDecimal(satInfo.getSatAmt()).add(new BigDecimal("1"));
-            satInfo.setSatAmt(upSatAmt.toBigInteger().toString());
-            satInfos.set(0, satInfo);
+            BigDecimal bigDecimal = BigDecimal.ZERO;
+            for (SatInfo sat: satInfos) {
+                bigDecimal = bigDecimal.add(new BigDecimal(sat.getSatAmt()));
+            }
+            if (bigDecimal.compareTo(total) != 0){
+                SatInfo satInfo = satInfos.get(0);
+                BigDecimal upSatAmt = new BigDecimal(satInfo.getSatAmt()).add(new BigDecimal("1"));
+                satInfo.setSatAmt(upSatAmt.toBigInteger().toString());
+                satInfos.set(0, satInfo);
+            }
         }
         return satInfos;
     }