mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
手动创建结算账户
This commit is contained in:
@@ -206,7 +206,7 @@ public class AdapayService {
|
||||
throw new BusinessException("00500001", errorMsg);
|
||||
}
|
||||
|
||||
// 创建结算账户
|
||||
/*// 创建结算账户
|
||||
Map<String, Object> accountInfo = Maps.newHashMap();
|
||||
// 银行卡号
|
||||
accountInfo.put("card_id", dto.getCardId());
|
||||
@@ -243,7 +243,9 @@ public class AdapayService {
|
||||
settleCountParams.put("account_info", accountInfo);
|
||||
log.info("创建汇付结算账户param:{}", settleCountParams);
|
||||
Map<String, Object> settleCount = SettleAccount.create(settleCountParams, config.getWechatAppId());
|
||||
log.info("创建汇付结算账户result:{}", settleCount);
|
||||
log.info("创建汇付结算账户result:{}", settleCount);*/
|
||||
|
||||
Map<String, Object> settleCount = createSettleAccountRequest(dto, adapayMemberId, dto.getWechatAppId());
|
||||
|
||||
if (settleCount == null || StringUtils.equals((String) settleCount.get("status"), "failed")) {
|
||||
String errorMsg = settleCount == null ? "创建汇付结算账户失败" : (String) settleCount.get("error_msg");
|
||||
@@ -403,6 +405,55 @@ public class AdapayService {
|
||||
return corpMemberVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建结算账户请求
|
||||
*/
|
||||
public Map<String, Object> createSettleAccountRequest(SettleAccountDTO dto, String adapayMemberId, String wechatAppId) throws BaseAdaPayException {
|
||||
// 获取汇付支付配置
|
||||
AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId);
|
||||
if (config == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR);
|
||||
}
|
||||
|
||||
// 创建结算账户
|
||||
Map<String, Object> accountInfo = Maps.newHashMap();
|
||||
// 银行卡号
|
||||
accountInfo.put("card_id", dto.getCardId());
|
||||
// 银行卡对应的户名
|
||||
accountInfo.put("card_name", dto.getCardName());
|
||||
// 证件号,银行账户类型为对私时,必填
|
||||
if (StringUtils.isNotBlank(dto.getCertId())) {
|
||||
accountInfo.put("cert_id", dto.getCertId());
|
||||
}
|
||||
// 证件类型,仅支持:00-身份证,银行账户类型为对私时,必填
|
||||
accountInfo.put("cert_type", "00");
|
||||
// 手机号
|
||||
accountInfo.put("tel_no", dto.getTelNo());
|
||||
// 银行编码,详见附录 银行代码,银行账户类型对公时,必填
|
||||
if (StringUtils.isNotBlank(dto.getBankCode())) {
|
||||
accountInfo.put("bank_code", dto.getBankCode());
|
||||
}
|
||||
// 银行账户类型:1-对公;2-对私
|
||||
accountInfo.put("bank_acct_type", dto.getBankAcctType());
|
||||
// 银行账户开户银行所在省份编码 (省市编码),银行账户类型为对公时,必填
|
||||
if (StringUtils.isNotBlank(dto.getProvCode())) {
|
||||
accountInfo.put("prov_code", dto.getProvCode());
|
||||
}
|
||||
// 银行账户开户银行所在地区编码(省市编码),银行账户类型为对公时,必填
|
||||
if (StringUtils.isNotBlank(dto.getAreaCode())) {
|
||||
accountInfo.put("area_code", dto.getAreaCode());
|
||||
}
|
||||
|
||||
Map<String, Object> settleCountParams = Maps.newHashMap();
|
||||
settleCountParams.put("member_id", adapayMemberId);
|
||||
settleCountParams.put("app_id", config.getAdapayAppId());
|
||||
// channel String Y 目前仅支持:bank_account(银行卡)
|
||||
settleCountParams.put("channel", "bank_account");
|
||||
settleCountParams.put("account_info", accountInfo);
|
||||
Map<String, Object> settleCount = SettleAccount.create(settleCountParams, config.getWechatAppId());
|
||||
log.info("创建汇付结算账户param:{}, result:{}", JSON.toJSONString(settleCountParams), JSON.toJSONString(settleCount));
|
||||
return settleCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除结算账户对象/创建删除结算账户请求
|
||||
@@ -419,6 +470,7 @@ public class AdapayService {
|
||||
settleCountParams.put("member_id", adapayMemberId);
|
||||
settleCountParams.put("app_id", config.getAdapayAppId());
|
||||
Map<String, Object> settleCount = SettleAccount.delete(settleCountParams);
|
||||
log.info("创建删除结算账户请求param:{}, result:{}", JSON.toJSONString(settleCountParams), JSON.toJSONString(settleCount));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -568,10 +620,10 @@ public class AdapayService {
|
||||
memberParams.put("zip_code", dto.getZipCode());
|
||||
memberParams.put("telphone", dto.getTelphone());
|
||||
memberParams.put("email", dto.getEmail());
|
||||
memberParams.put("bank_code", dto.getBankCode());
|
||||
memberParams.put("bank_acct_type", dto.getBankAcctType());
|
||||
memberParams.put("card_no", dto.getCardNo());
|
||||
memberParams.put("card_name", dto.getCardName());
|
||||
// memberParams.put("bank_code", dto.getBankCode());
|
||||
// memberParams.put("bank_acct_type", dto.getBankAcctType());
|
||||
// memberParams.put("card_no", dto.getCardNo());
|
||||
// memberParams.put("card_name", dto.getCardName());
|
||||
memberParams.put("notify_url", ADAPAY_CALLBACK_URL);
|
||||
File file = ZipUtil.createZipFileFromImages(dto.getImgList());
|
||||
Map<String, Object> member = CorpMember.create(memberParams, file, config.getWechatAppId());
|
||||
@@ -589,10 +641,19 @@ public class AdapayService {
|
||||
adapayMemberAccountService.deleteAdapayMemberAccountByIds(ids);
|
||||
}
|
||||
|
||||
// 取消自动创建结算账户,手动创建结算账户
|
||||
Map<String, Object> settleCount = createSettleAccountRequest(dto, adapayMemberId, dto.getWechatAppId());
|
||||
|
||||
if (settleCount == null || StringUtils.equals((String) settleCount.get("status"), "failed")) {
|
||||
String errorMsg = settleCount == null ? "创建汇付结算账户失败" : (String) settleCount.get("error_msg");
|
||||
throw new BusinessException("00500001", errorMsg);
|
||||
}
|
||||
String settleAccountId = (String) settleCount.get("id");
|
||||
// 保存到数据库
|
||||
AdapayMemberAccount adapayMemberAccount = new AdapayMemberAccount();
|
||||
adapayMemberAccount.setMerchantId(dto.getMerchantId());
|
||||
adapayMemberAccount.setAdapayMemberId(adapayMemberId);
|
||||
adapayMemberAccount.setSettleAccountId(settleAccountId);
|
||||
adapayMemberAccount.setStatus(Constants.ZERO);
|
||||
adapayMemberAccountService.insertAdapayMemberAccount(adapayMemberAccount);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user