@ -6,6 +6,7 @@ import au.com.royalpay.payment.manage.activities.app_index.core.AppActService;
import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper ;
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper ;
import au.com.royalpay.payment.manage.appclient.beans.AppClientBean ;
import au.com.royalpay.payment.manage.appclient.beans.AppPaymentConfigBean ;
import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean ;
import au.com.royalpay.payment.manage.appclient.core.RetailAppService ;
import au.com.royalpay.payment.manage.cashback.core.CashbackService ;
@ -93,6 +94,7 @@ import org.thymeleaf.spring5.SpringTemplateEngine;
import java.awt.image.BufferedImage ;
import java.io.* ;
import java.lang.reflect.Array ;
import java.math.BigDecimal ;
import java.math.RoundingMode ;
import java.text.DateFormat ;
@ -110,6 +112,7 @@ import java.util.TimeZone;
import java.util.concurrent.LinkedBlockingQueue ;
import java.util.concurrent.ThreadPoolExecutor ;
import java.util.concurrent.TimeUnit ;
import java.util.stream.Collectors ;
import javax.annotation.Resource ;
import javax.servlet.ServletOutputStream ;
@ -352,7 +355,7 @@ public class RetailAppServiceImp implements RetailAppService {
}
@Override
public void changeSurchargeEnable ( JSONObject device , UpdateSurchargeDTO updateSurchargeDTO ) {
public void changeSurchargeEnable ( JSONObject device , AppPaymentConfigBean appPaymentConfigBean ) {
JSONObject client = clientManager . getClientInfo ( device . getIntValue ( "client_id" ) ) ;
JSONObject account = clientAccountMapper . findById ( device . getString ( "account_id" ) ) ;
if ( PartnerRole . getRole ( account . getIntValue ( "role" ) ) ! = PartnerRole . ADMIN ) {
@ -361,17 +364,65 @@ public class RetailAppServiceImp implements RetailAppService {
if ( client = = null ) {
throw new NotFoundException ( "Client not found, please check" ) ;
}
if ( updateSurchargeDTO . getApiSurcharge ( ) ! = null ) {
if ( appPaymentConfigBean . getApiSurcharge ( ) ! = null ) {
clientModifySupport . processClientConfigModify (
new SwitchPermissionModify ( account , client . getString ( "client_moniker" ) , "api_surcharge" , updateSurchargeDTO . getApiSurcharge ( ) ) ) ;
new SwitchPermissionModify ( account , client . getString ( "client_moniker" ) , "api_surcharge" , appPaymentConfigBean . getApiSurcharge ( ) ) ) ;
}
if ( updateSurchargeDTO . getQrcodeSurcharge ( ) ! = null ) {
if ( appPaymentConfigBean . getQrcodeSurcharge ( ) ! = null ) {
clientModifySupport . processClientConfigModify (
new SwitchPermissionModify ( account , client . getString ( "client_moniker" ) , "qrcode_surcharge" , updateSurchargeDTO . getQrcodeSurcharge ( ) ) ) ;
new SwitchPermissionModify ( account , client . getString ( "client_moniker" ) , "qrcode_surcharge" , appPaymentConfigBean . getQrcodeSurcharge ( ) ) ) ;
}
if ( updateSurchargeDTO . getRetailSurcharge ( ) ! = null ) {
if ( appPaymentConfigBean . getRetailSurcharge ( ) ! = null ) {
clientModifySupport . processClientConfigModify (
new SwitchPermissionModify ( account , client . getString ( "client_moniker" ) , "retail_surcharge" , updateSurchargeDTO . getRetailSurcharge ( ) ) ) ;
new SwitchPermissionModify ( account , client . getString ( "client_moniker" ) , "retail_surcharge" , appPaymentConfigBean . getRetailSurcharge ( ) ) ) ;
}
if ( appPaymentConfigBean . getRequireRemark ( ) ! = null ) {
clientModifySupport . processClientConfigModify (
new SwitchPermissionModify ( account , client . getString ( "client_moniker" ) , "require_remark" , appPaymentConfigBean . getRequireRemark ( ) ) ) ;
}
if ( appPaymentConfigBean . getRequireCustinfo ( ) ! = null ) {
clientModifySupport . processClientConfigModify (
new SwitchPermissionModify ( account , client . getString ( "client_moniker" ) , "require_custinfo" , appPaymentConfigBean . getRequireCustinfo ( ) ) ) ;
}
}
@Override
public void changePaymentConfigByMoniker ( JSONObject device , String clientMoniker , AppPaymentConfigBean appPaymentConfigBean ) {
JSONObject client = clientManager . getClientInfo ( device . getIntValue ( "client_id" ) ) ;
JSONObject account = clientAccountMapper . findById ( device . getString ( "account_id" ) ) ;
if ( PartnerRole . getRole ( account . getIntValue ( "role" ) ) ! = PartnerRole . ADMIN ) {
throw new ForbiddenException ( "You have no permission" ) ;
}
if ( client = = null ) {
throw new NotFoundException ( "Client not found, please check" ) ;
}
boolean isSubPartner = isSubPartner ( device , clientMoniker ) ;
if ( ! isSubPartner ) {
throw new ForbiddenException ( "You have no permission" ) ;
}
if ( appPaymentConfigBean . getApiSurcharge ( ) ! = null ) {
clientModifySupport . processClientConfigModify (
new SwitchPermissionModify ( account , clientMoniker , "api_surcharge" , appPaymentConfigBean . getApiSurcharge ( ) ) ) ;
}
if ( appPaymentConfigBean . getQrcodeSurcharge ( ) ! = null ) {
clientModifySupport . processClientConfigModify (
new SwitchPermissionModify ( account , clientMoniker , "qrcode_surcharge" , appPaymentConfigBean . getQrcodeSurcharge ( ) ) ) ;
}
if ( appPaymentConfigBean . getRetailSurcharge ( ) ! = null ) {
clientModifySupport . processClientConfigModify (
new SwitchPermissionModify ( account , clientMoniker , "retail_surcharge" , appPaymentConfigBean . getRetailSurcharge ( ) ) ) ;
}
if ( appPaymentConfigBean . getRequireRemark ( ) ! = null ) {
clientModifySupport . processClientConfigModify (
new SwitchPermissionModify ( account , clientMoniker , "require_remark" , appPaymentConfigBean . getRequireRemark ( ) ) ) ;
}
if ( appPaymentConfigBean . getRequireCustinfo ( ) ! = null ) {
clientModifySupport . processClientConfigModify (
new SwitchPermissionModify ( account , clientMoniker , "require_custinfo" , appPaymentConfigBean . getRequireCustinfo ( ) ) ) ;
}
}
@ -429,6 +480,18 @@ public class RetailAppServiceImp implements RetailAppService {
return clientManager . getAuthFiles ( account , client . getString ( "client_moniker" ) ) ;
}
@Override
public JSONObject getAuthFilesByMoniker ( JSONObject device , String clientMoniker ) {
if ( ! isSubPartner ( device , clientMoniker ) ) {
throw new ForbiddenException ( "You have no permission" ) ;
}
JSONObject client = clientManager . getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new NotFoundException ( "Client not found, please check" ) ;
}
return clientManager . getAllAuthFiles ( null , clientMoniker ) ;
}
@Override
public void uploadAuthFiles ( JSONObject device , ClientAuthFilesInfo clientAuthFilesInfo ) {
JSONObject client = clientManager . getClientInfo ( device . getIntValue ( "client_id" ) ) ;
@ -593,7 +656,24 @@ public class RetailAppServiceImp implements RetailAppService {
throw new ForbiddenException ( "You have no permission" ) ;
}
clientManager . updateAppClient ( account , device . getIntValue ( "client_id" ) , appClientBean ) ;
}
@Override
public void updateClientByMoniker ( JSONObject device , String clientMoniker , AppClientBean appClientBean ) {
String clientType = device . getString ( "client_type" ) ;
deviceSupport . findRegister ( clientType ) ;
JSONObject account = clientAccountMapper . findById ( device . getString ( "account_id" ) ) ;
if ( device . getIntValue ( "client_id" ) ! = account . getIntValue ( "client_id" ) | | PartnerRole . getRole ( account . getIntValue ( "role" ) ) = = PartnerRole . CASHIER ) {
throw new ForbiddenException ( "You have no permission" ) ;
}
if ( ! isSubPartner ( device , clientMoniker ) ) {
throw new ForbiddenException ( "You have no permission" ) ;
}
JSONObject client = clientManager . getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new NotFoundException ( "Client not found, please check" ) ;
}
clientManager . updateAppClient ( account , client . getIntValue ( "client_id" ) , appClientBean ) ;
}
@Override
@ -602,30 +682,25 @@ public class RetailAppServiceImp implements RetailAppService {
deviceSupport . findRegister ( clientType ) ;
JSONObject clientWithConfig = clientMapper . findClient ( device . getIntValue ( "client_id" ) ) ;
clientWithConfig . putAll ( clientConfigService . find ( device . getIntValue ( "client_id" ) ) ) ;
JSONObject res = SignInAccountServiceImpl . clientInfoWithNoSecretInfo ( clientWithConfig ) ;
res . put ( "is_skip_clearing" , res . getBoolean ( "skip_clearing" ) ) ;
JSONObject res = getClientBaseInfo ( clientWithConfig ) ;
if ( clientType . equals ( "iphone" ) ) {
res . put ( "skip_clearing" , ! res . getBoolean ( "skip_clearing" ) ) ;
}
if ( "4" . equals ( clientWithConfig . getString ( "source" ) ) ) {
res . put ( "refuse_remark" , clientWithConfig . getString ( "refuse_remark" ) ) ;
res . put ( "base_info_lack" , false ) ;
res . put ( "compliance_info_lack" , false ) ;
if ( StringUtils . isEmpty ( clientWithConfig . getString ( "business_structure" ) ) | | StringUtils . isEmpty ( clientWithConfig . getString ( "logo_url" ) )
| | StringUtils . isEmpty ( clientWithConfig . getString ( "description" ) )
| | ( "Company" . equals ( clientWithConfig . getString ( "business_structure" ) ) & & StringUtils . isEmpty ( clientWithConfig . getString ( "acn" ) ) )
| | ( ! "Company" . equals ( clientWithConfig . getString ( "business_structure" ) ) & & StringUtils . isEmpty ( clientWithConfig . getString ( "abn" ) ) )
| | ( StringUtils . isEmpty ( clientWithConfig . getString ( "company_website" ) ) & & StringUtils . isEmpty ( clientWithConfig . getString ( "company_photo" ) )
& & StringUtils . isEmpty ( clientWithConfig . getString ( "store_photo" ) ) ) ) {
res . put ( "base_info_lack" , true ) ;
return res ;
}
}
JSONObject file = clientManager . getAuthFiles ( null , clientWithConfig . getString ( "client_moniker" ) ) ;
for ( String s : fileName ) {
if ( file . getString ( s ) = = null ) {
res . put ( "compliance_info_lack" , true ) ;
}
}
@Override
public JSONObject getClientInfoByMoniker ( JSONObject device , String clientMoniker ) {
String clientType = device . getString ( "client_type" ) ;
deviceSupport . findRegister ( clientType ) ;
if ( ! isSubPartner ( device , clientMoniker ) ) {
throw new ForbiddenException ( "You have no permission" ) ;
}
JSONObject client = clientManager . getClientInfoByMoniker ( clientMoniker ) ;
client . putAll ( clientConfigService . find ( client . getIntValue ( "client_id" ) ) ) ;
JSONObject res = getClientBaseInfo ( client ) ;
if ( clientType . equals ( "iphone" ) ) {
res . put ( "skip_clearing" , ! res . getBoolean ( "skip_clearing" ) ) ;
}
return res ;
}
@ -637,6 +712,22 @@ public class RetailAppServiceImp implements RetailAppService {
return clientWithConfig ;
}
@Override
public JSONObject getQRCodePaySurChargeByMoniker ( JSONObject device , String clientMoniker ) {
if ( ! isSubPartner ( device , clientMoniker ) ) {
throw new ForbiddenException ( "You have no permission" ) ;
}
JSONObject client = clientManager . getClientInfoByMoniker ( clientMoniker ) ;
client . putAll ( clientConfigService . find ( client . getIntValue ( "client_id" ) ) ) ;
JSONObject result = new JSONObject ( ) ;
result . put ( "qrcode_surcharge" , client . getBooleanValue ( "qrcode_surcharge" ) ) ;
result . put ( "retail_surcharge" , client . getBooleanValue ( "retail_surcharge" ) ) ;
result . put ( "api_surcharge" , client . getBooleanValue ( "api_surcharge" ) ) ;
result . put ( "require_custinfo" , client . getBooleanValue ( "require_custinfo" ) ) ;
result . put ( "require_remark" , client . getBooleanValue ( "require_remark" ) ) ;
return result ;
}
@Override
public JSONObject getClientInfoMe ( JSONObject device ) {
JSONObject result = new JSONObject ( ) ;
@ -1490,50 +1581,21 @@ public class RetailAppServiceImp implements RetailAppService {
String clientType = device . getString ( "client_type" ) ;
deviceSupport . findRegister ( clientType ) ;
int clientId = device . getIntValue ( "client_id" ) ;
Date now = new Date ( ) ;
JSONObject res = merchantInfoProvider . clientCurrentRate ( clientId , now , "Wechat" ) ;
JSONObject client = clientManager . getClientInfo ( clientId ) ;
Assert . notNull ( client , "Client is null" ) ;
JSONObject clientConfig = clientConfigService . find ( clientId ) ;
ArrayList < JSONObject > channels = new ArrayList < > ( ) ;
if ( clientConfig . getBigDecimal ( "customer_surcharge_rate" ) ! = null ) {
res . put ( "customer_surcharge_rate" , clientConfig . getBigDecimal ( "customer_surcharge_rate" ) ) ;
}
res . put ( "max_customer_surcharge_rate" , PlatformEnvironment . getEnv ( ) . getMaxCustomerSurchargeRate ( ) ) ;
JSONObject wechat = getChannel ( clientId , now , "Wechat" ) ;
if ( wechat . containsKey ( "channel" ) ) {
channels . add ( wechat ) ;
}
JSONObject alipay = getChannel ( clientId , now , "Alipay" ) ;
if ( alipay . containsKey ( "channel" ) ) {
channels . add ( alipay ) ;
}
JSONObject bestpay = getChannel ( clientId , now , "Bestpay" ) ;
if ( bestpay . containsKey ( "channel" ) ) {
channels . add ( bestpay ) ;
}
JSONObject jd = getChannel ( clientId , now , "jd" ) ;
if ( jd . containsKey ( "channel" ) ) {
channels . add ( jd ) ;
}
JSONObject AlipayOnline = getChannel ( clientId , now , "AlipayOnline" ) ;
if ( AlipayOnline . containsKey ( "channel" ) ) {
channels . add ( AlipayOnline ) ;
return getClientRateByClientId ( clientId ) ;
}
@Override
public JSONObject getClientCurrentRateNewByMoniker ( JSONObject device , String clientMoniker ) {
String clientType = device . getString ( "client_type" ) ;
deviceSupport . findRegister ( clientType ) ;
if ( ! isSubPartner ( device , clientMoniker ) ) {
throw new ForbiddenException ( "You have no permission" ) ;
}
// JSONObject Hf = getChannel(clientId, now, "hf");
// if (Hf.containsKey("channel")) {
// channels.add(Hf);
// }
// JSONObject Yeepay = getChannel(clientId, now, "Yeepay");
// if (Yeepay.containsKey("channel")) {
// channels.add(Yeepay);
// }
JSONObject CBBankPay = getChannel ( clientId , now , "CB_BankPay" ) ;
if ( CBBankPay . containsKey ( "channel" ) ) {
channels . add ( CBBankPay ) ;
JSONObject client = clientManager . getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new NotFoundException ( "Client not found, please check" ) ;
}
res . put ( "channels" , channels ) ;
return res ;
return getClientRateByClientId ( client . getIntValue ( "client_id" ) ) ;
}
private JSONObject getChannel ( int clientId , Date date , String channel ) {
@ -2250,12 +2312,11 @@ public class RetailAppServiceImp implements RetailAppService {
deviceSupport . findRegister ( clientType ) ;
JSONObject client = clientMapper . findClient ( device . getIntValue ( "client_id" ) ) ;
JSONObject account = clientAccountMapper . findById ( device . getString ( "account_id" ) ) ;
JSONObject authFileStatus = signInAccountService . checkAuthFileStatus ( client ) ;
if ( PartnerRole . getRole ( account . getIntValue ( "role" ) ) = = PartnerRole . CASHIER ) {
JSONObject cashierResult = new JSONObject ( ) ;
cashierResult . put ( "client_less_file" , false ) ;
return cashierResult ;
authFileStatus . put ( "client_less_file" , false ) ;
}
return signInAccountService. checkAuthFileStatus ( client ) ;
return authFileStatus ;
}
@Override
@ -2387,6 +2448,19 @@ public class RetailAppServiceImp implements RetailAppService {
clientManager . commitAuthFilesToCompliance ( client . getString ( "client_moniker" ) , account , "App" ) ;
}
@Override
public boolean isSubPartner ( JSONObject device , String clientMoniker ) {
JSONObject client = clientManager . getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new NotFoundException ( "Client not found, please check" ) ;
}
if ( device . getIntValue ( "client_id" ) = = client . getIntValue ( "client_id" ) ) {
return true ;
}
JSONObject deviceClient = clientManager . getClientInfo ( device . getIntValue ( "client_id" ) ) ;
JSONArray listSubClients = clientManager . getAllClientIds ( device . getIntValue ( "client_id" ) ) ;
return ( listSubClients . contains ( client . getString ( "client_id" ) ) & & deviceClient . getBooleanValue ( "sub_manage" ) ) ;
}
private void exportCBBankAggregateFile ( JSONObject client , HttpServletResponse httpResponse ) {
httpResponse . setContentType ( "application/pdf" ) ;
@ -2444,4 +2518,84 @@ public class RetailAppServiceImp implements RetailAppService {
List < JSONObject > list = clientBankAccountMapper . clientBankAccounts ( client_id ) ;
return list . isEmpty ( ) ? new JSONObject ( ) : list . get ( 0 ) ;
}
private JSONObject getClientBaseInfo ( JSONObject clientWithConfig ) {
JSONObject res = SignInAccountServiceImpl . clientInfoWithNoSecretInfo ( clientWithConfig ) ;
res . put ( "is_skip_clearing" , res . getBoolean ( "skip_clearing" ) ) ;
if ( "4" . equals ( clientWithConfig . getString ( "source" ) ) ) {
res . put ( "refuse_remark" , clientWithConfig . getString ( "refuse_remark" ) ) ;
res . put ( "base_info_lack" , false ) ;
res . put ( "compliance_info_lack" , false ) ;
if ( StringUtils . isEmpty ( clientWithConfig . getString ( "business_structure" ) ) | | StringUtils . isEmpty ( clientWithConfig . getString ( "logo_url" ) )
| | StringUtils . isEmpty ( clientWithConfig . getString ( "description" ) )
| | ( "Company" . equals ( clientWithConfig . getString ( "business_structure" ) ) & & StringUtils . isEmpty ( clientWithConfig . getString ( "acn" ) ) )
| | ( ! "Company" . equals ( clientWithConfig . getString ( "business_structure" ) ) & & StringUtils . isEmpty ( clientWithConfig . getString ( "abn" ) ) )
| | ( StringUtils . isEmpty ( clientWithConfig . getString ( "company_website" ) ) & & StringUtils . isEmpty ( clientWithConfig . getString ( "company_photo" ) )
& & StringUtils . isEmpty ( clientWithConfig . getString ( "store_photo" ) ) ) ) {
res . put ( "base_info_lack" , true ) ;
}
JSONObject file = clientManager . getAuthFiles ( null , clientWithConfig . getString ( "client_moniker" ) ) ;
for ( String s : fileName ) {
if ( file . getString ( s ) = = null ) {
res . put ( "compliance_info_lack" , true ) ;
}
}
}
JSONObject clientLegal = sysClientLegalPersonMapper . findRepresentativeInfo ( res . getIntValue ( "client_id" ) ) ;
if ( clientLegal ! = null ) {
res . put ( "legal_person" , clientLegal . getString ( "representative_person" ) ) ;
res . put ( "legal_job_title" , clientLegal . getString ( "job_title" ) ) ;
res . put ( "legal_phone" , clientLegal . getString ( "phone" ) ) ;
res . put ( "legal_email" , clientLegal . getString ( "email" ) ) ;
}
return res ;
}
private JSONObject getClientRateByClientId ( int clientId ) {
Date now = new Date ( ) ;
JSONObject res = merchantInfoProvider . clientCurrentRate ( clientId , now , "Wechat" ) ;
JSONObject client = clientManager . getClientInfo ( clientId ) ;
Assert . notNull ( client , "Client is null" ) ;
JSONObject clientConfig = clientConfigService . find ( clientId ) ;
ArrayList < JSONObject > channels = new ArrayList < > ( ) ;
if ( clientConfig . getBigDecimal ( "customer_surcharge_rate" ) ! = null ) {
res . put ( "customer_surcharge_rate" , clientConfig . getBigDecimal ( "customer_surcharge_rate" ) ) ;
}
res . put ( "max_customer_surcharge_rate" , PlatformEnvironment . getEnv ( ) . getMaxCustomerSurchargeRate ( ) ) ;
JSONObject wechat = getChannel ( clientId , now , "Wechat" ) ;
if ( wechat . containsKey ( "channel" ) ) {
channels . add ( wechat ) ;
}
JSONObject alipay = getChannel ( clientId , now , "Alipay" ) ;
if ( alipay . containsKey ( "channel" ) ) {
channels . add ( alipay ) ;
}
JSONObject bestpay = getChannel ( clientId , now , "Bestpay" ) ;
if ( bestpay . containsKey ( "channel" ) ) {
channels . add ( bestpay ) ;
}
JSONObject jd = getChannel ( clientId , now , "jd" ) ;
if ( jd . containsKey ( "channel" ) ) {
channels . add ( jd ) ;
}
JSONObject AlipayOnline = getChannel ( clientId , now , "AlipayOnline" ) ;
if ( AlipayOnline . containsKey ( "channel" ) ) {
channels . add ( AlipayOnline ) ;
}
// JSONObject Hf = getChannel(clientId, now, "hf");
// if (Hf.containsKey("channel")) {
// channels.add(Hf);
// }
// JSONObject Yeepay = getChannel(clientId, now, "Yeepay");
// if (Yeepay.containsKey("channel")) {
// channels.add(Yeepay);
// }
JSONObject CBBankPay = getChannel ( clientId , now , "CB_BankPay" ) ;
if ( CBBankPay . containsKey ( "channel" ) ) {
channels . add ( CBBankPay ) ;
}
res . put ( "channels" , channels ) ;
return res ;
}
}