新增 删除结算账户、新增结算账户接口

This commit is contained in:
Lemon
2025-06-25 15:37:29 +08:00
parent d892f2d7b2
commit 1e178d6890
6 changed files with 126 additions and 1 deletions

View File

@@ -1517,4 +1517,53 @@ public class AdapayService {
return totalSplitAmount;
}
/**
* 创建结算账户
* @param dto
* @throws BaseAdaPayException
*/
public void createBankAccount(SettleAccountDTO dto) throws BaseAdaPayException {
// 根据运营商id 查出现有的adapayMemberId
String merchantId = dto.getMerchantId();
// 新写一个查询方法,查询最近一条的记录(因为之前已经删除过数据,使用原查询方法查不到数据)
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectRecentInfoByMerchantId(merchantId);
if (adapayMemberAccount == null) {
return;
}
String adapayMemberId = adapayMemberAccount.getAdapayMemberId();
// 查询该商户的wxAppId
String wxAppId = pileMerchantInfoService.queryAppIdByMerchantId(merchantId);
// 创建结算账户请求
Map<String, Object> settleAccount = this.createSettleAccountRequest(dto, adapayMemberId, wxAppId);
// 保存结果
if (settleAccount == null || StringUtils.equals((String) settleAccount.get("status"), "failed")) {
String errorMsg = settleAccount == null ? "创建汇付结算账户失败" : (String) settleAccount.get("error_msg");
throw new BusinessException("00500001", errorMsg);
}
String settleAccountId = (String) settleAccount.get("id");
// 保存到数据库
adapayMemberAccount = new AdapayMemberAccount();
adapayMemberAccount.setMerchantId(dto.getMerchantId());
adapayMemberAccount.setAdapayMemberId(adapayMemberId);
adapayMemberAccount.setSettleAccountId(settleAccountId);
adapayMemberAccount.setStatus(Constants.ONE);
adapayMemberAccountService.insertAdapayMemberAccount(adapayMemberAccount);
}
/**
* 删除结算账户(先删除汇付的结算账户,再逻辑删除数据库)
* @param dto
* @throws BaseAdaPayException
*/
public void deleteSettleAccount(AdapayMemberInfoDTO dto) throws BaseAdaPayException {
// 查询appId
String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(dto.getMerchantId());
// 1、新建删除请求 2、如果成功再将数据库中的记录删除
this.createDeleteSettleAccountRequest(dto.getAdapayMemberId(), dto.getSettleAccountId(), wechatAppId);
// 删除数据库中的记录
adapayMemberAccountService.deleteAccountByMerchantId(dto.getMerchantId());
}
}