@ -1914,7 +1914,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
// }
// });
JSONObject weChatRate = merchantInfoProvider . clientCurrentRate ( client . getIntValue ( "client_id" ) , new Date ( ) , "Wechat" ) ;
if ( weChatRate = = null ) {
throw new BadRequestException ( "The Partner's Rate is not config!" ) ;
@ -1974,6 +1973,74 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
@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 ) {
logger . error ( "合同制作出现问题:" , e ) ;
}
}
@Override
public void temporaryExportPdf ( String clientMoniker , JSONObject manager , HttpServletResponse httpResponse ) throws Exception {
httpResponse . setContentType ( "application/pdf" ) ;
@ -3178,25 +3245,35 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
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 ( ) ) ) ;
}
if ( old_contract ) {
result . put ( "contract_info" , messageSource . getMessage ( "contract.old.waring" , null , RequestEnvironment . getLocale ( ) ) ) ;
}
}
JSONObject file = clientContractService . getOrGenerateSourceAgreement ( account . getIntValue ( "client_id" ) , "pc" ) ;
if ( file ! = null ) {
result . put ( "file_url" , file . getString ( "file_value" ) ) ;
@ -3204,7 +3281,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
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 ;