diff --git a/ghy-admin/src/main/java/com/ghy/web/timer/AdapaySyncTimer.java b/ghy-admin/src/main/java/com/ghy/web/timer/AdapaySyncTimer.java index 91b20e1c..0c693b58 100644 --- a/ghy-admin/src/main/java/com/ghy/web/timer/AdapaySyncTimer.java +++ b/ghy-admin/src/main/java/com/ghy/web/timer/AdapaySyncTimer.java @@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject; import com.ghy.common.adapay.model.AdapayStatusEnum; import com.ghy.common.enums.AdapayOrderType; import com.ghy.common.utils.AdapayUtils; +import com.ghy.customer.domain.CustomerBank; +import com.ghy.customer.service.CustomerBankService; import com.ghy.order.service.OrderDetailService; import com.ghy.payment.domain.DrawCashRecord; import com.ghy.payment.mapper.DrawCashRecordMapper; @@ -39,6 +41,8 @@ public class AdapaySyncTimer { @Resource private WorkerBankService workerBankService; @Resource + private CustomerBankService customerBankService; + @Resource private OrderDetailService orderDetailService; @Resource private DrawCashRecordMapper drawCashRecordMapper; @@ -75,6 +79,33 @@ public class AdapaySyncTimer { log.error(e.getMessage(), e); } } + + List customerBanks = customerBankService.getCustomerBankList(new CustomerBank()); + for (CustomerBank customer : customerBanks) { + Long deptId = customer.getDeptId(); + String memberId = customer.getAdapayMemberId(); + String settleAccountId = customer.getSettleAccountId(); + if (deptId == null || StringUtils.isBlank(memberId) || StringUtils.isBlank(settleAccountId)) { + continue; + } + try { + JSONObject accountBalance = adapayService.queryAccountBalance(deptId, memberId, settleAccountId, "01"); + if (AdapayStatusEnum.succeeded.code.equals(accountBalance.getString("status"))) { + // 可提现金额 + String avlBalance = accountBalance.getString("avl_balance"); + if (BigDecimal.ZERO.compareTo(new BigDecimal(avlBalance)) > -1) { + continue; + } + // 提现 + log.info("Customer[{},{}]开始提现: avlBalance={}", customer.getCustomerId(), customer.getName(), avlBalance); + String orderNo = AdapayUtils.createOrderNo(AdapayOrderType.DRAW_CASH); + JSONObject drawCash = adapayService.drawCash(deptId, orderNo, "T1", avlBalance, memberId, "提现", null); + log.info("Customer[{},{}]提现结果: {}", customer.getCustomerId(), customer.getName(), drawCash.toJSONString()); + } + } catch (BaseAdaPayException e) { + log.error(e.getMessage(), e); + } + } } @Scheduled(fixedRate = 5 * 60 * 1000L) diff --git a/ghy-custom/src/main/resources/mapper/customer/CustomerBankMapper.xml b/ghy-custom/src/main/resources/mapper/customer/CustomerBankMapper.xml index cd7c28a0..f7bd490d 100644 --- a/ghy-custom/src/main/resources/mapper/customer/CustomerBankMapper.xml +++ b/ghy-custom/src/main/resources/mapper/customer/CustomerBankMapper.xml @@ -22,20 +22,8 @@ - SELECT customer_bank_id, - settle_account_id, - customer_id, - name, - cert_id, - bank_name, - bank_num, - phone, - dept_id, - adapay_member_id, - settle_account, - create_by, - create_time, - remark + SELECT customer_bank_id, settle_account_id, customer_id, name, cert_id, bank_name, bank_num, phone, dept_id, + adapay_member_id, settle_account, create_by, create_time, update_by, update_time, remark FROM customer_bank