@ -1865,7 +1865,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
ByteArrayOutputStream bos = pdu . templetPdfBos ( file ) ;
stream = new ByteArrayInputStream ( bos . toByteArray ( ) ) ;
JSONObject fileRes = attachmentClient . uploadFile ( stream , clientMoniker + "_agreement.pdf" , false ) ;
importAgreeFile ( clientMoniker , manager , fileRes . getString ( "url" ) , false ) ;
importAgreeFile ( clientMoniker , manager , fileRes . getString ( "url" ) , false ) ;
} catch ( Exception e ) {
logger . error ( "合同制作出现问题:" , e ) ;
} finally {
@ -1875,7 +1875,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
@Transactional
public void getAggregateAgreeFile ( String clientMoniker , JSONObject manager , boolean renewal ) throws Exception {
public void getAggregateAgreeFile ( String clientMoniker , JSONObject manager , boolean renewal ) throws Exception {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
@ -1893,27 +1893,26 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
client . put ( "company_name_acn" , client . getString ( "company_name" ) + " (ABN " + client . getString ( "abn" ) + ")" ) ;
}
// List<JSONObject> clientRate = clientRateMapper.latestConfig(client.getIntValue("client_id"), null);
// if (CollectionUtils.isEmpty(clientRate)) {
// throw new BadRequestException("The Partner's Rate is not config!");
// }
// clientRate.forEach((p) -> {
// String rate_name = p.getString("rate_name");
// if ("Wechat".equals(rate_name)) {
// client.put("wechat_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
// client.put("clean", "T+" + p.getString("clean_days"));
// client.put("clean_days", p.getString("clean_days"));
// } else if ("Alipay".equals(rate_name)) {
// client.put("alipay_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
// } else if ("Bestpay".equals(rate_name)) {
// client.put("bestpay_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
// } else if ("jd".equals(rate_name)) {
// client.put("jd_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
// } else if ("AlipayOnline".equals(rate_name)) {
// client.put("alipay_online_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
// }
// });
// List<JSONObject> clientRate = clientRateMapper.latestConfig(client.getIntValue("client_id"), null);
// if (CollectionUtils.isEmpty(clientRate)) {
// throw new BadRequestException("The Partner's Rate is not config!");
// }
// clientRate.forEach((p) -> {
// String rate_name = p.getString("rate_name");
// if ("Wechat".equals(rate_name)) {
// client.put("wechat_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
// client.put("clean", "T+" + p.getString("clean_days"));
// client.put("clean_days", p.getString("clean_days"));
// } else if ("Alipay".equals(rate_name)) {
// client.put("alipay_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
// } else if ("Bestpay".equals(rate_name)) {
// client.put("bestpay_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
// } else if ("jd".equals(rate_name)) {
// client.put("jd_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
// } else if ("AlipayOnline".equals(rate_name)) {
// client.put("alipay_online_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN));
// }
// });
JSONObject weChatRate = merchantInfoProvider . clientCurrentRate ( client . getIntValue ( "client_id" ) , new Date ( ) , "Wechat" ) ;
if ( weChatRate = = null ) {
@ -1966,7 +1965,75 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
InputStream stream = new ByteArrayInputStream ( bos . toByteArray ( ) ) ;
JSONObject fileRes = attachmentClient . uploadFile ( stream , clientMoniker + "_" + System . currentTimeMillis ( ) + "_agreement.pdf" , false ) ;
if ( fileRes ! = null ) {
importAgreeFile ( clientMoniker , manager , fileRes . getString ( "url" ) , renewal ) ;
importAgreeFile ( clientMoniker , manager , fileRes . getString ( "url" ) , renewal ) ;
}
stream . close ( ) ;
} catch ( Exception e ) {
logger . error ( "合同制作出现问题:" , e ) ;
}
}
@Override
@Transactional
public void getNewAggregateAgreeFile ( String clientMoniker , JSONObject manager , boolean renewal ) throws Exception {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
}
String address = client . getString ( "address" ) . trim ( ) ;
if ( address . contains ( "," ) ) {
client . put ( "address" , address . substring ( 0 , address . lastIndexOf ( "," ) ) . trim ( ) ) ;
client . put ( "address_sub" , address . substring ( address . lastIndexOf ( "," ) + 1 ) . trim ( ) ) ;
}
if ( client . getString ( "acn" ) ! = null & & ! client . getString ( "acn" ) . equals ( "" ) ) {
client . put ( "acn_type" , "ACN: (" + client . getString ( "acn" ) + ")" ) ;
client . put ( "company_name_acn" , client . getString ( "company_name" ) + " (ACN " + client . getString ( "acn" ) + ")" ) ;
} else {
client . put ( "acn_type" , "ABN: (" + client . getString ( "abn" ) + ")" ) ;
client . put ( "company_name_acn" , client . getString ( "company_name" ) + " (ABN " + client . getString ( "abn" ) + ")" ) ;
}
List < JSONObject > clientRate = clientRateMapper . latestConfig ( client . getIntValue ( "client_id" ) , null ) ;
if ( CollectionUtils . isEmpty ( clientRate ) ) {
throw new BadRequestException ( "The Partner's Rate is not config!" ) ;
}
clientRate . forEach ( ( p ) - > {
String rate_name = p . getString ( "rate_name" ) ;
if ( "Wechat" . equals ( rate_name ) ) {
client . put ( "wechat_rate" , p . getBigDecimal ( "rate_value" ) . setScale ( 2 , BigDecimal . ROUND_DOWN ) ) ;
client . put ( "clean" , "T+" + p . getString ( "clean_days" ) ) ;
client . put ( "clean_days" , p . getString ( "clean_days" ) ) ;
} else if ( "Alipay" . equals ( rate_name ) ) {
client . put ( "alipay_rate" , p . getBigDecimal ( "rate_value" ) . setScale ( 2 , BigDecimal . ROUND_DOWN ) ) ;
} else if ( "Bestpay" . equals ( rate_name ) ) {
client . put ( "bestpay_rate" , p . getBigDecimal ( "rate_value" ) . setScale ( 2 , BigDecimal . ROUND_DOWN ) ) ;
} else if ( "jd" . equals ( rate_name ) ) {
client . put ( "jd_rate" , p . getBigDecimal ( "rate_value" ) . setScale ( 2 , BigDecimal . ROUND_DOWN ) ) ;
} else if ( "AlipayOnline" . equals ( rate_name ) ) {
client . put ( "alipay_online_rate" , p . getBigDecimal ( "rate_value" ) . setScale ( 2 , BigDecimal . ROUND_DOWN ) ) ;
}
} ) ;
JSONObject account = getBankAccountByClientId ( client . getIntValue ( "client_id" ) ) ;
if ( account = = null | | account . size ( ) < = 0 ) {
throw new BadRequestException ( "The Partner's Account is not config!" ) ;
}
client . put ( "bank" , account . getString ( "bank" ) ) ;
client . put ( "bsb_no" , account . getString ( "bsb_no" ) ) ;
client . put ( "account_no" , account . getString ( "account_no" ) ) ;
client . put ( "account_name" , account . getString ( "account_name" ) ) ;
String start_date = DateFormatUtils . format ( new Date ( ) , "dd/MM/yyyy" ) ;
client . put ( "start_date" , start_date ) ;
PdfUtils pdu = new PdfUtils ( ) ;
pdu . setTemplatePdfPath ( aggregateAgreetemplatePdfPath ) ;
pdu . setPdfTemplate ( client ) ;
try {
File file = new File ( clientMoniker + "_agreement.pdf" ) ;
ByteArrayOutputStream bos = pdu . templetPdfBos ( file ) ;
InputStream stream = new ByteArrayInputStream ( bos . toByteArray ( ) ) ;
JSONObject fileRes = attachmentClient . uploadFile ( stream , clientMoniker + "_" + System . currentTimeMillis ( ) + "_agreement.pdf" , false ) ;
if ( fileRes ! = null ) {
importAgreeFile ( clientMoniker , manager , fileRes . getString ( "url" ) , renewal ) ;
}
stream . close ( ) ;
} catch ( Exception e ) {
@ -2052,7 +2119,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
@Transactional
public void importAgreeFile ( String clientMoniker , JSONObject manager , String sourceFile , boolean renewal ) {
public void importAgreeFile ( String clientMoniker , JSONObject manager , String sourceFile , boolean renewal ) {
JSONObject client = getClientInfoByMoniker ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
@ -2081,7 +2148,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
file . put ( "file_id" , existFile . getString ( "file_id" ) ) ;
clientFilesMapper . update ( file ) ;
}
if ( ! renewal ) {
if ( ! renewal ) {
client . put ( "open_status" , 2 ) ;
clientMapper . update ( client ) ;
}
@ -2598,22 +2665,22 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
@Transactional
public void changeManualSettle ( int client_id , boolean manual_settle , String operator_id , int type , String operation ) {
public void changeManualSettle ( int client_id , boolean manual_settle , String operator_id , int type , String operation ) {
JSONObject client = getClientInfo ( client_id ) ;
if ( client = = null ) {
if ( client = = null ) {
throw new BadRequestException ( "merchant not found" ) ;
}
JSONObject record = new JSONObject ( ) ;
record . put ( "client_id" , client_id ) ;
record . put ( "manual_settle" , manual_settle ) ;
record . put ( "client_id" , client_id ) ;
record . put ( "manual_settle" , manual_settle ) ;
clientMapper . update ( record ) ;
JSONObject actClientLog = new JSONObject ( ) ;
actClientLog . put ( "client_id" , client_id ) ;
actClientLog . put ( "operator_id" , operator_id ) ;
actClientLog . put ( "operation" , operation ) ;
actClientLog . put ( "create_time" , new Date ( ) ) ;
actClientLog . put ( "operator_type" , type ) ;
actClientLog . put ( "client_id" , client_id ) ;
actClientLog . put ( "operator_id" , operator_id ) ;
actClientLog . put ( "operation" , operation ) ;
actClientLog . put ( "create_time" , new Date ( ) ) ;
actClientLog . put ( "operator_type" , type ) ;
clientsOperationLogMapper . save ( actClientLog ) ;
clientInfoCacheSupport . clearClientCache ( client_id ) ;
@ -3173,38 +3240,47 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
@Override
public JSONObject getCheckClientInfo ( int client_id , String account_id ) {
public JSONObject getCheckClientInfo ( int client_id , String account_id ) {
JSONObject result = clientContractService . getClientContractExpire ( client_id ) ;
JSONObject account = clientAccountMapper . findById ( account_id ) ;
boolean expire = result . getBoolean ( "rate_expire" ) ;
boolean waring = result . getBoolean ( "rate_waring" ) ;
boolean old_contract = result . getBoolean ( "old_contract" ) ;
if ( PartnerRole . getRole ( account . getIntValue ( "role" ) ) = = PartnerRole . CASHIER ) {
result . put ( "is_ordinary" , true ) ;
if ( ! expire & & waring ) {
String [ ] key = { result . getString ( "expire_days" ) } ;
result . put ( "contract_info" , editContractOrdinaryWaring ( key , messageSource . getMessage ( "sys.contract.ordinary.waring" , null , RequestEnvironment . getLocale ( ) ) ) ) ;
result . put ( "contract_info" ,
editContractOrdinaryWaring ( key , messageSource . getMessage ( "sys.contract.ordinary.waring" , null , RequestEnvironment . getLocale ( ) ) ) ) ;
}
if ( expire ) {
result . put ( "contract_info" , messageSource . getMessage ( "sys.contract.ordinary.info" , null , RequestEnvironment . getLocale ( ) ) ) ;
}
return result ;
if ( old_contract ) {
result . put ( "contract_info" , messageSource . getMessage ( "contract.old.waring" , null , RequestEnvironment . getLocale ( ) ) ) ;
}
} else {
result . put ( "is_ordinary" , false ) ;
if ( ! expire & & waring ) {
String [ ] key = { result . getString ( "expire_days" ) } ;
result . put ( "contract_info" , editContractOrdinaryWaring ( key , messageSource . getMessage ( "sys.contract.waring" , null , RequestEnvironment . getLocale ( ) ) ) ) ;
result . put ( "contract_info" ,
editContractOrdinaryWaring ( key , messageSource . getMessage ( "sys.contract.waring" , null , RequestEnvironment . getLocale ( ) ) ) ) ;
}
if ( expire ) {
result . put ( "contract_info" , messageSource . getMessage ( "sys.contract.info" , null , RequestEnvironment . getLocale ( ) ) ) ;
}
JSONObject file = clientContractService . getOrGenerateSourceAgreement ( account . getIntValue ( "client_id" ) , "pc" ) ;
if ( file ! = null ) {
result . put ( "file_url" , file . getString ( "file_value" ) ) ;
} else {
result . put ( "file_url" , "" ) ;
if ( old_contract ) {
result . put ( "contract_info" , messageSource . getMessage ( "contract.old.waring" , null , RequestEnvironment . getLocale ( ) ) ) ;
}
return result ;
}
JSONObject file = clientContractService . getOrGenerateSourceAgreement ( account . getIntValue ( "client_id" ) , "pc" ) ;
if ( file ! = null ) {
result . put ( "file_url" , file . getString ( "file_value" ) ) ;
} else {
result . put ( "file_url" , "" ) ;
}
return result ;
}
@ -3213,6 +3289,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
return "" ;
}
for ( int i = 0 ; i < key . length ; i + + ) {
if ( key [ i ] = = null ) {
return "" ;
}
sourceStr = sourceStr . replace ( "{" + i + "}" , key [ i ] ) ;
}
return sourceStr ;