2 Komitmen cae775992d ... f1a8ea654b

Pembuat SHA1 Pesan Tanggal
  wujiefeng f1a8ea654b Merge remote-tracking branch 'origin/master' 1 tahun lalu
  wujiefeng 769b19c3f6 判断是否需要分账补偿 1 tahun lalu

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

@@ -1,5 +1,6 @@
 package com.zhongshu.card.server.core.service.pay;
 
+import cn.hutool.core.util.ArrayUtil;
 import com.github.microservice.core.util.JsonUtil;
 import com.github.microservice.core.util.bean.BeanUtil;
 import com.github.microservice.core.util.queue.ExecuteQueueUtil;
@@ -40,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;
@@ -47,8 +49,7 @@ import org.springframework.util.StopWatch;
 import java.math.BigDecimal;
 import java.math.MathContext;
 import java.math.RoundingMode;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -340,7 +341,7 @@ public class ChinaumsSenselessPayService extends SuperService {
 
     private List<SatInfo> buildSatInfo(String projectOid, BigDecimal total, String orderNo, String sysSourceNo, List<SatInfoModel> satInfoModels) {
         //按比例降序排序
-        satInfoModels.sort((a, b) -> b.getRatio().compareTo(a.getRatio()));
+        satInfoModels.sort((a, b)-> b.getRatio().compareTo(a.getRatio()));
 
         List<SatInfo> satInfos = satInfoModels.stream().map(model -> {
             if (BigDecimal.ZERO.compareTo(model.getRatio()) >= 0) {
@@ -378,16 +379,22 @@ public class ChinaumsSenselessPayService extends SuperService {
             return satInfo;
         }).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);
+        if (satInfos.size()>1){
+            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;
     }
 
-    private String buildShareOrderNo(String sysSourceNo) {
+    private String buildShareOrderNo(String sysSourceNo){
         return sysSourceNo + DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyyMMddHHmmssSSS) + CommonUtil.randomCode(7);
     }
 
@@ -476,8 +483,8 @@ public class ChinaumsSenselessPayService extends SuperService {
                     result.setData(refundQuery.getContent());
                     result.setDone(true);
                     return result;
-                } else if (refundQuery.getContent().getRefundStatus().equals("PROCESSING")) {
-                    if (it.getIndex() > 4) {
+                }else if (refundQuery.getContent().getRefundStatus().equals("PROCESSING")) {
+                    if (it.getIndex()>4){
                         result.setData(refundQuery.getContent());
                         result.setDone(true);
                         return result;