mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-07-02 21:18:05 +08:00
新增 删除结算账户、新增结算账户接口
This commit is contained in:
@@ -209,7 +209,8 @@ public class AdapayMemberController extends BaseController {
|
|||||||
public AjaxResult deleteSettleAccount(@RequestBody AdapayMemberInfoDTO dto) {
|
public AjaxResult deleteSettleAccount(@RequestBody AdapayMemberInfoDTO dto) {
|
||||||
AjaxResult result = null;
|
AjaxResult result = null;
|
||||||
try {
|
try {
|
||||||
adapayService.createDeleteSettleAccountRequest(dto.getAdapayMemberId(), dto.getSettleAccountId(), Constants.DEFAULT_APP_ID);
|
// 新写删除方法
|
||||||
|
adapayService.deleteSettleAccount(dto);
|
||||||
result = AjaxResult.success();
|
result = AjaxResult.success();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("删除结算账户 error,", e);
|
logger.error("删除结算账户 error,", e);
|
||||||
@@ -217,4 +218,23 @@ public class AdapayMemberController extends BaseController {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在仅删除结算账户后,重新创建新的结算账户
|
||||||
|
* 注:使用原 member_id 重新创建结算账户对象,且必须与原身份证和银行卡户名保持一致
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("createBankAccount")
|
||||||
|
public AjaxResult createBankAccount(@RequestBody SettleAccountDTO dto) {
|
||||||
|
AjaxResult result = null;
|
||||||
|
try {
|
||||||
|
adapayService.createBankAccount(dto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("重新创建结算账户 error, ", e);
|
||||||
|
result = AjaxResult.error();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1517,4 +1517,53 @@ public class AdapayService {
|
|||||||
|
|
||||||
return totalSplitAmount;
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,4 +119,17 @@ public interface AdapayMemberAccountMapper {
|
|||||||
void updateAdapayMemberAccountByMemberId(AdapayMemberAccount adapayMemberAccount);
|
void updateAdapayMemberAccountByMemberId(AdapayMemberAccount adapayMemberAccount);
|
||||||
|
|
||||||
AdapayMemberAccount selectByMemberId(String memberId);
|
AdapayMemberAccount selectByMemberId(String memberId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过运营商id删除账户信息
|
||||||
|
* @param merchantId
|
||||||
|
*/
|
||||||
|
void deleteAccountByMerchantId(String merchantId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据运营商id查询最近一条的信息
|
||||||
|
* @param merchantId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AdapayMemberAccount selectRecentInfoByMerchantId(String merchantId);
|
||||||
}
|
}
|
||||||
@@ -109,4 +109,17 @@ public interface AdapayMemberAccountService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String selectMerchantNameByAdapayMemberId(String adapayMemberId);
|
String selectMerchantNameByAdapayMemberId(String adapayMemberId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据运营商id删除记录
|
||||||
|
* @param merchantId
|
||||||
|
*/
|
||||||
|
void deleteAccountByMerchantId(String merchantId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据运营商Id查询最近一条的信息
|
||||||
|
* @param merchantId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AdapayMemberAccount selectRecentInfoByMerchantId(String merchantId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,5 +259,19 @@ public class AdapayMemberAccountServiceImpl implements AdapayMemberAccountServic
|
|||||||
return pileMerchantInfo.getMerchantName();
|
return pileMerchantInfo.getMerchantName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteAccountByMerchantId(String merchantId) {
|
||||||
|
adapayMemberAccountMapper.deleteAccountByMerchantId(merchantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据运营商id查询最近一条的信息
|
||||||
|
* @param merchantId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AdapayMemberAccount selectRecentInfoByMerchantId(String merchantId) {
|
||||||
|
return adapayMemberAccountMapper.selectRecentInfoByMerchantId(merchantId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -528,4 +528,20 @@
|
|||||||
where del_flag = '0'
|
where del_flag = '0'
|
||||||
and adapay_member_id = #{memberId,jdbcType=VARCHAR}
|
and adapay_member_id = #{memberId,jdbcType=VARCHAR}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<update id="deleteAccountByMerchantId">
|
||||||
|
update
|
||||||
|
adapay_member_account
|
||||||
|
set del_flag = '0'
|
||||||
|
where merchant_id = #{merchantId,jdbcType=VARCHAR}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="selectRecentInfoByMerchantId" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from adapay_member_account
|
||||||
|
where merchant_id = #{merchantId,jdbcType=VARCHAR}
|
||||||
|
order by create_time desc
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user