@@ -266,33 +266,91 @@ public class AdapayService {
}
/**
* 创建结算账 户
*
* @param dto
* @throws BaseAdaPayException
* @throws BusinessException
* 创建个人用 户
*/
public void createSettleAccount ( SettleAccount DTO dto ) throws BaseAdaPayException , BusinessException {
String bankAcctType = dto . getBankAcctType ( ) ;
public void createAdapayMember ( CreatePersonalMember DTO dto ) throws BaseAdaPayException , BusinessException {
SettleAccountDTO request = SettleAccountDTO . builder ( )
. merchantId ( dto . getMerchantId ( ) )
. location ( dto . getLocation ( ) )
. email ( dto . getEmail ( ) )
. gender ( dto . getGender ( ) )
. nickname ( dto . getNickname ( ) )
. wechatAppId ( pileMerchantInfoService . queryAppIdByMerchantId ( dto . getMerchantId ( ) ) )
. build ( ) ;
createMember ( request ) ;
}
/**
* 创建企业用户
*/
public void createCorpMember ( CreateCorpMemberDTO dto ) throws BaseAdaPayException , BusinessException {
SettleAccountDTO request = SettleAccountDTO . builder ( )
. merchantId ( dto . getMerchantId ( ) )
. wechatAppId ( pileMerchantInfoService . queryAppIdByMerchantId ( dto . getMerchantId ( ) ) )
. businessName ( dto . getName ( ) )
. provCode ( dto . getProvCode ( ) )
. areaCode ( dto . getAreaCode ( ) )
. socialCreditCode ( dto . getSocialCreditCode ( ) )
. socialCreditCodeExpires ( dto . getSocialCreditCodeExpires ( ) )
. businessScope ( dto . getBusinessScope ( ) )
. legalPerson ( dto . getLegalPerson ( ) )
. legalCertId ( dto . getLegalCertId ( ) )
. legalCertIdExpires ( dto . getLegalCertIdExpires ( ) )
. legalMp ( dto . getLegalMp ( ) )
. address ( dto . getAddress ( ) )
. zipCode ( dto . getZipCode ( ) )
. telphone ( dto . getTelphone ( ) )
. email ( dto . getEmail ( ) )
. imgList ( dto . getImgList ( ) )
. build ( ) ;
createCorpMember ( request ) ;
}
/**
* 创建结算账户
*/
public void createSettleAccount ( CreateSettleAccountDTO dto ) throws BaseAdaPayException , BusinessException {
AdapayMemberAccount adapayMemberAccount = requireCurrentMemberAccount ( dto . getMerchantId ( ) ) ;
if ( CollectionUtils . isNotEmpty ( selectSettleAccount ( dto . getMerchantId ( ) ) ) ) {
throw new BusinessException ( " " , " 当前商户已存在结算账户 " ) ;
}
// 设置wechatAppId
String wechatAppId = pileMerchantInfoService . queryAppIdByMerchantId ( dto . getMerchantId ( ) ) ;
dto . setWechatAppId ( wechatAppId ) ;
String cardId = dto . getCardId ( ) ;
String cardNo = dto . getCardNo ( ) ;
if ( StringUtils . isBlank ( cardId ) & & StringUtils . isNotBlank ( cardNo ) ) {
dto . setCardId ( cardNo ) ;
}
if ( StringUtils . isBlank ( cardNo ) & & StringUtils . isNotBlank ( cardId ) ) {
dto . setCardNo ( cardId ) ;
SettleAccountDTO request = buildSettleAccountDTO ( dto ) ;
Map < String , Object > settleCount = createSettleAccountRequest ( request , adapayMemberAccount . getAdapayMemberId ( ) , wechatAppId ) ;
if ( settleCount = = null | | StringUtils . equals ( ( String ) settleCount . get ( " status " ) , " failed " ) ) {
String errorMsg = settleCount = = null ? " 创建汇付结算账户失败 " : ( String ) settleCount . get ( " error_msg " ) ;
throw new BusinessException ( " 00500001 " , errorMsg ) ;
}
if ( StringUtils . equals ( bankAcctType , Constants . ONE ) ) {
createCorp Member ( dto ) ;
} else if ( StringUtils . equals ( bankAcctType , Consta nts . TWO ) ) {
createMember ( dto ) ;
AdapayMemberAccount updateRecord = new AdapayMemberAccount ( ) ;
updateRecord . setAdapay MemberId ( adapayMemberAccount . getAdapayMemberId ( ) ) ;
updateRecord . setSettleAccountId ( ( String ) settleCou nt. get ( " id " ) ) ;
adapayMemberAccountService . updateAdapayMemberAccountByMemberId ( updateRecord ) ;
}
/**
* 查询当前商户的结算账户
*/
public List < AdapaySettleAccountVO > selectSettleAccount ( String merchantId ) throws BaseAdaPayException {
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService . selectByMerchantId ( merchantId ) ;
if ( adapayMemberAccount = = null ) {
return Lists . newArrayList ( ) ;
}
String wechatAppId = pileMerchantInfoService . queryAppIdByMerchantId ( merchantId ) ;
String settleAccountId = adapayMemberAccount . getSettleAccountId ( ) ;
if ( StringUtils . isBlank ( settleAccountId ) & & isCorpMember ( adapayMemberAccount . getAdapayMemberId ( ) ) ) {
AdapayCorpMemberVO corpMemberVO = queryCorpAdapayMemberInfo ( adapayMemberAccount . getAdapayMemberId ( ) , wechatAppId ) ;
if ( corpMemberVO ! = null ) {
settleAccountId = corpMemberVO . getSettleAccountId ( ) ;
}
}
AdapaySettleAccountVO adapaySettleAccountVO = queryAdapaySettleAccount ( adapayMemberAccount . getAdapayMemberId ( ) , settleAccountId , wechatAppId ) ;
if ( adapaySettleAccountVO = = null ) {
return Lists . newArrayList ( ) ;
}
adapaySettleAccountVO . setMerchantId ( merchantId ) ;
return Lists . newArrayList ( adapaySettleAccountVO ) ;
}
/**
@@ -314,9 +372,8 @@ public class AdapayService {
// 查询汇付会员关系
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService . selectByMerchantId ( dto . getMerchantId ( ) ) ;
if ( adapayMemberAccount ! = null & & StringUtils . equals ( adapayMemberAccount . getStatus ( ) , Constants . ONE ) ) {
log . error ( " 通过merchantId:{}, 查询到结算账户配置:{} " , dto . getMerchantId ( ) , JSON . toJSONString ( adapayMemberAccount ) ) ;
return ;
if ( adapayMemberAccount ! = null ) {
throw new BusinessException ( " " , " 当前商户已绑定汇付用户 " ) ;
}
log . info ( " =======execute CreateMember begin======= " ) ;
@@ -338,19 +395,10 @@ public class AdapayService {
throw new BusinessException ( " 00500001 " , errorMsg ) ;
}
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 = new AdapayMemberAccount ( ) ;
adapayMemberAccount . setMerchantId ( dto . getMerchantId ( ) ) ;
adapayMemberAccount . setAdapayMemberId ( adapayMemberId ) ;
adapayMemberAccount . setSettleAccountId ( settleAccountId ) ;
adapayMemberAccount . setStatus ( Constants . ONE ) ;
adapayMemberAccountService . insertAdapayMemberAccount ( adapayMemberAccount ) ;
}
@@ -361,66 +409,61 @@ public class AdapayService {
* @param merchantId
* @return
*/
public Map < String , Object > selectAdapayMember ( String merchantId ) throws BaseAdaPayException {
Map < String , Object > map = Maps . newHashMap ( ) ;
public AdapayMemberAggregateVO selectAdapayMember ( String merchantId ) throws BaseAdaPayException {
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService . selectByMerchantId ( merchantId ) ;
if ( adapayMemberAccount = = null ) {
log . error ( " 通过merchantId:{}, 没有查询到结算账户配置 " , merchantId ) ;
return null ;
}
String bankAcctType = null ;
A dapayMemberInfoVO adapayMemberInfoVO = null ;
AdapayCorpMemberVO adapayCorpMemberVO = null ;
List < AdapaySettleAccountVO > list = null ;
AdapayMemberAggregateVO . AdapayMemberAggregateVOBuilder builder = AdapayMemberAggregateVO . builder ( )
. a dapayMemberId ( adapayMemberAccount . getAdapayMemberId ( ) ) ;
// 审核失败
if ( Constants . TWO . equals ( adapayMemberAccount . getStatus ( ) ) ) {
bankAcctType = Constants . ONE ; // 只有企业用户才会审核失败
adapayCorpMemberVO = new AdapayCorpMemberVO ( ) ;
AdapayCorpMemberVO adapayCorpMemberVO = new AdapayCorpMemberVO ( ) ;
MerchantInfoVO merchantInfoVO = pileMerchantInfoService . getMerchantInfoVO ( adapayMemberAccount . getMerchantId ( ) ) ;
if ( merchantInfoVO ! = null ) {
adapayCorpMemberVO . setName ( merchantInfoVO . getMerchantName ( ) ) ;
}
adapayCorpMemberVO . setAuditState ( " B " ) ;
adapayCorpMemberVO . setAuditDesc ( adapayMemberAccount . getRemark ( ) ) ;
map . put ( " adapayCorpMember " , adapayCorpMemberVO ) ;
map . put ( " bankAcctType " , bankAcctType ) ;
map . put ( " adapayMember " , adapayMemberInfoVO ) ;
map . put ( " settleAccountList " , list ) ;
return map ;
return builder
. memberType ( " CORP " )
. bankAcctType ( Constants . ONE )
. adapayCorpMember ( adapayCorpMemberVO )
. settleAccountList ( Lists . newArrayList ( ) )
. canDeleteUser ( true )
. build ( ) ;
}
// 通过merchantId获取appId
String wechatAppId = pileMerchantInfoService . queryAppIdByMerchantId ( merchantId ) ;
String adapayMemberId = adapayMemberAccount . getAdapayMemberId ( ) ;
List < AdapaySettleAccountVO > settleAccountList = selectSettleAccount ( merchantId ) ;
boolean canDeleteUser = CollectionUtils . isEmpty ( settleAccountList ) ;
builder
. settleAccountList ( settleAccountList )
. canDeleteUser ( canDeleteUser )
. deleteBlockReason ( canDeleteUser ? " " : " 请先删除结算账户 " ) ;
if ( StringUtils . startsWith ( adapayMemberId , Constants . ADAPAY_MEMBER_PREFIX ) ) {
bankAcctType = Constants . TWO ;
// 查询个人用户
adapayMemberInfoVO = queryAdapayMemberInfo ( adapayMemberId , wechatAppId ) ;
if ( adapayMemberInfoVO ! = null ) {
adapayMemberInfoVO . setMerchantId ( merchantId ) ;
}
AdapaySettleAccountVO adapaySettleAccountVO = queryAdapaySettleAccount ( adapayMemberId , adapayMemberAccount . getSettleAccountId ( ) , wechatAppId ) ;
if ( adapaySettleAccountVO ! = null ) {
adapaySettleAccountVO . setMerchantId ( merchantId ) ;
}
map . put ( " adapayMember " , adapayMemberInfoVO ) ;
list = Lists . newArrayList ( adapaySettleAccountVO ) ;
map . put ( " settleAccountList " , list ) ;
} else {
bankAcctType = Constants . ONE ;
// 查询企业用户
adapayCorpMemberVO = queryCorpAdapayMemberInfo ( adapayMemberId , wechatAppId ) ;
AdapayMemberInfoVO adapayMemberInfoVO = queryAdapayMemberInfo ( adapayMemberId , wechatAppId ) ;
return builder
. memberType ( " PERSONAL " )
. bankAcctType ( Constants . TWO )
. adapayMember( adapayMemberInfoVO )
. build ( ) ;
}
map . put ( " bankAcctType " , bankAcctType ) ;
map . put ( " adapayMember" , adapayMemberInfoVO ) ;
map . put ( " settleAccountList " , list ) ;
map . put ( " adapayCorpMember " , adapayCorpMemberVO ) ;
return map ;
// 查询企业用户
AdapayCorpMemberVO adapayCorp MemberVO = queryCorpAdapayMemberInfo ( adapayMemberId , wechatAppId ) ;
return builder
. memberType ( " CORP " )
. bankAcctType ( Constants . ONE )
. adapayCorpMember ( adapayCorpMemberVO )
. build ( ) ;
}
@@ -449,6 +492,7 @@ public class AdapayService {
QueryMemberResponse queryMemberResponse = JSON . parseObject ( JSON . toJSONString ( member ) , QueryMemberResponse . class ) ;
AdapayMemberInfoVO resultVO = AdapayMemberInfoVO . builder ( )
. memberId ( adapayMemberId )
. nickname ( queryMemberResponse . getNickname ( ) )
. gender ( queryMemberResponse . getGender ( ) )
. email ( queryMemberResponse . getEmail ( ) )
@@ -761,6 +805,11 @@ public class AdapayService {
// 逻辑删除原来审核不通过的记录
adapayMemberAccountService . deleteAuditFailed ( dto . getMerchantId ( ) ) ;
AdapayMemberAccount currentAccount = adapayMemberAccountService . selectByMerchantId ( dto . getMerchantId ( ) ) ;
if ( currentAccount ! = null ) {
throw new BusinessException ( " " , " 当前商户已绑定汇付用户 " ) ;
}
// 创建企业用户参数
Map < String , Object > memberParams = Maps . newHashMap ( ) ;
String adapayMemberId = Constants . ADAPAY_CORP_MEMBER_PREFIX + IdUtils . getMemberId ( ) ;
@@ -790,10 +839,6 @@ 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 ( " notify_url " , ADAPAY_CALLBACK_URL ) ;
File file = ZipUtil . createZipFileFromImages ( dto . getImgList ( ) ) ;
Map < String , Object > member = CorpMember . create ( memberParams , file , config . getWechatAppId ( ) ) ;
@@ -958,6 +1003,63 @@ public class AdapayService {
* @return
* @throws BaseAdaPayException
*/
public void updateAdapayMember ( Map < String , Object > payload ) throws BaseAdaPayException {
String merchantId = ( String ) payload . get ( " merchantId " ) ;
AdapayMemberAccount adapayMemberAccount = requireCurrentMemberAccount ( merchantId ) ;
if ( isPersonalMember ( adapayMemberAccount . getAdapayMemberId ( ) ) ) {
UpdatePersonalMemberDTO dto = JSON . parseObject ( JSON . toJSONString ( payload ) , UpdatePersonalMemberDTO . class ) ;
updatePersonalMember ( dto ) ;
return ;
}
UpdateCorpMemberDTO dto = JSON . parseObject ( JSON . toJSONString ( payload ) , UpdateCorpMemberDTO . class ) ;
updateCorpMember ( dto ) ;
}
public void updateCorpMember ( UpdateCorpMemberDTO dto ) throws BaseAdaPayException {
SettleAccountDTO request = SettleAccountDTO . builder ( )
. merchantId ( dto . getMerchantId ( ) )
. businessName ( dto . getName ( ) )
. provCode ( dto . getProvCode ( ) )
. areaCode ( dto . getAreaCode ( ) )
. socialCreditCodeExpires ( dto . getSocialCreditCodeExpires ( ) )
. businessScope ( dto . getBusinessScope ( ) )
. legalPerson ( dto . getLegalPerson ( ) )
. legalCertId ( dto . getLegalCertId ( ) )
. legalCertIdExpires ( dto . getLegalCertIdExpires ( ) )
. legalMp ( dto . getLegalMp ( ) )
. address ( dto . getAddress ( ) )
. zipCode ( dto . getZipCode ( ) )
. telphone ( dto . getTelphone ( ) )
. email ( dto . getEmail ( ) )
. imgList ( dto . getImgList ( ) )
. build ( ) ;
updateAdapayMember ( request ) ;
}
public void updatePersonalMember ( UpdatePersonalMemberDTO dto ) throws BaseAdaPayException {
String wechatAppId = pileMerchantInfoService . queryAppIdByMerchantId ( dto . getMerchantId ( ) ) ;
AbstractAdapayConfig config = AdapayConfigFactory . getConfig ( wechatAppId ) ;
if ( config = = null ) {
throw new BusinessException ( ReturnCodeEnum . CODE_ADAPAY_CONFIG_IS_NULL_ERROR ) ;
}
AdapayMemberAccount adapayMemberAccount = requireCurrentMemberAccount ( dto . getMerchantId ( ) ) ;
Map < String , Object > memberParams = Maps . newHashMap ( ) ;
memberParams . put ( " member_id " , adapayMemberAccount . getAdapayMemberId ( ) ) ;
memberParams . put ( " app_id " , config . getAdapayAppId ( ) ) ;
memberParams . put ( " location " , dto . getLocation ( ) ) ;
memberParams . put ( " email " , dto . getEmail ( ) ) ;
memberParams . put ( " gender " , dto . getGender ( ) ) ;
memberParams . put ( " nickname " , dto . getNickname ( ) ) ;
Map < String , Object > member = Member . update ( memberParams , config . getWechatAppId ( ) ) ;
log . info ( " 更新个人账户param:{}, result:{} " , JSON . toJSONString ( memberParams ) , JSON . toJSONString ( member ) ) ;
if ( member = = null | | AdapayStatusEnum . FAILED . getValue ( ) . equals ( ( String ) member . get ( " status " ) ) ) {
String errorMsg = member = = null ? " 更新汇付个人用户失败 " : ( String ) member . get ( " error_msg " ) ;
throw new BusinessException ( " " , errorMsg ) ;
}
}
public Map < String , Object > updateAdapayMember ( SettleAccountDTO dto ) throws BaseAdaPayException {
String wechatAppId = pileMerchantInfoService . queryAppIdByMerchantId ( dto . getMerchantId ( ) ) ;
// 获取汇付支付配置
@@ -1486,7 +1588,13 @@ public class AdapayService {
settleAccountDTO . setBankAcctType ( dto . getBankAcctType ( ) ) ;
settleAccountDTO . setProvCode ( dto . getProvCode ( ) ) ;
settleAccountDTO . setAreaCode ( dto . getAreaCode ( ) ) ;
this . createSettleAccountRequest ( settleAccountDTO , adapayMemberId , wechatAppId ) ;
Map < String , Object > settleAccount = this . createSettleAccountRequest ( settleAccountDTO , adapayMemberId , wechatAppId ) ;
if ( settleAccount ! = null & & ! StringUtils . equals ( ( String ) settleAccount . get ( " status " ) , " failed " ) ) {
AdapayMemberAccount updateRecord = new AdapayMemberAccount ( ) ;
updateRecord . setAdapayMemberId ( adapayMemberId ) ;
updateRecord . setSettleAccountId ( ( String ) settleAccount . get ( " id " ) ) ;
adapayMemberAccountService . updateAdapayMemberAccountByMemberId ( updateRecord ) ;
}
}
/**
@@ -1551,33 +1659,21 @@ public class AdapayService {
* @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 ( s ettleAccount = = 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 ) ;
CreateSettleAccountDTO request = CreateSettleAccountDTO . builder ( )
. merchantId ( dto . getMerchantId ( ) )
. bankAcctType ( dto . getBankAcctType ( ) )
. cardId ( dto . getCardId ( ) )
. cardNo ( dto . getCardNo ( ) )
. cardName ( dto . getCardName ( ) )
. certId ( dto . getCertId ( ) )
. certType ( dto . getCertType ( ) )
. telNo ( dto . getTelNo ( ) )
. bankCode ( dto . getBankCode ( ) )
. bankName ( dto . getBankName ( ) )
. provCode ( dto . getProvCode ( ) )
. areaCode ( dto . getAreaCode ( ) )
. build ( ) ;
createS ettleAccount( request ) ;
}
/**
@@ -1586,14 +1682,79 @@ public class AdapayService {
* @throws BaseAdaPayException
*/
public void deleteSettleAccount ( AdapayMemberInfoDTO dto ) throws BaseAdaPayException {
// 查询appId
AdapayMemberAccount adapayMemberAccount = requireCurrentMemberAccount ( dto . getMerchantId ( ) ) ;
String wechatAppId = pileMerchantInfoService . queryAppIdByMerchantId ( dto . getMerchantId ( ) ) ;
// 1、新建删除请求 2、如果成功, 再将数据库中的记录删除
this . createDeleteSettleAccountRequest ( dto . getAdapayMember Id ( ) , dto . getSettleAccountId ( ) , wechatAppId ) ;
// 删除数据库中的记录
String adapayMemberId = StringUtils . isNotBlank ( dto . getAdapayMemberId ( ) ) ? dto . getAdapayMemberId ( ) : adapayMemberAccount . getAdapayMemberId ( ) ;
String settleAccountId = StringUtils . isNotBlank ( dto . getSettleAccount Id ( ) ) ? dto . getSettleAccountId ( ) : adapayMemberAccount . getSettleAccountId ( ) ;
if ( StringUtils . isBlank ( settleAccountId ) & & isCorpMember ( adapayMemberId ) ) {
AdapayCorpMemberVO corpMemberVO = queryCorpAdapayMemberInfo ( adapayMemberId , wechatAppId ) ;
if ( corpMemberVO ! = null ) {
settleAccountId = corpMemberVO . getSettleAccountId ( ) ;
}
}
if ( StringUtils . isBlank ( settleAccountId ) ) {
throw new BusinessException ( " " , " 未查询到结算账户 " ) ;
}
this . createDeleteSettleAccountRequest ( adapayMemberId , settleAccountId , wechatAppId ) ;
adapayMemberAccountService . clearSettleAccountByMerchantId ( dto . getMerchantId ( ) ) ;
}
public void deleteAdapayMember ( DeleteAdapayMemberDTO dto ) throws BaseAdaPayException {
AdapayMemberAccount adapayMemberAccount = requireCurrentMemberAccount ( dto . getMerchantId ( ) ) ;
if ( StringUtils . isNotBlank ( dto . getAdapayMemberId ( ) )
& & ! StringUtils . equals ( dto . getAdapayMemberId ( ) , adapayMemberAccount . getAdapayMemberId ( ) ) ) {
throw new BusinessException ( " " , " 汇付用户信息不匹配 " ) ;
}
if ( CollectionUtils . isNotEmpty ( selectSettleAccount ( dto . getMerchantId ( ) ) ) ) {
throw new BusinessException ( " " , " 请先删除结算账户 " ) ;
}
adapayMemberAccountService . deleteAccountByMerchantId ( dto . getMerchantId ( ) ) ;
}
private AdapayMemberAccount requireCurrentMemberAccount ( String merchantId ) {
AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService . selectByMerchantId ( merchantId ) ;
if ( adapayMemberAccount = = null ) {
throw new BusinessException ( ReturnCodeEnum . CODE_ADAPAY_MEMBER_IS_NULL_ERROR ) ;
}
return adapayMemberAccount ;
}
private boolean isPersonalMember ( String adapayMemberId ) {
return StringUtils . startsWith ( adapayMemberId , Constants . ADAPAY_MEMBER_PREFIX ) ;
}
private boolean isCorpMember ( String adapayMemberId ) {
return StringUtils . startsWith ( adapayMemberId , Constants . ADAPAY_CORP_MEMBER_PREFIX ) ;
}
private SettleAccountDTO buildSettleAccountDTO ( CreateSettleAccountDTO dto ) {
SettleAccountDTO request = SettleAccountDTO . builder ( )
. merchantId ( dto . getMerchantId ( ) )
. bankAcctType ( dto . getBankAcctType ( ) )
. cardId ( dto . getCardId ( ) )
. cardNo ( dto . getCardNo ( ) )
. cardName ( dto . getCardName ( ) )
. certId ( dto . getCertId ( ) )
. certType ( dto . getCertType ( ) )
. telNo ( dto . getTelNo ( ) )
. bankCode ( dto . getBankCode ( ) )
. bankName ( dto . getBankName ( ) )
. provCode ( dto . getProvCode ( ) )
. areaCode ( dto . getAreaCode ( ) )
. build ( ) ;
String cardId = request . getCardId ( ) ;
String cardNo = request . getCardNo ( ) ;
if ( StringUtils . isBlank ( cardId ) & & StringUtils . isNotBlank ( cardNo ) ) {
request . setCardId ( cardNo ) ;
}
if ( StringUtils . isBlank ( cardNo ) & & StringUtils . isNotBlank ( cardId ) ) {
request . setCardNo ( cardId ) ;
}
return request ;
}
/**
* 根据paymentIdList查询分账信息
* @param paymentIdList