瀏覽代碼

fixCharge

xiongzhu 4 年之前
父節點
當前提交
339f775949

+ 16 - 13
src/main/java/com/izouma/nineth/service/WithdrawApplyService.java

@@ -180,18 +180,21 @@ public class WithdrawApplyService {
     }
 
     @Async
-    public void fixCharge() {
-        withdrawApplyRepo.findByStatusAndAmountLessThanEqual(WithdrawStatus.SUCCESS, new BigDecimal("1000"))
-                .parallelStream().forEach(apply -> {
-                    try {
-                        UserBankCard bankCard = userBankCardRepo.findByUserId(apply.getUserId())
-                                .stream().findFirst()
-                                .orElseThrow(new BusinessException("未绑卡"));
-                        JSONObject res = sandPayService.transfer(snowflakeIdWorker.nextId() + "", bankCard.getRealName(),
-                                bankCard.getBankNo(), new BigDecimal("6"));
-                    } catch (Exception e) {
-                        log.error("fixCharge", e);
-                    }
-                });
+    public void fixCharge() throws ExecutionException, InterruptedException {
+        new ForkJoinPool(5).submit(() -> {
+            withdrawApplyRepo.findByStatusAndAmountLessThanEqual(WithdrawStatus.SUCCESS, new BigDecimal("1000"))
+                    .parallelStream().forEach(apply -> {
+                        try {
+                            UserBankCard bankCard = userBankCardRepo.findByUserId(apply.getUserId())
+                                    .stream().findFirst()
+                                    .orElseThrow(new BusinessException("未绑卡"));
+                            JSONObject res = sandPayService.transfer(snowflakeIdWorker.nextId() + "", bankCard.getRealName(),
+                                    bankCard.getBankNo(), new BigDecimal("6"));
+                        } catch (Exception e) {
+                            log.error("fixCharge", e);
+                        }
+                    });
+        }).get();
+
     }
 }

+ 1 - 1
src/main/java/com/izouma/nineth/web/WithdrawApplyController.java

@@ -64,7 +64,7 @@ public class WithdrawApplyController extends BaseController {
 
     @PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/fixCharge")
-    public void fixCharge() {
+    public void fixCharge() throws ExecutionException, InterruptedException {
         withdrawApplyService.fixCharge();
     }
 }