|
|
@@ -16,6 +16,7 @@ import com.izouma.nineth.repo.WithdrawApplyRepo;
|
|
|
import com.izouma.nineth.utils.JpaUtils;
|
|
|
import com.izouma.nineth.utils.SnowflakeIdWorker;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.redisson.api.RLock;
|
|
|
import org.redisson.api.RedissonClient;
|
|
|
@@ -37,6 +38,7 @@ import java.util.regex.Pattern;
|
|
|
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
+@Slf4j
|
|
|
public class WithdrawApplyService {
|
|
|
|
|
|
private WithdrawApplyRepo withdrawApplyRepo;
|
|
|
@@ -96,7 +98,7 @@ public class WithdrawApplyService {
|
|
|
String withdrawCharge = sysConfigService.getString("withdraw_charge");
|
|
|
if (StringUtils.isNotEmpty(withdrawCharge) && Pattern.matches("^(\\d+|\\d+.\\d+),\\d+$", withdrawCharge)) {
|
|
|
String[] arr = withdrawCharge.split(",");
|
|
|
- chargeAmount = new BigDecimal(arr[0]);
|
|
|
+ chargeAmount = apply.getAmount().multiply(new BigDecimal(arr[0]));
|
|
|
BigDecimal minChargeAmount = new BigDecimal(arr[1]);
|
|
|
if (chargeAmount.compareTo(minChargeAmount) < 0) {
|
|
|
chargeAmount = minChargeAmount;
|
|
|
@@ -176,4 +178,23 @@ public class WithdrawApplyService {
|
|
|
});
|
|
|
}).get();
|
|
|
}
|
|
|
+
|
|
|
+ @Async
|
|
|
+ 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();
|
|
|
+
|
|
|
+ }
|
|
|
}
|