Ver Fonte

balance

xiongzhu há 4 anos atrás
pai
commit
f2260de898

+ 3 - 0
src/main/java/com/izouma/nineth/dto/SandPaySettle.java

@@ -28,4 +28,7 @@ public class SandPaySettle {
 
     @ExcelProperty("订单号")
     private String orderNo;
+
+    @ExcelProperty("附言")
+    private String remark;
 }

+ 21 - 2
src/main/java/com/izouma/nineth/service/UserBalanceService.java

@@ -17,6 +17,7 @@ import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -39,6 +40,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Optional;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
@@ -153,6 +155,9 @@ public class UserBalanceService {
             Optional.ofNullable(row.getCell(3))
                     .orElse(row.createCell(3))
                     .setCellValue(withdrawList.get(i).getAmount().doubleValue());
+            Optional.ofNullable(row.getCell(4))
+                    .orElse(row.createCell(4))
+                    .setCellValue(withdrawList.get(i).getUserId());
         }
 
         inputStream.close();
@@ -202,8 +207,22 @@ public class UserBalanceService {
                 .doReadSync();
         List<UserWithdraw> failWithdraw = new ArrayList<>();
         for (SandPaySettle sandPaySettle : failSettleList) {
-            withdrawList.stream().filter(i -> i.getBankNo().equals(sandPaySettle.getBankNo()))
-                    .findAny().ifPresent(failWithdraw::add);
+            List<UserWithdraw> list;
+            if (StringUtils.isNotBlank(sandPaySettle.getRemark()) && Pattern.matches("^\\d+$", sandPaySettle.getRemark().trim())) {
+                Long userId = Long.parseLong(sandPaySettle.getRemark().trim());
+                list = withdrawList.stream().filter(i -> i.getUserId().equals(userId))
+                        .collect(Collectors.toList());
+            } else {
+                list = withdrawList.stream().filter(i -> i.getBankNo().equals(sandPaySettle.getBankNo())
+                                && i.getName().equals(sandPaySettle.getName())
+                                && i.getAmount().compareTo(sandPaySettle.getAmount()) == 0)
+                        .collect(Collectors.toList());
+            }
+            if (list.size() != 1) {
+                throw new BusinessException("不唯一:" + sandPaySettle.getName() + "," + sandPaySettle.getBankNo());
+            } else {
+                failWithdraw.add(list.get(0));
+            }
         }
         for (UserWithdraw withdraw : failWithdraw) {
             UserBalance userBalance = userBalanceRepo.findById(withdraw.getUserId())