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