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.adapay.model.AdapayStatusEnum;
|
||||||
import com.ghy.common.enums.AdapayOrderType;
|
import com.ghy.common.enums.AdapayOrderType;
|
||||||
import com.ghy.common.utils.AdapayUtils;
|
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.order.service.OrderDetailService;
|
||||||
import com.ghy.payment.domain.DrawCashRecord;
|
import com.ghy.payment.domain.DrawCashRecord;
|
||||||
import com.ghy.payment.mapper.DrawCashRecordMapper;
|
import com.ghy.payment.mapper.DrawCashRecordMapper;
|
||||||
|
|
@ -39,6 +41,8 @@ public class AdapaySyncTimer {
|
||||||
@Resource
|
@Resource
|
||||||
private WorkerBankService workerBankService;
|
private WorkerBankService workerBankService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private CustomerBankService customerBankService;
|
||||||
|
@Resource
|
||||||
private OrderDetailService orderDetailService;
|
private OrderDetailService orderDetailService;
|
||||||
@Resource
|
@Resource
|
||||||
private DrawCashRecordMapper drawCashRecordMapper;
|
private DrawCashRecordMapper drawCashRecordMapper;
|
||||||
|
|
@ -75,6 +79,33 @@ public class AdapaySyncTimer {
|
||||||
log.error(e.getMessage(), e);
|
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)
|
@Scheduled(fixedRate = 5 * 60 * 1000L)
|
||||||
|
|
|
||||||
|
|
@ -22,20 +22,8 @@
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectCustomerBank">
|
<sql id="selectCustomerBank">
|
||||||
SELECT customer_bank_id,
|
SELECT customer_bank_id, settle_account_id, customer_id, name, cert_id, bank_name, bank_num, phone, dept_id,
|
||||||
settle_account_id,
|
adapay_member_id, settle_account, create_by, create_time, update_by, update_time, remark
|
||||||
customer_id,
|
|
||||||
name,
|
|
||||||
cert_id,
|
|
||||||
bank_name,
|
|
||||||
bank_num,
|
|
||||||
phone,
|
|
||||||
dept_id,
|
|
||||||
adapay_member_id,
|
|
||||||
settle_account,
|
|
||||||
create_by,
|
|
||||||
create_time,
|
|
||||||
remark
|
|
||||||
FROM customer_bank
|
FROM customer_bank
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue