Customer自动提现
This commit is contained in:
parent
acf7a47be6
commit
9982b95211
|
|
@ -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<CustomerBank> 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)
|
||||
|
|
|
|||
|
|
@ -22,20 +22,8 @@
|
|||
</resultMap>
|
||||
|
||||
<sql id="selectCustomerBank">
|
||||
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
|
||||
</sql>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue