@@ -4,10 +4,7 @@ import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject ;
import com.cool.store.constants.CommonConstants ;
import com.cool.store.constants.RedisConstant ;
import com.cool.store.dao.LineInfoDAO ;
import com.cool.store.dao.RegionDao ;
import com.cool.store.dao.ShopInfoDAO ;
import com.cool.store.dao.ShopStageInfoDAO ;
import com.cool.store.dao.* ;
import com.cool.store.dao.wallet.WalletPaymentOrderDAO ;
import com.cool.store.dto.wallet.* ;
import com.cool.store.entity.* ;
@@ -66,6 +63,7 @@ public class WalletServiceImpl implements WalletService {
private final WalletPaymentOrderDAO walletPaymentOrderDAO ;
private final LineInfoDAO lineInfoDAO ;
private final RedisUtilPool redisUtilPool ;
private final QualificationsInfoDAO qualificationsInfoDAO ;
private final static DateTimeFormatter formatter = DateTimeFormatter . ofPattern ( " yyyy-MM-dd HH:mm:ss " ) ;
@@ -73,10 +71,6 @@ public class WalletServiceImpl implements WalletService {
public Boolean accountCreate ( AccountCreateRequest request ) {
ShopInfoDO shopInfo = getAndVerifyShopAndStage ( request . getShopId ( ) ) ;
// 调用 创建门店签约人账户接口
RegionDO regionDO = regionDao . getRegionById ( shopInfo . getRegionId ( ) ) ;
if ( Objects . isNull ( regionDO ) ) {
throw new ServiceException ( ErrorCodeEnum . REGION_NOT_EXIST ) ;
}
CreateStoreAndAccountRequest accountRequest = CreateStoreAndAccountRequest . builder ( )
. outStoreId ( shopInfo . getStoreId ( ) )
. phoneNumber ( request . getMobile ( ) )
@@ -102,7 +96,7 @@ public class WalletServiceImpl implements WalletService {
if ( Objects . nonNull ( authentication ) ) {
if ( authentication . getAccountStatus ( ) . equals ( 4 ) ) {
// 判断营业执照是否已经上传,已上传则调用打标接口
addTagIfUploadLicense ( request . getShopId ( ) , shopInfo . getStoreId ( ) ) ;
addTagIfUploadLicense ( request . getShopId ( ) , shopInfo . getStoreId ( ) , shopInfo . getLineId ( ) );
}
return new AccountAuthenticationVO ( authentication . getAccountStatus ( ) ) ;
}
@@ -132,7 +126,7 @@ public class WalletServiceImpl implements WalletService {
shopStageInfoDAO . batchUpdateShopStageStatus ( request . getShopId ( ) , updateSubStageList ) ;
// 判断营业执照是否已经上传,已上传则调用打标接口
addTagIfUploadLicense ( request . getShopId ( ) , shopInfo . getStoreId ( ) ) ;
addTagIfUploadLicense ( request . getShopId ( ) , shopInfo . getStoreId ( ) , shopInfo . getLineId ( ) );
return true ;
}
@@ -160,23 +154,33 @@ public class WalletServiceImpl implements WalletService {
}
@Override
public void addTagIfUploadLicense ( Long shopId , String storeId ) {
LicenseTransactDO licenseTransactDO = applyLicenseMapper . selectByShopId ( shopId ) ;
public void addTagIfUploadLicense ( Long shopId , String storeId , Long lineId ) {
LicenseTransactDO license = applyLicenseMapper . selectByShopId ( shopId ) ;
// 营业执照已上传,调用打标接口
if ( Objects . nonNull ( licenseTransactDO ) & & StringUtils . isNotBlank ( licenseTransactDO . getCreditUrl ( ) ) ) {
if ( Objects . nonNull ( license ) & & StringUtils . isNotBlank ( license . getCreditUrl ( ) ) ) {
try {
// 判断一下账户的开通状态
if ( enableAddTag ( storeId ) ) {
LineInfoDO lineInfoDO = lineInfoDAO . getLineInfo ( lineId ) ;
QualificationsInfoDO qualificationsInfoDO = qualificationsInfoDAO . getByLineId ( lineId ) ;
// 调用 签约人账户打标(升级)接口
log . info ( " 营业执照已上传,账户打标 " ) ;
AccountAddTagRequest tagRequest = AccountAddTagRequest . builder ( )
. outStoreId ( storeId )
. licenseNo ( licenseTransactDO . getCreditCode ( ) )
. licenseName ( licenseTransactDO . getBusinessLicense ( ) )
. licenseNo ( license . getCreditCode ( ) )
. licenseName ( license . getBusinessLicense ( ) )
// .licenseExpire(Objects.nonNull(licenseTransactDO.getValidity()) ? CoolDateUtils.DateFormat(licenseTransactDO.getValidity(), "yyyy-MM-dd") : "2999-12-31")
. legalName ( licenseTransactDO . getLicenseLegalPerson ( ) )
. legalNo ( licenseTransactDO . getLicenseLegalIdCardNo ( ) )
. legalPhone ( licenseTransactDO . getLicenseLegalMobile ( ) )
. legalName ( license . getLicenseLegalPerson ( ) )
. legalNo ( license . getLicenseLegalIdCardNo ( ) )
. legalPhone ( license . getLicenseLegalMobile ( ) )
. certPhotoA ( license . getLicenseLegalIdCardFront ( ) )
. certPhotoB ( license . getLicenseLegalIdCardBack ( ) )
. licensePhoto ( license . getCreditUrl ( ) )
. signatoryName ( lineInfoDO . getUsername ( ) )
. signatoryNo ( qualificationsInfoDO . getIdCardNo ( ) )
. signatoryPhone ( lineInfoDO . getMobile ( ) )
. signatoryPhotoA ( qualificationsInfoDO . getFrontOfIdCard ( ) )
. signatoryPhotoB ( qualificationsInfoDO . getBackOfIdCard ( ) )
. build ( ) ;
AddTagDTO addTagDTO = walletApiService . addTag ( tagRequest ) ;
log . info ( " 打标接口调用成功, response:{} " , JSONObject . toJSONString ( addTagDTO ) ) ;
@@ -210,18 +214,33 @@ public class WalletServiceImpl implements WalletService {
redisUtilPool . delKey ( key ) ;
}
} catch ( Exception e ) {
log . info ( " 回调失败 " , e ) ;
log . info ( " 平安打标 回调失败" , e ) ;
}
return Boolean . TRUE ;
}
@Override
public Boolean largePaymentCallback ( PaymentDTO request ) {
try {
walletPaymentOrderDAO . updateOrderByPaymentId ( request . getOutStoreId ( ) , request . getPaymentId ( ) , request . getOrderStatus ( ) ) ;
} catch ( Exception e ) {
log . error ( " 大额充值回调失败 " , e ) ;
}
return Boolean . TRUE ;
}
@Override
public Boolean onlineCommercialBankCallback ( OnlineCommercialBankCallbackRequest request ) {
try {
String key = MessageFormat . format ( RedisConstant . WALLET_OPEN_FAIL , request . getOutStoreId ( ) , " 1 " ) ;
if ( Integer . valueOf ( 5 ) . equals ( request . getAccountStatus ( ) ) ) {
redisUtilPool . setString ( key , request . getFailReason ( ) ) ;
} else {
redisUtilPool . delKey ( key ) ;
}
} catch ( Exception e ) {
log . info ( " 平安打标回调失败 " , e ) ;
}
return Boolean . TRUE ;
}
@@ -259,14 +278,15 @@ public class WalletServiceImpl implements WalletService {
. outStoreId ( shopInfo . getStoreId ( ) )
. beginDate ( DateUtil . format ( request . getBeginDate ( ) , " yyyy-MM-dd HH:mm:ss " ) )
. endDate ( DateUtil . format ( request . getEndDate ( ) , " yyyy-MM-dd HH:mm:ss " ) )
. walletType ( CommonConstants . INDEX_ONE . equals ( request. getIsLegal ( ) ) ? 2 : 1 )
. walletType ( request . getWalletType ( ) )
. isLegal ( request . getIsLegal ( ) )
. recordType ( request . getRecordType ( ) )
. feeItemId ( request . getFeeItemId ( ) )
. currentPage ( request . getPageNum ( ) )
. pageSize ( request . getPageSize ( ) )
. build ( ) ;
BillPageDTO billPage = walletApiService . getBillPage ( billPageRequest ) ;
return toPageInfo ( billPage . getData ( ) , AccountBillListVO . class , billPage . getPage ( ) ) ;
return toPageInfo ( billPage . getPage Data ( ) , AccountBillListVO . class , billPage . getPage ( ) ) ;
}
@Override
@@ -344,7 +364,7 @@ public class WalletServiceImpl implements WalletService {
public Boolean withDrawer ( WalletWithDrawerRequest request ) {
String storeId = getStoreId ( request ) ;
String reqNo = UUIDUtils . get32UUID ( ) ;
WithDrawerRequest withDrawerRequest = new WithDrawerRequest ( storeId , request . getPayPwd ( ) , reqNo , request . getAmount ( ) . toString ( ) , " 提现 " ) ;
WithDrawerRequest withDrawerRequest = new WithDrawerRequest ( storeId , request . getPayPwd ( ) , reqNo , request . getAmount ( ) . toString ( ) , " 提现 " , request . getWalletType ( ) );
WithDrawerDTO withdraw = walletApiService . withdraw ( withDrawerRequest ) ;
if ( " 2 " . equals ( withdraw . getTradeStatus ( ) ) ) {
throw new ServiceException ( ErrorCodeEnum . WALLET_WITH_DRAWER_FAIL ) ;