@ -6993,4 +6993,139 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientInfoCacheSupport . clearClientCache ( client . getIntValue ( "client_id" ) ) ;
}
@Override
public void exportLetterOfferPDF ( String clientMoniker , HttpServletResponse response ) {
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 ( fileName , pdfPath , info , response ) ;
}
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 = clientRateMapper . latestChannelCleanDays ( "rpaypmt_card" , clientId ) ;
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 info = new JSONObject ( ) ;
info . put ( "down_date" , convertDateEnglish ( new Date ( ) ) ) ; //下载文件日期
info . put ( "bussiness_name" , client . getString ( "business_name" ) + " 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" , client . getInteger ( "industry" ) ) ; //商户行业编码
info . put ( "legal_bussiness" , client . getString ( "contact_person" ) + " AS " + client . getString ( "business_name" ) + " ABN " + client . getString ( "abn" ) ) ; //拼接规则:法人名 AS 商用名称 ABD 编码
info . put ( "annual_rate" , "0" ) ; //年费率
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" ) ) ; //国际服务费
info . put ( "account_reserve" , "1000" ) ; //账户储备金
//银行账号信息
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" , "xxxxxxxxxxxxx" ) ;
return info ;
}
@Override
public void exportPromotionalOfferPDF ( String clientMoniker , String date , HttpServletResponse response ) {
JSONObject info = convertPromotionalOfferInfo ( clientMoniker , date ) ;
String pdfPath = this . getClass ( ) . getClassLoader ( ) . getResource ( "" ) . getPath ( ) + "/templates/pdf/promotional_offer.pdf" ;
String fileName = clientMoniker + "_Promotional_Offer.pdf" ;
publishExcelCardPDFFile ( fileName , pdfPath , info , response ) ;
}
private JSONObject convertPromotionalOfferInfo ( String clientMoniker , String date ) {
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 = clientRateMapper . latestChannelCleanDays ( "rpaypmt_card" , clientId ) ;
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 info = new JSONObject ( ) ;
info . put ( "down_date" , convertDateEnglish ( new Date ( ) ) ) ; //下载文件日期
info . put ( "bussiness_name" , client . getString ( "business_name" ) + " 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 ( "letter_offer_sub_time" , date ) ;
info . put ( "legal_bussiness" , client . getString ( "contact_person" ) + " AS " + client . getString ( "business_name" ) + " 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" , "xxxxxxxxx" ) ;
info . put ( "promotional_period" , "xxxxxxxxx" ) ;
return info ;
}
@Override
public void exportTermsConditionsPDF ( String clientMoniker , HttpServletResponse response ) {
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 ( fileName , pdfPath , new JSONObject ( ) , response ) ;
}
private void publishExcelCardPDFFile ( String fileName , String pdfPath , JSONObject info , HttpServletResponse response ) {
response . setContentType ( "application/pdf" ) ;
response . setHeader ( "Content-Disposition" , "attachment;fileName=" + fileName + ".pdf" ) ;
try {
OutputStream outs = response . getOutputStream ( ) ;
PdfUtils pdu = new PdfUtils ( ) ;
pdu . setTemplatePdfPath ( pdfPath ) ;
pdu . setPdfTemplate ( info ) ;
File file = new File ( fileName ) ;
ByteArrayOutputStream bos = pdu . templetPdfBos ( file , "" , "" ) ;
outs . write ( bos . toByteArray ( ) , 0 , bos . toByteArray ( ) . length ) ;
outs . flush ( ) ;
outs . close ( ) ;
} catch ( IOException e ) {
e . printStackTrace ( ) ;
} 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 ;
}
}