@ -142,6 +142,7 @@ import java.security.InvalidParameterException;
import java.security.KeyPair ;
import java.security.KeyPair ;
import java.security.interfaces.RSAPrivateKey ;
import java.security.interfaces.RSAPrivateKey ;
import java.security.interfaces.RSAPublicKey ;
import java.security.interfaces.RSAPublicKey ;
import java.text.ParseException ;
import java.text.SimpleDateFormat ;
import java.text.SimpleDateFormat ;
import java.util.List ;
import java.util.List ;
import java.util.* ;
import java.util.* ;
@ -183,6 +184,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Resource
@Resource
private ClientIncrementalMapper clientIncrementalMapper ;
private ClientIncrementalMapper clientIncrementalMapper ;
@Value ( "${client_card.account_reserve}" )
private String cardAccountReserve ;
@Value ( "${client_card.annual_rate}" )
private String cardAnnualRate ;
@Value ( "${app.redis.prefix}" )
@Value ( "${app.redis.prefix}" )
private String redisPrefix ;
private String redisPrefix ;
private ApplicationEventPublisher publisher ;
private ApplicationEventPublisher publisher ;
@ -326,6 +332,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
private RPayPaymentCardSvcApi rPayPaymentCardSvcApi ;
private RPayPaymentCardSvcApi rPayPaymentCardSvcApi ;
@Resource
@Resource
private RPayMerchantMapper rPayMerchantMapper ;
private RPayMerchantMapper rPayMerchantMapper ;
@Resource
private SysClientUpayProfileMapper sysClientUpayProfileMapper ;
@Resource
@Resource
@ -336,6 +344,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
private static final String CLIENT_AGREE_FILE = "client_agree_file" ;
private static final String CLIENT_AGREE_FILE = "client_agree_file" ;
private static final String CLIENT_COMPANY_FILE = "client_company_file" ;
private static final String CLIENT_COMPANY_FILE = "client_company_file" ;
private static final String CLIENT_APPLY_FILE = "client_apply_file" ;
private static final String CLIENT_APPLY_FILE = "client_apply_file" ;
//卡支付合同文件
private static final String LETTER_OF_OFFER_FILE = "letter_of_offer_file" ;
private static final String PROMOTIONAL_OFFER_FILE = "promotional_offer_file" ;
private static final String TERMS_AND_CONDITIONS_FILE = "terms_and_conditions_file" ;
private static final List < String > tags = new ArrayList < > ( ) ;
private static final List < String > tags = new ArrayList < > ( ) ;
private static final String KYC_UTILITY_BILL_FILE = "kyc_utility_bill_file" ;
private static final String KYC_UTILITY_BILL_FILE = "kyc_utility_bill_file" ;
@ -433,6 +448,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientConfig . put ( "ext_params" , client . getString ( "ext_params" ) ) ;
clientConfig . put ( "ext_params" , client . getString ( "ext_params" ) ) ;
}
}
client . putAll ( clientConfig ) ;
client . putAll ( clientConfig ) ;
JSONObject upayInfo = sysClientUpayProfileMapper . findInfo ( client . getIntValue ( "client_id" ) ) ;
if ( upayInfo ! = null ) {
client . putAll ( upayInfo ) ;
}
client . put ( "unsubscribe" , mailUnsubMapper . findOneByClientMoniker ( clientMoniker ) = = null ? false : true ) ;
client . put ( "unsubscribe" , mailUnsubMapper . findOneByClientMoniker ( clientMoniker ) = = null ? false : true ) ;
client . put ( "show_all_permission" , true ) ;
client . put ( "show_all_permission" , true ) ;
int role = manager ! = null ? manager . getIntValue ( "role" ) : 0 ;
int role = manager ! = null ? manager . getIntValue ( "role" ) : 0 ;
@ -447,7 +466,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
client . put ( "show_all_permission" , checkBDPermission > 0 ) ;
client . put ( "show_all_permission" , checkBDPermission > 0 ) ;
if ( checkBDPermission > 0 ) {
if ( checkBDPermission > 0 ) {
JSONObject org = orgMapper . findOne ( manager . getIntValue ( "org_id" ) ) ;
JSONObject org = orgMapper . findOne ( manager . getIntValue ( "org_id" ) ) ;
boolean bdRateEditable = client . getIntValue ( "approve_result" ) ! = 1 | | org . getBooleanValue ( "rate_editable" ) ;
boolean bdRateEditable = client . getIntValue ( "approve_result" ) ! = 1 | | org . getBooleanValue ( "rate_editable" ) | |
//开起信用卡支付申请, 并且申请结果不是: null.新建 1.通过 4.BD已提交资料状态
( ! clientConfig . getBoolean ( "enable_card_payment" ) & & ! client . containsKey ( "upay_approve_result" ) & & client . getIntValue ( "upay_approve_result" ) ! = 1 & & client . getIntValue ( "upay_approve_result" ) ! = 4 ) ;
client . put ( "rate_editable" , bdRateEditable ) ;
client . put ( "rate_editable" , bdRateEditable ) ;
} else {
} else {
client . put ( "company_phone" , "******" ) ;
client . put ( "company_phone" , "******" ) ;
@ -486,12 +507,18 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
client . put ( "min_customer_surcharge_rate" , client . getBigDecimal ( "rate_value" ) . add ( new BigDecimal ( "0.1" ) ) ) ;
client . put ( "min_customer_surcharge_rate" , client . getBigDecimal ( "rate_value" ) . add ( new BigDecimal ( "0.1" ) ) ) ;
}
}
// 商户 审核过程日志
// 商户 跨境支付 审核过程日志
PageList < JSONObject > audit_logs = clientAuditProcessMapper . getAuditLog ( client . getIntValue ( "client_id" ) ,
PageList < JSONObject > audit_logs = clientAuditProcessMapper . getAuditLog ( client . getIntValue ( "client_id" ) , 1 ,
new PageBounds ( Order . formString ( "create_time" ) ) ) ;
new PageBounds ( Order . formString ( "create_time" ) ) ) ;
if ( audit_logs ! = null & & ! audit_logs . isEmpty ( ) ) {
if ( audit_logs ! = null & & ! audit_logs . isEmpty ( ) ) {
client . put ( "audit_logs" , audit_logs ) ;
client . put ( "audit_logs" , audit_logs ) ;
}
}
//商户卡支付审核过程日志
PageList < JSONObject > audit_card_logs = clientAuditProcessMapper . getAuditLog ( client . getIntValue ( "client_id" ) , 2 ,
new PageBounds ( Order . formString ( "create_time" ) ) ) ;
if ( audit_card_logs ! = null & & ! audit_card_logs . isEmpty ( ) ) {
client . put ( "audit_card_logs" , audit_card_logs ) ;
}
//HF支付链接二维码
//HF支付链接二维码
if ( client . getString ( "hf_pay_url" ) ! = null ) {
if ( client . getString ( "hf_pay_url" ) ! = null ) {
@ -782,10 +809,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
partner . put ( "ali_sub_merchant_id" , registery . getClientMoniker ( ) ) ;
partner . put ( "ali_sub_merchant_id" , registery . getClientMoniker ( ) ) ;
partner . put ( "credential_code" , RandomStringUtils . random ( 32 , true , true ) ) ;
partner . put ( "credential_code" , RandomStringUtils . random ( 32 , true , true ) ) ;
partner . put ( "creator" , manager . getString ( "manager_id" ) ) ;
partner . put ( "creator" , manager . getString ( "manager_id" ) ) ;
// if (manager.getIntValue("org_id") == 0) {
// throw new ForbiddenException("You were not belong to any organizations so that you cannot create new
// client");
// }
partner . put ( "org_id" , manager . getIntValue ( "org_id" ) ) ;
partner . put ( "org_id" , manager . getIntValue ( "org_id" ) ) ;
if ( StringUtils . isNotEmpty ( registery . getLogoId ( ) ) ) {
if ( StringUtils . isNotEmpty ( registery . getLogoId ( ) ) ) {
partner . put ( "logo_url" , attachmentClient . getFileUrl ( registery . getLogoId ( ) ) ) ;
partner . put ( "logo_url" , attachmentClient . getFileUrl ( registery . getLogoId ( ) ) ) ;
@ -807,43 +830,24 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
//isRiskyMerchant(partner, null);
//isRiskyMerchant(partner, null);
try {
try {
clientMapper . save ( partner ) ;
clientMapper . save ( partner ) ;
JSONObject clientConfig = new JSONObject ( ) ;
JSONObject clientConfig = new JSONObject ( ) ;
clientConfig . put ( "client_id" , partner . getIntValue ( "client_id" ) ) ;
clientConfig . put ( "client_id" , partner . getIntValue ( "client_id" ) ) ;
clientConfig . put ( "client_moniker" , partner . getString ( "client_moniker" ) ) ;
clientConfig . put ( "client_moniker" , partner . getString ( "client_moniker" ) ) ;
clientConfig . put ( "client_pay_type" , partner . getString ( "client_pay_type" ) ) ;
clientConfig . put ( "client_pay_type" , partner . getString ( "client_pay_type" ) ) ;
clientConfig . put ( "client_pay_desc" , partner . get ( "client_pay_desc" ) ) ;
clientConfig . put ( "client_pay_desc" , partner . get ( "client_pay_desc" ) ) ;
clientConfig . put ( "enable_cross_payment" , partner . get ( "enable_cross_payment" ) ) ;
clientConfig . put ( "enable_card_payment" , partner . get ( "enable_card_payment" ) ) ;
clientConfigService . save ( clientConfig ) ;
clientConfigService . save ( clientConfig ) ;
permissionPartnerManagerImpl . permissionClientModuleSave ( partner . getIntValue ( "client_id" ) , partner . getString ( "client_moniker" ) ) ;
permissionPartnerManagerImpl . permissionClientModuleSave ( partner . getIntValue ( "client_id" ) , partner . getString ( "client_moniker" ) ) ;
} catch ( Exception e ) {
saveLegalAndMarketingInfo ( partner ) ;
throw new BadRequestException ( "error.partner.valid.dumplicate_client_moniker" ) ;
if ( registery . isEnableCardPayment ( ) ) {
sysClientUpayProfileMapper . save ( partner ) ;
}
}
try {
JSONObject representativeInfo = new JSONObject ( ) ;
representativeInfo . put ( "client_id" , partner . getIntValue ( "client_id" ) ) ;
representativeInfo . put ( "representative_person" , partner . getString ( "legal_representative_person" ) ) ;
representativeInfo . put ( "phone" , partner . getString ( "legal_representative_phone" ) ) ;
representativeInfo . put ( "email" , partner . getString ( "legal_representative_email" ) ) ;
representativeInfo . put ( "job_title" , partner . getString ( "legal_representative_job" ) ) ;
representativeInfo . put ( "address" , partner . getString ( "registered_address" ) ) ;
representativeInfo . put ( "suburb" , partner . getString ( "registered_suburb" ) ) ;
representativeInfo . put ( "postcode" , partner . getString ( "registered_postcode" ) ) ;
representativeInfo . put ( "state" , partner . getString ( "registered_state" ) ) ;
representativeInfo . put ( "legal_representative_wechatid" , partner . getString ( "legal_representative_wechatid" ) ) ;
// marking联系人
representativeInfo . put ( "marketing_person" , partner . getString ( "marketing_person" ) ) ;
representativeInfo . put ( "marketing_phone" , partner . getString ( "marketing_phone" ) ) ;
representativeInfo . put ( "marketing_email" , partner . getString ( "marketing_email" ) ) ;
representativeInfo . put ( "marketing_job_title" , partner . getString ( "marketing_job" ) ) ;
representativeInfo . put ( "marketing_wechatid" , partner . getString ( "marketing_wechatid" ) ) ;
sysClientLegalPersonMapper . save ( representativeInfo ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
throw new BadRequestException ( "error.partner.valid.dumplicate_client_moniker" ) ;
throw new BadRequestException ( "error.partner.valid.dumplicate_client_moniker" ) ;
}
}
if ( ManagerRole . BD_USER . hasRole ( manager . getIntValue ( "role" ) ) ) {
if ( ManagerRole . BD_USER . hasRole ( manager . getIntValue ( "role" ) ) ) {
JSONObject client_bd = new JSONObject ( ) ;
JSONObject client_bd = new JSONObject ( ) ;
client_bd . put ( "client_id" , partner . getIntValue ( "client_id" ) ) ;
client_bd . put ( "client_id" , partner . getIntValue ( "client_id" ) ) ;
@ -917,6 +921,16 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
sysClientLegalPersonMapper . save ( representativeInfo ) ;
sysClientLegalPersonMapper . save ( representativeInfo ) ;
}
}
if ( info . isEnableCardPayment ( ) ) {
JSONObject upay = sysClientUpayProfileMapper . findInfo ( clientId ) ;
if ( upay = = null ) {
sysClientUpayProfileMapper . save ( updateInfo ) ;
} else {
upay . putAll ( updateInfo ) ;
sysClientUpayProfileMapper . update ( upay ) ;
}
}
int originReferrerId = client . getIntValue ( "referrer_id" ) ;
int originReferrerId = client . getIntValue ( "referrer_id" ) ;
int updateReferrerId = Integer . parseInt ( info . getReferrer_id ( ) = = null ? "0" : info . getReferrer_id ( ) ) ;
int updateReferrerId = Integer . parseInt ( info . getReferrer_id ( ) = = null ? "0" : info . getReferrer_id ( ) ) ;
if ( originReferrerId = = 0 & & updateReferrerId ! = 0 ) {
if ( originReferrerId = = 0 & & updateReferrerId ! = 0 ) {
@ -932,6 +946,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
JSONObject clientConfig = new JSONObject ( ) ;
JSONObject clientConfig = new JSONObject ( ) ;
clientConfig . put ( "client_id" , clientId ) ;
clientConfig . put ( "client_id" , clientId ) ;
clientConfig . put ( "client_moniker" , client . getString ( "client_moniker" ) ) ;
clientConfig . put ( "client_moniker" , client . getString ( "client_moniker" ) ) ;
clientConfig . put ( "enable_cross_payment" , updateInfo . getBooleanValue ( "enable_cross_payment" ) ) ;
clientConfig . put ( "enable_card_payment" , updateInfo . getBooleanValue ( "enable_card_payment" ) ) ;
if ( StringUtils . isNotBlank ( updateInfo . getString ( "client_pay_type" ) ) & & StringUtils . isNotBlank ( updateInfo . getString ( "client_pay_desc" ) ) ) {
if ( StringUtils . isNotBlank ( updateInfo . getString ( "client_pay_type" ) ) & & StringUtils . isNotBlank ( updateInfo . getString ( "client_pay_desc" ) ) ) {
clientConfig . put ( "client_pay_type" , updateInfo . getString ( "client_pay_type" ) ) ;
clientConfig . put ( "client_pay_type" , updateInfo . getString ( "client_pay_type" ) ) ;
clientConfig . put ( "client_pay_desc" , updateInfo . getString ( "client_pay_desc" ) ) ;
clientConfig . put ( "client_pay_desc" , updateInfo . getString ( "client_pay_desc" ) ) ;
@ -1179,24 +1195,55 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if ( client . getIntValue ( "source" ) = = 4 | | client . getIntValue ( "source" ) = = 5 ) {
if ( client . getIntValue ( "source" ) = = 4 | | client . getIntValue ( "source" ) = = 5 ) {
List < JSONObject > accounts = clientAccountMapper . listAdminAccounts ( client . getIntValue ( "client_id" ) ) ;
List < JSONObject > accounts = clientAccountMapper . listAdminAccounts ( client . getIntValue ( "client_id" ) ) ;
JSONObject account = accounts . get ( 0 ) ;
JSONObject account = accounts . get ( 0 ) ;
sendInitEmail ( client , account . getString ( "username" ) , "*****" );
sendInitEmail ( client , account . getString ( "username" ) , "*****" , false );
// sendInitEmail(manager, client, account.getString("username"), "*****");
// sendInitEmail(manager, client, account.getString("username"), "*****");
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status , 5 , "合规通过" , manager );
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status , 5 , "合规通过" , manager ,1 );
clientModifySupport . processClientConfigModify ( new SwitchPermissionModify ( manager , clientMoniker , "skip_clearing" , false ) ) ;
clientModifySupport . processClientConfigModify ( new SwitchPermissionModify ( manager , clientMoniker , "skip_clearing" , false ) ) ;
clientModifySupport . processClientConfigModify ( new SwitchPermissionModify ( manager , clientMoniker , "common_sub_merchant_id" , false ) ) ;
clientModifySupport . processClientConfigModify ( new SwitchPermissionModify ( manager , clientMoniker , "common_sub_merchant_id" , false ) ) ;
gatewayMerchantApply . notifyOrgMerchantStatus ( client ) ;
gatewayMerchantApply . notifyOrgMerchantStatus ( client ) ;
} else if ( checkGreenChannel & & client . getIntValue ( "open_status" ) = = 5 ) {
} else if ( checkGreenChannel & & client . getIntValue ( "open_status" ) = = 5 ) {
// 绿色通道通过后不发邮件
// 绿色通道通过后不发邮件
logger . info ( "PASS 绿色通道:" + clientMoniker ) ;
logger . info ( "PASS 绿色通道:" + clientMoniker ) ;
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status , 5 , "合规通过" , manager );
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status , 5 , "合规通过" , manager ,1 );
} else {
} else {
initAdminUserAndSendEmail ( manager , clientMoniker , client );
initAdminUserAndSendEmail ( manager , clientMoniker , client , false );
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status , 5 , "合规通过" , manager );
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status , 5 , "合规通过" , manager ,1 );
}
}
}
}
clientInfoCacheSupport . clearClientCache ( client . getIntValue ( "client_id" ) ) ;
clientInfoCacheSupport . clearClientCache ( client . getIntValue ( "client_id" ) ) ;
}
}
@Override
public void auditCardClient ( JSONObject manager , String clientMoniker , int pass ) {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
}
//检查商户是否进入平台黑名单
int clientId = client . getIntValue ( "client_id" ) ;
isRiskyMerchant ( client , clientBankAccountMapper . clientBankAccounts ( clientId ) . get ( 0 ) ) ;
JSONObject cardFlowInfo = sysClientUpayProfileMapper . findInfo ( clientId ) ;
client . putAll ( clientConfigService . find ( client . getIntValue ( "client_id" ) ) ) ;
Integer open_status_to = cardFlowInfo ! = null ? cardFlowInfo . getIntValue ( "upay_open_status" ) : null ;
cardFlowInfo . put ( "upay_open_status" , 5 ) ;
cardFlowInfo . put ( "upay_approve_result" , 1 ) ;
sysClientUpayProfileMapper . update ( cardFlowInfo ) ;
sendCardCommissionWechatMessage ( client ) ; // wxMessage
if ( pass = = 1 ) {
createKycAuthStatus ( manager , client ) ;
clientModifySupport . processClientConfigModify ( new SwitchPermissionModify ( manager , clientMoniker , "skip_clearing" , false ) ) ;
List < JSONObject > accounts = clientAccountMapper . listAdminAccounts ( clientId ) ;
if ( accounts ! = null & & accounts . size ( ) > 0 ) {
sendInitEmail ( client , accounts . get ( 0 ) . getString ( "username" ) , "*******" , true ) ;
} else {
initAdminUserAndSendEmail ( manager , clientMoniker , client , true ) ;
}
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status_to , 5 , "合规通过" , manager , 2 ) ;
}
clientInfoCacheSupport . clearClientCache ( client . getIntValue ( "client_id" ) ) ;
}
private void createKycAuthStatus ( JSONObject manager , JSONObject client ) {
private void createKycAuthStatus ( JSONObject manager , JSONObject client ) {
JSONObject compliance = clientComplianceCompanyMapper . findKycFileByClientId ( client . getIntValue ( "client_id" ) ) ;
JSONObject compliance = clientComplianceCompanyMapper . findKycFileByClientId ( client . getIntValue ( "client_id" ) ) ;
if ( compliance ! = null ) {
if ( compliance ! = null ) {
@ -1240,15 +1287,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new BadRequestException ( "该商户未设置微信 Sub Merchant ID!" ) ;
throw new BadRequestException ( "该商户未设置微信 Sub Merchant ID!" ) ;
}
}
clientModifySupport . processClientModify ( new GreenChannelModify ( manager , clientMoniker , manager . getString ( "manager_id" ) ) ) ;
clientModifySupport . processClientModify ( new GreenChannelModify ( manager , clientMoniker , manager . getString ( "manager_id" ) ) ) ;
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , 10 , 1 , "绿色通道申请通过" , manager );
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , 10 , 1 , "绿色通道申请通过" , manager ,1 );
sendCommissionWechatMessage ( client ) ;
sendCommissionWechatMessage ( client ) ;
initAdminUserAndSendEmail ( manager , clientMoniker , client );
initAdminUserAndSendEmail ( manager , clientMoniker , client , false );
}
}
private void initAdminUserAndSendEmail ( JSONObject manager , String clientMoniker , JSONObject client ) {
private void initAdminUserAndSendEmail ( JSONObject manager , String clientMoniker , JSONObject client , boolean isUpayEmail ) {
if ( StringUtils . isEmpty ( client . getString ( "sub_merchant_id" ) ) ) {
throw new BadRequestException ( "Sub Merchant ID Can't be null " ) ;
}
String username = clientMoniker ;
String username = clientMoniker ;
boolean duplicated = true ;
boolean duplicated = true ;
String pwd = RandomStringUtils . random ( 8 , true , true ) ;
String pwd = RandomStringUtils . random ( 8 , true , true ) ;
@ -1265,7 +1309,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
username + = "0" ;
username + = "0" ;
}
}
}
}
sendInitEmail ( client , username . toLowerCase ( ) , pwd );
sendInitEmail ( client , username . toLowerCase ( ) , pwd , isUpayEmail );
// sendInitEmail(manager, client, username, pwd);
// sendInitEmail(manager, client, username, pwd);
}
}
@ -1291,16 +1335,16 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if ( client . getIntValue ( "source" ) = = 4 ) {
if ( client . getIntValue ( "source" ) = = 4 ) {
JSONObject account = accounts . get ( 0 ) ;
JSONObject account = accounts . get ( 0 ) ;
// sendInitEmail(manager, client, account.getString("username"), "*****");
// sendInitEmail(manager, client, account.getString("username"), "*****");
sendInitEmail ( client , account . getString ( "username" ) , "*****" );
sendInitEmail ( client , account . getString ( "username" ) , "*****" , false );
} else {
} else {
if ( accounts . size ( ) = = 0 ) {
if ( accounts . size ( ) = = 0 ) {
initAdminUserAndSendEmail ( manager , clientMoniker , client );
initAdminUserAndSendEmail ( manager , clientMoniker , client , false );
} else {
} else {
JSONObject account = accounts . get ( 0 ) ;
JSONObject account = accounts . get ( 0 ) ;
String pwd = RandomStringUtils . random ( 8 , true , true ) ;
String pwd = RandomStringUtils . random ( 8 , true , true ) ;
resetAccountPwd ( manager , clientMoniker , account . getString ( "account_id" ) , pwd ) ;
resetAccountPwd ( manager , clientMoniker , account . getString ( "account_id" ) , pwd ) ;
// sendInitEmail(manager, client, account.getString("username"), pwd);
// sendInitEmail(manager, client, account.getString("username"), pwd);
sendInitEmail ( client , account . getString ( "username" ) , pwd );
sendInitEmail ( client , account . getString ( "username" ) , pwd , false );
}
}
}
}
}
}
@ -1372,7 +1416,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} . start ( ) ;
} . start ( ) ;
}
}
public void sendInitEmail ( final JSONObject client , String username , String pwd ) {
public void sendInitEmail ( final JSONObject client , String username , String pwd ,boolean isUpayAuditPass ) {
logger . debug ( "sending email after comply" ) ;
logger . debug ( "sending email after comply" ) ;
JSONObject model = new JSONObject ( ) ;
JSONObject model = new JSONObject ( ) ;
model . put ( "username" , username ) ;
model . put ( "username" , username ) ;
@ -1422,16 +1466,30 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
mailService . sendEmail ( "Your RoyalPay Cross-border Payment has been set up" , emails . isEmpty ( ) ? "" : StringUtils . join ( emails , "," ) ,
mailService . sendEmail ( "Your RoyalPay Cross-border Payment has been set up" , emails . isEmpty ( ) ? "" : StringUtils . join ( emails , "," ) ,
"" , contentBd ) ;
"" , contentBd ) ;
JSONObject clientUpdate = new JSONObject ( ) ;
JSONObject clientUpdate = new JSONObject ( ) ;
if ( isUpayAuditPass ) {
clientUpdate . put ( "client_id" , client . getIntValue ( "client_id" ) ) ;
clientUpdate . put ( "upay_approve_email_send" , 3 ) ;
clientUpdate . put ( "upay_approve_email_id" , emailId ) ;
sysClientUpayProfileMapper . update ( clientUpdate ) ;
} else {
clientUpdate . put ( "client_id" , client . getIntValue ( "client_id" ) ) ;
clientUpdate . put ( "client_id" , client . getIntValue ( "client_id" ) ) ;
clientUpdate . put ( "approve_email_send" , 3 ) ;
clientUpdate . put ( "approve_email_send" , 3 ) ;
clientUpdate . put ( "approve_email_id" , emailId ) ;
clientUpdate . put ( "approve_email_id" , emailId ) ;
clientMapper . update ( clientUpdate ) ;
clientMapper . update ( clientUpdate ) ;
}
} catch ( Exception e ) {
} catch ( Exception e ) {
JSONObject clientUpdate = new JSONObject ( ) ;
JSONObject clientUpdate = new JSONObject ( ) ;
if ( isUpayAuditPass ) {
clientUpdate . put ( "client_id" , client . getIntValue ( "client_id" ) ) ;
clientUpdate . put ( "upay_approve_email_send" , 0 ) ;
clientUpdate . put ( "upay_approve_email_id" , null ) ;
sysClientUpayProfileMapper . update ( clientUpdate ) ;
} else {
clientUpdate . put ( "client_id" , client . getIntValue ( "client_id" ) ) ;
clientUpdate . put ( "client_id" , client . getIntValue ( "client_id" ) ) ;
clientUpdate . put ( "approve_email_send" , 0 ) ;
clientUpdate . put ( "approve_email_send" , 0 ) ;
clientUpdate . put ( "approve_email_id" , null ) ;
clientUpdate . put ( "approve_email_id" , null ) ;
clientMapper . update ( clientUpdate ) ;
clientMapper . update ( clientUpdate ) ;
}
throw new EmailException ( "Email Sending Failed" , e ) ;
throw new EmailException ( "Email Sending Failed" , e ) ;
}
}
}
}
@ -1605,7 +1663,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if ( client = = null ) {
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
throw new InvalidShortIdException ( ) ;
}
}
clientModifySupport . processClientConfigModify ( new SwitchPermissionModify ( manager , clientMoniker , permissionKey , allow ) ) ;
JSONObject upayProfileInfo = sysClientUpayProfileMapper . findInfo ( client . getInteger ( "client_id" ) ) ;
upayProfileInfo . put ( permissionKey , allow ) ;
sysClientUpayProfileMapper . update ( upayProfileInfo ) ;
}
}
@Override
@Override
@ -2094,6 +2154,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
configJson . put ( "manager_id" , manager . getString ( "manager_id" ) ) ;
configJson . put ( "manager_id" , manager . getString ( "manager_id" ) ) ;
configJson . put ( "manager_name" , manager . getString ( "username" ) ) ;
configJson . put ( "manager_name" , manager . getString ( "username" ) ) ;
configJson . put ( "update_time" , new Date ( ) ) ;
configJson . put ( "update_time" , new Date ( ) ) ;
if ( StringUtils . equalsIgnoreCase ( "rpaypmt_card" , config . getRateName ( ) ) ) {
JSONObject extParams = configJson . getJSONObject ( "ext_rates" ) ;
extParams . put ( "domestic_rate_value" , config . getRateValue ( ) ) ;
configJson . put ( "ext_rates" , extParams . toJSONString ( ) ) ;
}
clientRateMapper . updateConfig ( configJson ) ;
clientRateMapper . updateConfig ( configJson ) ;
// if ("Rpay".equals(configJson.getString("rate_name"))) {
// if ("Rpay".equals(configJson.getString("rate_name"))) {
// rpayApi.modifySurchargeConfig(client);
// rpayApi.modifySurchargeConfig(client);
@ -3120,6 +3185,35 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
}
}
@Override
@Transactional
public void getAggregateCardAgreeFile ( String clientMoniker , JSONObject manager , boolean renewal ) {
JSONObject client = clientMapper . findClientByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
}
exportLetterOfferPDF ( clientMoniker , manager ) ;
exportTermsConditionsPDF ( clientMoniker , manager ) ;
if ( ! renewal ) {
JSONObject cardFlow = sysClientUpayProfileMapper . findInfo ( client . getInteger ( "client_id" ) ) ;
cardFlow . put ( "upay_open_status" , 2 ) ;
sysClientUpayProfileMapper . update ( cardFlow ) ;
}
if ( manager ! = null ) {
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , 1 , 2 , "Compliance合同制作中" , manager , 2 ) ;
}
}
@Override
@Transactional
public void getAggregateCardPromotionaAgreeFile ( String clientMoniker , JSONObject manager , boolean renewal , String promotionalEffectiveDate , int promotionalPeriod ) throws ParseException {
JSONObject client = clientMapper . findClientByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
}
exportPromotionalOfferPDF ( clientMoniker , manager , promotionalEffectiveDate , promotionalPeriod ) ;
}
@Override
@Override
public void getNewAggregateAgreeFile ( String clientMoniker , JSONObject manager , boolean renewal ) throws Exception {
public void getNewAggregateAgreeFile ( String clientMoniker , JSONObject manager , boolean renewal ) throws Exception {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
@ -3317,7 +3411,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
if ( manager ! = null ) {
if ( manager ! = null ) {
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , 1 , 2 , "Compliance合同制作中" , manager );
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , 1 , 2 , "Compliance合同制作中" , manager ,1 );
}
}
}
}
}
}
@ -3334,11 +3428,29 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
client . put ( "open_status" , 3 ) ;
client . put ( "open_status" , 3 ) ;
clientModifySupport . processClientModify ( new OpenStatusModify ( manager , clientMoniker , 3 ) ) ;
clientModifySupport . processClientModify ( new OpenStatusModify ( manager , clientMoniker , 3 ) ) ;
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , 2 , 3 , "合同制作完成, 等待BD处理" , manager );
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , 2 , 3 , "合同制作完成, 等待BD处理" , manager ,1 );
// sendAgreeFileMsgToBD(client,null);
// sendAgreeFileMsgToBD(client,null);
sendCommissionWechatMessage ( client ) ;
sendCommissionWechatMessage ( client ) ;
}
}
@Override
public void cardCompleteAgree ( String clientMoniker , JSONObject manager ) {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
}
List < JSONObject > existLeffterFiles = clientFilesMapper . findFileByClientAndType ( client . getIntValue ( "client_id" ) , LETTER_OF_OFFER_FILE ) ;
List < JSONObject > existConditionsFiles = clientFilesMapper . findFileByClientAndType ( client . getIntValue ( "client_id" ) , TERMS_AND_CONDITIONS_FILE ) ;
if ( CollectionUtils . isEmpty ( existLeffterFiles ) & & CollectionUtils . isEmpty ( existConditionsFiles ) ) {
throw new BadRequestException ( "The Agree File is not Complete!" ) ;
}
JSONObject cardFlowInfo = sysClientUpayProfileMapper . findInfo ( client . getInteger ( "client_id" ) ) ;
cardFlowInfo . put ( "upay_open_status" , 3 ) ;
sysClientUpayProfileMapper . update ( cardFlowInfo ) ;
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , 2 , 3 , "合同制作完成, 等待BD处理" , manager , 2 ) ;
sendCardCommissionWechatMessage ( client ) ;
}
@Override
@Override
public void downloadComplianceZip ( String clientMoniker , HttpServletResponse response ) throws Exception {
public void downloadComplianceZip ( String clientMoniker , HttpServletResponse response ) throws Exception {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
@ -3385,7 +3497,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if ( client = = null ) {
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
throw new InvalidShortIdException ( ) ;
}
}
List < JSONObject > files = clientMWAuthFilesInfo . findClientFile ( client . getIntValue ( "client_id" ) );
List < JSONObject > files = clientMWAuthFilesInfo . findClientFile ( client . getIntValue ( "client_id" ) , new PageBounds ( 1 , 999999 , Order . formString ( "last_update_date.asc" ) ) );
if ( files ! = null & & files . size ( ) > 0 ) {
if ( files ! = null & & files . size ( ) > 0 ) {
List < String > filePaths = new ArrayList < > ( ) ;
List < String > filePaths = new ArrayList < > ( ) ;
for ( JSONObject file : files ) {
for ( JSONObject file : files ) {
@ -3591,7 +3703,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
int clientId = client . getIntValue ( "client_id" ) ;
int clientId = client . getIntValue ( "client_id" ) ;
params . put ( "client_id" , client . getIntValue ( "client_id" ) ) ;
params . put ( "client_id" , client . getIntValue ( "client_id" ) ) ;
clientConfigMapper . update ( params ) ;
JSONObject upayInfo = sysClientUpayProfileMapper . findInfo ( clientId ) ;
if ( upayInfo = = null ) {
sysClientUpayProfileMapper . save ( params ) ;
} else {
sysClientUpayProfileMapper . update ( params ) ;
}
}
}
@Override
@Override
@ -3669,6 +3786,19 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
return sourceFile ;
return sourceFile ;
}
}
@Override
public JSONObject getSourceCardAgreeFiles ( String clientMoniker , JSONObject manager , String fileName ) {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
}
JSONObject sourceFile = clientFilesMapper . getSourceCardAgreeFilesByClientId ( client . getIntValue ( "client_id" ) , fileName ) ;
if ( sourceFile ! = null ) {
sourceFile . put ( sourceFile . getString ( "file_name" ) , sourceFile . getString ( "file_value" ) ) ;
}
return sourceFile ;
}
@Override
@Override
public JSONObject getAllAuthFiles ( JSONObject manager , String clientMoniker ) {
public JSONObject getAllAuthFiles ( JSONObject manager , String clientMoniker ) {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
@ -3709,7 +3839,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if ( client = = null ) {
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
throw new InvalidShortIdException ( ) ;
}
}
List < JSONObject > clientFiles = clientMWAuthFilesInfo . findClientFile ( client . getIntValue ( "client_id" ) );
List < JSONObject > clientFiles = clientMWAuthFilesInfo . findClientFile ( client . getIntValue ( "client_id" ) , new PageBounds ( 1 , 999999 , Order . formString ( "last_update_date.asc" ) ) );
JSONObject fileJson = new JSONObject ( ) ;
JSONObject fileJson = new JSONObject ( ) ;
for ( JSONObject file : clientFiles ) {
for ( JSONObject file : clientFiles ) {
fileJson . put ( file . getString ( "file_name" ) , file . getString ( "file_value" ) ) ;
fileJson . put ( file . getString ( "file_name" ) , file . getString ( "file_value" ) ) ;
@ -3867,11 +3997,18 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
int clientId = client . getIntValue ( "client_id" ) ;
int clientId = client . getIntValue ( "client_id" ) ;
try {
try {
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . UPAY_APPLICATION_FORM . getFileName ( ) , filesInfo . getUpay_application_form ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . CLIENT_BANK_FILE . getFileName ( ) , filesInfo . getClient_bank_file ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . UPAY_AGREEMENT_FILE . getFileName ( ) , filesInfo . getUpay_agreement_file ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . CLIENT_COMPANY_FILE . getFileName ( ) , filesInfo . getClient_company_file ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . UPAY_OFFER_LETTER . getFileName ( ) , filesInfo . getUpay_offer_letter ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . UPAY_DRIVER_LICENSE . getFileName ( ) , filesInfo . getUpay_driver_license ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . UPAY_DRIVER_LICENSE . getFileName ( ) , filesInfo . getUpay_driver_license ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . UPAY_RESIDENCE_CERTIFICATE . getFileName ( ) , filesInfo . getUpay_residence_certificate ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . REFUND_EXCHANGE_POLICY . getFileName ( ) , filesInfo . getRefund_exchange_policy ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . UPAY_PRIVACY_POLICY . getFileName ( ) , filesInfo . getUpay_privacy_policy ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . CARD_SECURITY_POLICY . getFileName ( ) , filesInfo . getCard_security_policy ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . UPAY_OFFER_LETTER . getFileName ( ) , filesInfo . getUpay_offer_letter ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . UPAY_PROMOTIONAL_OFFER . getFileName ( ) , filesInfo . getUpay_promotional_offer ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . UPAY_TERMS_CONDITIONS . getFileName ( ) , filesInfo . getUpay_terms_conditions ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . KYC_UTILITY_BILL_FILE . getFileName ( ) , filesInfo . getKyc_utility_bill_file ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . UPAY_APPLICATION_FORM . getFileName ( ) , filesInfo . getUpay_application_form ( ) ) ;
updateSysMWClientFiles ( manager , clientId , UPayAuthFileEnum . UPAY_DESC_FILE . getFileName ( ) , filesInfo . getUpay_desc_file ( ) ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
logger . error ( "上传合规文件失败" , e ) ;
logger . error ( "上传合规文件失败" , e ) ;
}
}
@ -3955,7 +4092,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
@Override
@Override
@Transactional
@Transactional
public void commitAuthFilesToCompliance ( String clientMoniker , JSONObject account , String source ) {
public void commitAuthFilesToCompliance ( String clientMoniker , JSONObject account , String source ) {
@ -4534,14 +4670,53 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
client . put ( "open_status" , 4 ) ;
client . put ( "open_status" , 4 ) ;
clientModifySupport . processClientModify ( openStatusModify ) ;
clientModifySupport . processClientModify ( openStatusModify ) ;
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status_from , 4 , "BD完成签字提交compliance审核" , manager );
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status_from , 4 , "BD完成签字提交compliance审核" , manager ,1 );
if ( manager ! = null ) {
if ( manager ! = null ) {
// sendMessagetoCompliance(client, manager.getString("display_name"));
// sendMessagetoCompliance(client, manager.getString("display_name"));
sendCommissionWechatMessage ( client ) ;
sendCommissionWechatMessage ( client ) ;
}
}
}
}
private void saveClientAuditProcess ( int client_id , Integer open_status_form , Integer open_status_to , String remark , JSONObject manager ) {
@Override
@Transactional
public void commitToCardCompliance ( String clientMoniker , JSONObject manager ) {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
}
client . putAll ( clientConfigService . find ( client . getIntValue ( "client_id" ) ) ) ;
if ( manager ! = null & & ManagerRole . BD_USER . hasRole ( manager . getIntValue ( "role" ) ) ) {
int bdOperatClientRole = clientBDMapper . checkBDPermission ( client . getIntValue ( "client_id" ) , manager . getString ( "manager_id" ) ) ;
if ( bdOperatClientRole < = 0 ) {
throw new ForbiddenException ( ) ;
}
}
// 提交合规启用银行、费率验证 add by Tayl0r 2017/06/13
JSONObject rate = merchantInfoProvider . clientCurrentRate ( client . getIntValue ( "client_id" ) , new Date ( ) , "rpaypmt_card" ) ;
if ( rate = = null ) {
throw new BadRequestException ( "The Partner's Rate is not config!" ) ;
}
List < JSONObject > clientFiles = clientFilesMapper . findClientFile ( client . getIntValue ( "client_id" ) ) ;
if ( clientFiles = = null | | clientFiles . equals ( "" ) ) {
throw new BadRequestException ( "The Compliance File Must Be Uploaded!" ) ;
}
JSONObject account = getBankAccountByClientId ( client . getIntValue ( "client_id" ) ) ;
if ( account = = null ) {
throw new BadRequestException ( "The Partner's Bank Account is not config!" ) ;
}
JSONObject cardFlowInfo = sysClientUpayProfileMapper . findInfo ( client . getInteger ( "client_id" ) ) ;
int open_status_from = cardFlowInfo . getIntValue ( "upay_open_status" ) ;
cardFlowInfo . put ( "upay_approve_time" , new Date ( ) ) ;
cardFlowInfo . put ( "upay_approve_result" , 4 ) ;
cardFlowInfo . put ( "upay_open_status" , 4 ) ;
sysClientUpayProfileMapper . update ( cardFlowInfo ) ;
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status_from , 4 , "BD完成签字提交compliance审核" , manager , 2 ) ;
if ( manager ! = null ) {
sendCardCommissionWechatMessage ( client ) ;
}
}
private void saveClientAuditProcess ( int client_id , Integer open_status_form , Integer open_status_to , String remark , JSONObject manager , int type ) {
JSONObject log = new JSONObject ( ) ;
JSONObject log = new JSONObject ( ) ;
try {
try {
log . put ( "client_id" , client_id ) ;
log . put ( "client_id" , client_id ) ;
@ -4552,6 +4727,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
log . put ( "operator_id" , StringUtils . isNotEmpty ( manager . getString ( "manager_id" ) ) ? manager . getString ( "manager_id" ) : manager . getString ( "account_id" ) ) ;
log . put ( "operator_id" , StringUtils . isNotEmpty ( manager . getString ( "manager_id" ) ) ? manager . getString ( "manager_id" ) : manager . getString ( "account_id" ) ) ;
log . put ( "operator" , manager . getString ( "display_name" ) ) ;
log . put ( "operator" , manager . getString ( "display_name" ) ) ;
log . put ( "create_time" , new Date ( ) ) ;
log . put ( "create_time" , new Date ( ) ) ;
log . put ( "type" , type ) ;
log . put ( "remark" , remark ) ;
log . put ( "remark" , remark ) ;
clientAuditProcessMapper . save ( log ) ;
clientAuditProcessMapper . save ( log ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -4567,6 +4743,48 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException ( ) ;
throw new InvalidShortIdException ( ) ;
}
}
client . putAll ( clientConfigService . find ( client . getIntValue ( "client_id" ) ) ) ;
client . putAll ( clientConfigService . find ( client . getIntValue ( "client_id" ) ) ) ;
beforeCommitToDoAgreeValid ( client , manager , "Wechat" ) ;
OpenStatusModify openStatusModify = new OpenStatusModify ( manager , clientMoniker , 1 ) ;
openStatusModify . setApprove_result ( 4 ) ;
openStatusModify . setApprove_time ( new Date ( ) ) ;
clientModifySupport . processClientModify ( openStatusModify ) ;
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , null , 1 , "提交Card Payment Compliance制作合同" , manager , 1 ) ;
if ( manager ! = null ) {
// sendAgreeFileMsgtoCompliance(client, manager.getString("display_name"));
sendCommissionWechatMessage ( client ) ;
}
}
@Override
@Transactional
public void commitToDoCardAgreeFile ( String clientMoniker , JSONObject manager ) {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
}
int clientId = client . getIntValue ( "client_id" ) ;
client . putAll ( clientConfigService . find ( clientId ) ) ;
beforeCommitToDoAgreeValid ( client , manager , "rpaypmt_card" ) ;
JSONObject surCharge = merchantInfoProvider . clientCurrentRate ( client . getIntValue ( "client_id" ) , new Date ( ) , "rpaypmt_card" ) ;
if ( surCharge = = null | | surCharge . size ( ) < = 0 ) {
throw new BadRequestException ( "The Partner's Rpaypmt Card Rate is not config!" ) ;
}
JSONObject cardFlowInfo = sysClientUpayProfileMapper . findInfo ( clientId ) ;
JSONObject cardFlow = new JSONObject ( ) { {
put ( "client_id" , clientId ) ;
put ( "upay_approve_result" , 4 ) ;
put ( "upay_open_status" , 1 ) ;
put ( "upay_approve_time" , new Date ( ) ) ;
} } ;
sysClientUpayProfileMapper . update ( cardFlow ) ;
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , null , 1 , "提交Compliance制作合同" , manager , 2 ) ;
}
private void beforeCommitToDoAgreeValid ( JSONObject client , JSONObject manager , String channel ) {
if ( manager ! = null & & ManagerRole . BD_USER . hasRole ( manager . getIntValue ( "role" ) ) ) {
if ( manager ! = null & & ManagerRole . BD_USER . hasRole ( manager . getIntValue ( "role" ) ) ) {
int bdOperatClientRole = clientBDMapper . checkBDPermission ( client . getIntValue ( "client_id" ) , manager . getString ( "manager_id" ) ) ;
int bdOperatClientRole = clientBDMapper . checkBDPermission ( client . getIntValue ( "client_id" ) , manager . getString ( "manager_id" ) ) ;
if ( bdOperatClientRole < = 0 ) {
if ( bdOperatClientRole < = 0 ) {
@ -4574,7 +4792,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
}
}
JSONObject surCharge = merchantInfoProvider . clientCurrentRate ( client . getIntValue ( "client_id" ) , new Date ( ) , "Wechat" ) ;
JSONObject surCharge = merchantInfoProvider . clientCurrentRate ( client . getIntValue ( "client_id" ) , new Date ( ) , channel ) ;
if ( surCharge = = null | | surCharge . size ( ) < = 0 ) {
if ( surCharge = = null | | surCharge . size ( ) < = 0 ) {
throw new BadRequestException ( "The Partner's Rate is not config!" ) ;
throw new BadRequestException ( "The Partner's Rate is not config!" ) ;
}
}
@ -4583,15 +4801,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if ( account = = null | | account . size ( ) < = 0 ) {
if ( account = = null | | account . size ( ) < = 0 ) {
throw new BadRequestException ( "The Partner's Bank Account is not config!" ) ;
throw new BadRequestException ( "The Partner's Bank Account is not config!" ) ;
}
}
OpenStatusModify openStatusModify = new OpenStatusModify ( manager , clientMoniker , 1 ) ;
openStatusModify . setApprove_result ( 4 ) ;
openStatusModify . setApprove_time ( new Date ( ) ) ;
clientModifySupport . processClientModify ( openStatusModify ) ;
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , null , 1 , "提交Compliance制作合同" , manager ) ;
if ( manager ! = null ) {
// sendAgreeFileMsgtoCompliance(client, manager.getString("display_name"));
sendCommissionWechatMessage ( client ) ;
}
}
}
@Override
@Override
@ -4623,7 +4832,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
openStatusModify . setApprove_result ( 4 ) ;
openStatusModify . setApprove_result ( 4 ) ;
openStatusModify . setApprove_time ( new Date ( ) ) ;
openStatusModify . setApprove_time ( new Date ( ) ) ;
clientModifySupport . processClientModify ( openStatusModify ) ;
clientModifySupport . processClientModify ( openStatusModify ) ;
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status_from , 10 , "提交绿色通道申请Compliance审核" , manager );
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status_from , 10 , "提交绿色通道申请Compliance审核" , manager ,1 );
if ( manager ! = null ) {
if ( manager ! = null ) {
// sendGreenChannelMessagetoCompliance(client, manager.getString("display_name"));
// sendGreenChannelMessagetoCompliance(client, manager.getString("display_name"));
sendCommissionWechatMessage ( client ) ;
sendCommissionWechatMessage ( client ) ;
@ -4913,7 +5122,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if ( refuse_remark ! = null & & ! refuse_remark . isEmpty ( ) ) {
if ( refuse_remark ! = null & & ! refuse_remark . isEmpty ( ) ) {
auditModify . setRefuse_remark ( refuse_remark ) ;
auditModify . setRefuse_remark ( refuse_remark ) ;
}
}
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status , client . getInteger ( "open_status" ) , "打回," + refuse_remark , manager );
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status , client . getInteger ( "open_status" ) , "打回," + refuse_remark , manager ,1 );
clientModifySupport . processClientModify ( auditModify ) ;
clientModifySupport . processClientModify ( auditModify ) ;
try {
try {
@ -4938,6 +5147,55 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
}
}
@Override
public void cardRefusePartner ( String clientMoniker , JSONObject manager , String refuse_remark ) {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
}
Integer clientId = client . getInteger ( "client_id" ) ;
JSONObject cardFlowInfo = sysClientUpayProfileMapper . findInfo ( clientId ) ;
Integer open_status = null ;
if ( null ! = cardFlowInfo ) {
open_status = cardFlowInfo . getIntValue ( "upay_open_status" ) ;
if ( open_status = = 1 ) {
cardFlowInfo . put ( "upay_open_status" , null ) ;
} else {
cardFlowInfo . put ( "upay_open_status" , open_status - 1 ) ;
}
if ( cardFlowInfo . getIntValue ( "upay_approve_result" ) = = 4 | | client . getIntValue ( "source" ) = = 4 ) {
cardFlowInfo . put ( "upay_approve_result" , 5 ) ;
}
if ( refuse_remark ! = null & & ! refuse_remark . isEmpty ( ) ) {
cardFlowInfo . put ( "upay_refuse_remark" , refuse_remark ) ;
}
} else {
cardFlowInfo . put ( "upay_open_status" , null ) ;
}
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status , cardFlowInfo . getIntValue ( "open_status" ) , "打回," + refuse_remark , manager , 2 ) ;
sysClientUpayProfileMapper . update ( cardFlowInfo ) ;
try {
if ( client . getIntValue ( "source" ) = = 4 ) {
String contact_phone = client . getString ( "contact_phone" ) ;
if ( contact_phone . startsWith ( "+61" ) ) {
ArrayList < String > param = new ArrayList < > ( ) ;
param . add ( refuse_remark ) ;
try {
smsSender . getSender ( ) . sendWithParam ( "61" , contact_phone . replace ( "+61" , "" ) , REFUSE_CLIENT_TEMPLID , param , "RoyalPay" , "" , "" ) ;
} catch ( Exception ignore ) {
throw new ServerErrorException ( "Phone number is wrong :" + contact_phone ) ;
}
}
}
if ( client . getIntValue ( "source" ) = = 5 ) {
gatewayMerchantApply . notifyOrgMerchantStatus ( client ) ;
}
} catch ( Exception e ) {
logger . error ( "RefusePartnerError=======:" + clientMoniker + "," + e . getMessage ( ) ) ;
}
}
@Override
@Override
@Cacheable ( value = ":all_clients:" , key = "''+#clientId" )
@Cacheable ( value = ":all_clients:" , key = "''+#clientId" )
public JSONArray getAllClientIds ( int clientId ) {
public JSONArray getAllClientIds ( int clientId ) {
@ -5455,6 +5713,94 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
private void sendCardCommissionWechatMessage ( JSONObject client ) {
String bd_user_name = client . getString ( "bd_user_name" ) ;
String client_moniker = "[" + client . getString ( "client_moniker" ) + "]" ;
String short_name = client . getString ( "short_name" ) ;
JSONObject cardFlowInfo = sysClientUpayProfileMapper . findInfo ( client . getInteger ( "client_id" ) ) ;
if ( null = = cardFlowInfo ) {
return ;
}
if ( cardFlowInfo . getIntValue ( "upay_open_status" ) = = 1 ) {
List < JSONObject > complianceList = managerMapper . getOnlyCompliance ( ) ;
if ( complianceList ! = null & & complianceList . size ( ) > 0 ) {
for ( JSONObject compliance : complianceList ) {
String wxopenid = compliance . getString ( "wx_openid" ) ;
try {
MpWechatApi paymentApi = mpWechatApiProvider . getNewPaymentApi ( ) ;
TemplateMessage msg = initSendCommissionTemplate ( wxopenid , paymentApi . getTemplateId ( "commission" ) , "BD申请制作信用卡支付合同" + client_moniker ,
bd_user_name , "制作卡支付合同申请" , "BD申请制作" + short_name + "的卡支付合同" ) ;
paymentApi . sendTemplateMessage ( msg ) ;
} catch ( WechatException e ) {
logger . error ( "Wechat Message Error,open_status=1" + e . getMessage ( ) ) ;
publisher . publishEvent ( new WechatExceptionEvent ( this , e , "Audit,open_status=1,openid=" + wxopenid ) ) ;
}
}
}
return ;
}
if ( cardFlowInfo . getIntValue ( "upay_open_status" ) = = 3 ) {
List < JSONObject > bds = clientBDMapper . listClientBDInfoAvailable ( client . getIntValue ( "client_id" ) , new Date ( ) ) ;
for ( JSONObject bd : bds ) {
String wxopenid = bd . getString ( "wx_openid" ) ;
if ( wxopenid ! = null ) {
try {
MpWechatApi paymentApi = mpWechatApiProvider . getNewPaymentApi ( ) ;
TemplateMessage msg = initSendCommissionTemplate ( wxopenid , paymentApi . getTemplateId ( "commission" ) , client_moniker + "信用卡支付合同制作完成" ,
"Compliance" , "合规材料" , "上传完整合规材料,商户:" + short_name ) ;
paymentApi . sendTemplateMessage ( msg ) ;
} catch ( WechatException e ) {
logger . error ( "Wechat Message Error,open_status=3" + e . getMessage ( ) ) ;
publisher . publishEvent ( new WechatExceptionEvent ( this , e , "Audit,open_status=3,openid=" + wxopenid ) ) ;
}
}
}
return ;
}
if ( cardFlowInfo . getIntValue ( "upay_open_status" ) = = 4 ) {
if ( client . getIntValue ( "source" ) = = 4 & & ! StringUtils . isNotEmpty ( bd_user_name ) ) {
bd_user_name = "自助开通商户" ;
}
List < JSONObject > complianceList = managerMapper . getOnlyCompliance ( ) ;
if ( complianceList ! = null & & complianceList . size ( ) > 0 ) {
for ( JSONObject compliance : complianceList ) {
String wxopenid = compliance . getString ( "wx_openid" ) ;
try {
MpWechatApi paymentApi = mpWechatApiProvider . getNewPaymentApi ( ) ;
TemplateMessage msg = initSendCommissionTemplate ( wxopenid , paymentApi . getTemplateId ( "commission" ) , client_moniker + "信用卡卡支付合规材料已提交" ,
bd_user_name , "审核材料" , "已提交合规材料,等待审核" ) ;
paymentApi . sendTemplateMessage ( msg ) ;
} catch ( WechatException e ) {
logger . error ( "Wechat Message Error,open_status=1" + e . getMessage ( ) ) ;
publisher . publishEvent ( new WechatExceptionEvent ( this , e , "Audit,open_status=1,openid=" + wxopenid ) ) ;
} catch ( Exception e ) {
logger . error ( "Wechat Message Error,open_status=1" + e . getMessage ( ) ) ;
}
}
}
return ;
}
if ( cardFlowInfo . getIntValue ( "upay_open_status" ) = = 5 ) {
List < JSONObject > bds = clientBDMapper . listClientBDInfoAvailable ( client . getIntValue ( "client_id" ) , new Date ( ) ) ;
for ( JSONObject bd : bds ) {
String wxopenid = bd . getString ( "wx_openid" ) ;
if ( wxopenid ! = null ) {
try {
TemplateMessage msg = initTaskFinishTemplate ( wxopenid , client_moniker + "已正式开通" , "Card Payment Compliance审核通过" , "" ) ;
MpWechatApi paymentApi = mpWechatApiProvider . getNewPaymentApi ( ) ;
paymentApi . sendTemplateMessage ( msg ) ;
} catch ( WechatException e ) {
logger . error ( "Wechat Message Error,open_status=5" + e . getMessage ( ) ) ;
publisher . publishEvent ( new WechatExceptionEvent ( this , e , "Audit,open_status=5,openid=" + wxopenid ) ) ;
}
}
}
return ;
}
}
@Override
@Override
@Cacheable ( value = ":all_sub_merchant_id_applices:" , key = "#clientMoniker" )
@Cacheable ( value = ":all_sub_merchant_id_applices:" , key = "#clientMoniker" )
public List < JSONObject > listSubMerchantIdApplys ( JSONObject manager , String clientMoniker ) {
public List < JSONObject > listSubMerchantIdApplys ( JSONObject manager , String clientMoniker ) {
@ -6061,7 +6407,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
client . put ( "open_status" , 4 ) ;
client . put ( "open_status" , 4 ) ;
clientModifySupport . processClientModify ( openStatusModify ) ;
clientModifySupport . processClientModify ( openStatusModify ) ;
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status_from , 4 , "自助开通商户提交compliance审核" , client_account );
saveClientAuditProcess ( client . getIntValue ( "client_id" ) , open_status_from , 4 , "自助开通商户提交compliance审核" , client_account ,1 );
if ( params ! = null ) {
if ( params ! = null ) {
params . put ( "display_name" , client_account . getString ( "display_name" ) ) ;
params . put ( "display_name" , client_account . getString ( "display_name" ) ) ;
@ -6993,4 +7339,195 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientInfoCacheSupport . clearClientCache ( client . getIntValue ( "client_id" ) ) ;
clientInfoCacheSupport . clearClientCache ( client . getIntValue ( "client_id" ) ) ;
}
}
private void exportLetterOfferPDF ( String clientMoniker , JSONObject manage ) {
JSONObject info = convertClientLetterOfferInfo ( clientMoniker ) ;
String pdfPath = this . getClass ( ) . getClassLoader ( ) . getResource ( "" ) . getPath ( ) + "/templates/pdf/letter_of_offer.pdf" ;
String fileName = clientMoniker + "_Letter_of_Offer.pdf" ;
publishExcelCardPDFFile ( clientMoniker , manage , fileName , pdfPath , info , LETTER_OF_OFFER_FILE ) ;
}
private JSONObject convertClientLetterOfferInfo ( String clientMoniker ) {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
}
//合规状态
if ( client . getIntValue ( "approve_result" ) ! = 1 & & client . getIntValue ( "approve_result" ) = = 3 ) {
throw new BadRequestException ( "The merchant failed the audit!" ) ;
}
//获取数据源
int clientId = client . getInteger ( "client_id" ) ;
JSONObject clientRate = merchantInfoProvider . clientCurrentRate ( clientId , new Date ( ) , "rpaypmt_card" ) ;
if ( clientRate = = null ) {
throw new BadRequestException ( "rpaypmt_card rate Not configured" ) ;
}
JSONObject cardRate = clientRate . getJSONObject ( "ext_rates" ) ;
JSONObject bankAccountInfo = clientBankAccountMapper . clientBankAccounts ( clientId ) . get ( 0 ) ;
JSONObject upayProfileInfo = sysClientUpayProfileMapper . findInfo ( clientId ) ;
JSONObject legalInfo = sysClientLegalPersonMapper . findRepresentativeInfo ( clientId ) ;
//装在数据
JSONObject info = new JSONObject ( ) ;
info . put ( "down_date" , convertDateEnglish ( new Date ( ) ) ) ; //下载文件日期
info . put ( "bussiness_name" , ( client . containsKey ( "business_name" ) ? client . getString ( "business_name" ) : legalInfo . getString ( "representative_person" ) ) + " " + client . getString ( "abn" ) ) ; //商圈类型
info . put ( "partner_address" , client . getString ( "address" ) ) ; //商家店铺地址
info . put ( "partner_country" , client . getString ( "country" ) ) ; //国家
info . put ( "partner_state" , client . getString ( "state" ) ) ; //洲
info . put ( "partner_bussiness_name" , client . getString ( "business_name" ) ) ; //商户商用名称
info . put ( "clean_days" , client . getInteger ( "clean_days" ) ) ; //T+规则清算天数
info . put ( "partner_industry_mcc" , upayProfileInfo . getString ( "mw_industry" ) ) ; //信用卡注册商户行业编码
info . put ( "legal_bussiness" , legalInfo . getString ( "representative_person" ) + " AS " + ( client . containsKey ( "business_name" ) ? client . getString ( "business_name" ) : legalInfo . getString ( "representative_person" ) ) + " ABN " + client . getString ( "abn" ) ) ; //拼接规则:法人名 AS 商用名称 ABD 编码
info . put ( "annual_rate" , cardAnnualRate ) ; //年费率
info . put ( "cost_per_transaction" , clientRate . getString ( "transaction_fee" ) ) ; //每次交易成本
info . put ( "domestic_fee" , cardRate . getString ( "domestic_rate_value" ) ) ; //国内服务费
info . put ( "international_fee" , cardRate . getString ( "overseas_rate_value" ) ) ; //国际服务费
BigDecimal reserve = ( upayProfileInfo . getBigDecimal ( "expected_card_revenue" ) . multiply ( new BigDecimal ( 0.005 ) ) . setScale ( 0 , RoundingMode . HALF_UP ) ) ;
info . put ( "account_reserve" , reserve . compareTo ( new BigDecimal ( 200 ) ) < = 0 ? new BigDecimal ( 200 ) . toPlainString ( ) : reserve . toPlainString ( ) ) ; //账户储备金
//银行账号信息
info . put ( "account_name" , bankAccountInfo . getString ( "account_name" ) ) ; //
info . put ( "bsb" , bankAccountInfo . getString ( "bsb_no" ) ) ;
info . put ( "account_no" , bankAccountInfo . getString ( "account_no" ) ) ;
info . put ( "card_acceptor_name" , upayProfileInfo . getString ( "acceptor_name" ) ) ;
return info ;
}
private void exportPromotionalOfferPDF ( String clientMoniker , JSONObject manager , String promotionalEffectiveDate , int promotionalPeriod ) throws ParseException {
Date date = DateUtils . parseDate ( promotionalEffectiveDate , "yyyy-MM-dd" ) ;
JSONObject info = convertPromotionalOfferInfo ( clientMoniker , convertDateEnglish ( date ) , promotionalPeriod ) ;
String pdfPath = this . getClass ( ) . getClassLoader ( ) . getResource ( "" ) . getPath ( ) + "/templates/pdf/promotional_offer.pdf" ;
String fileName = clientMoniker + "_Promotional_Offer.pdf" ;
publishExcelCardPDFFile ( clientMoniker , manager , fileName , pdfPath , info , PROMOTIONAL_OFFER_FILE ) ;
}
private JSONObject convertPromotionalOfferInfo ( String clientMoniker , String promotionalEffectiveDate , int promotionalPeriod ) {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
}
//合规状态
if ( client . getIntValue ( "approve_result" ) ! = 1 & & client . getIntValue ( "approve_result" ) = = 3 ) {
throw new BadRequestException ( "The merchant failed the audit!" ) ;
}
int clientId = client . getInteger ( "client_id" ) ;
JSONObject clientRate = merchantInfoProvider . clientCurrentRate ( clientId , new Date ( ) , "rpaypmt_card" ) ;
if ( clientRate = = null ) {
throw new BadRequestException ( "rpaypmt_card rate Not configured" ) ;
}
JSONObject cardRate = clientRate . getJSONObject ( "ext_rates" ) ;
JSONObject legalInfo = sysClientLegalPersonMapper . findRepresentativeInfo ( clientId ) ;
JSONObject info = new JSONObject ( ) ;
info . put ( "down_date" , convertDateEnglish ( new Date ( ) ) ) ; //下载文件日期
info . put ( "bussiness_name" , ( client . containsKey ( "business_name" ) ? client . getString ( "business_name" ) : legalInfo . getString ( "representative_person" ) ) + " " + client . getString ( "abn" ) ) ; //商圈类型
info . put ( "partner_address" , client . getString ( "address" ) ) ; //商家店铺地址
info . put ( "partner_country" , client . getString ( "country" ) ) ; //国家
info . put ( "partner_state" , client . getString ( "state" ) ) ; //洲
info . put ( "partner_bussiness_name" , client . getString ( "business_name" ) ) ; //商户商用名称
info . put ( "legal_bussiness" , legalInfo . getString ( "representative_person" ) + " AS " + ( client . containsKey ( "business_name" ) ? client . getString ( "business_name" ) : legalInfo . getString ( "representative_person" ) ) + " ABN " + client . getString ( "abn" ) ) ; //拼接规则:法人名 AS 商用名称 ABD 编码
info . put ( "domestic_fee" , cardRate . getString ( "domestic_rate_value" ) ) ; //国内服务费
info . put ( "international_fee" , cardRate . getString ( "overseas_rate_value" ) ) ; //国际服务费
info . put ( "promotional_effective_date" , promotionalEffectiveDate ) ;
info . put ( "promotional_period" , promotionalPeriod ) ;
return info ;
}
private void exportTermsConditionsPDF ( String clientMoniker , JSONObject manage ) {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
}
if ( client . getIntValue ( "approve_result" ) ! = 1 & & client . getIntValue ( "approve_result" ) = = 3 ) {
throw new BadRequestException ( "The merchant failed the audit!" ) ;
}
String pdfPath = this . getClass ( ) . getClassLoader ( ) . getResource ( "" ) . getPath ( ) + "/templates/pdf/terms_and_conditions.pdf" ;
String fileName = clientMoniker + "_Terms_And_Conditions.pdf" ;
publishExcelCardPDFFile ( clientMoniker , manage , fileName , pdfPath , new JSONObject ( ) , TERMS_AND_CONDITIONS_FILE ) ;
}
private void publishExcelCardPDFFile ( String clientMoniker , JSONObject manager , String fileName , String pdfPath , JSONObject info , String fileLabel ) {
try {
PdfUtils pdu = new PdfUtils ( ) ;
pdu . setTemplatePdfPath ( pdfPath ) ;
pdu . setPdfTemplate ( info ) ;
try {
File file = new File ( fileName ) ;
ByteArrayOutputStream bos = pdu . templetPdfBos ( file ) ;
InputStream stream = new ByteArrayInputStream ( bos . toByteArray ( ) ) ;
JSONObject fileRes = attachmentClient . uploadFile ( stream , fileName , false ) ;
if ( fileRes ! = null ) {
importCardAgreeFile ( clientMoniker , manager , fileRes . getString ( "url" ) , fileLabel ) ;
}
stream . close ( ) ;
} catch ( Exception e ) {
logger . error ( "合同制作出现问题:" , e ) ;
}
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
}
private String convertDateEnglish ( Date date ) {
String [ ] months = { "Jan" , "Feb" , "Mar" , "Apr" , "May" , "Jun" , "Jul" , "Aug" , "Spt" , "Oct" , "Nov" , "Dec" } ;
Calendar calendar = Calendar . getInstance ( ) ;
calendar . setTime ( date ) ;
int year = calendar . get ( Calendar . YEAR ) ;
int month = calendar . get ( Calendar . MONTH ) ;
int day = calendar . get ( Calendar . DAY_OF_MONTH ) ;
return day + " " + months [ month ] + " " + year ;
}
private void importCardAgreeFile ( String clientMoniker , JSONObject manager , String sourceFile , String fileLabel ) {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
}
if ( sourceFile ! = null ) {
List < JSONObject > existFiles = clientFilesMapper . findFileByClientAndType ( client . getIntValue ( "client_id" ) , fileLabel ) ;
JSONObject existFile = null ;
if ( ! CollectionUtils . isEmpty ( existFiles ) ) {
existFile = existFiles . get ( 0 ) ;
}
Date now = new Date ( ) ;
JSONObject file = new JSONObject ( ) ;
file . put ( "file_name" , fileLabel ) ;
file . put ( "file_value" , sourceFile ) ;
file . put ( "client_id" , client . getIntValue ( "client_id" ) ) ;
file . put ( "last_update_date" , now ) ;
file . put ( "status" , 1 ) ;
file . put ( "is_valid" , 1 ) ;
if ( manager = = null ) {
file . put ( "last_update_by" , "System Import" ) ;
} else {
file . put ( "last_update_by" , manager . getString ( "display_name" ) ) ;
}
JSONObject contract = clientsContractMapper . findByClientId ( client . getIntValue ( "client_id" ) ) ;
if ( contract = = null | | now . compareTo ( contract . getDate ( "expiry_date" ) ) > 0 | | ! contract . getBoolean ( "has_sign" ) | | existFile = = null
| | existFile . isEmpty ( ) ) {
clientFilesMapper . save ( file ) ;
} else {
file . put ( "file_id" , existFile . getString ( "file_id" ) ) ;
clientFilesMapper . update ( file ) ;
}
}
}
public void saveLegalAndMarketingInfo ( JSONObject partner ) {
JSONObject representativeInfo = new JSONObject ( ) ;
representativeInfo . put ( "client_id" , partner . getIntValue ( "client_id" ) ) ;
representativeInfo . put ( "representative_person" , partner . getString ( "legal_representative_person" ) ) ;
representativeInfo . put ( "phone" , partner . getString ( "legal_representative_phone" ) ) ;
representativeInfo . put ( "email" , partner . getString ( "legal_representative_email" ) ) ;
representativeInfo . put ( "job_title" , partner . getString ( "legal_representative_job" ) ) ;
representativeInfo . put ( "address" , partner . getString ( "registered_address" ) ) ;
representativeInfo . put ( "suburb" , partner . getString ( "registered_suburb" ) ) ;
representativeInfo . put ( "postcode" , partner . getString ( "registered_postcode" ) ) ;
representativeInfo . put ( "state" , partner . getString ( "registered_state" ) ) ;
representativeInfo . put ( "legal_representative_wechatid" , partner . getString ( "legal_representative_wechatid" ) ) ;
representativeInfo . put ( "marketing_person" , partner . getString ( "marketing_person" ) ) ;
representativeInfo . put ( "marketing_phone" , partner . getString ( "marketing_phone" ) ) ;
representativeInfo . put ( "marketing_email" , partner . getString ( "marketing_email" ) ) ;
representativeInfo . put ( "marketing_job_title" , partner . getString ( "marketing_job" ) ) ;
representativeInfo . put ( "marketing_wechatid" , partner . getString ( "marketing_wechatid" ) ) ;
sysClientLegalPersonMapper . save ( representativeInfo ) ;
}
}
}