Upd:Card-PDF导出文件

master
dulingling 5 years ago
parent 531d6ba78a
commit 42c3905c66

@ -584,4 +584,10 @@ public interface ClientManager {
void selectBillCodeVersion(JSONObject manager, String clientMoniker, String version);
void exportLetterOfferPDF(String clientMoniker,HttpServletResponse response);
void exportPromotionalOfferPDF(String moniker, String date, HttpServletResponse response);
void exportTermsConditionsPDF(String clientMoniker,HttpServletResponse response);
}

@ -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;
}
}

@ -22,6 +22,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
import java.util.List;
/**
@ -929,4 +930,43 @@ public class PartnerManageController {
public RPayMerchantEntity queryMWMerchantInfo(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.queryMWMerchantInfo(clientMoniker, manager);
}
/**
* /
* @param clientMoniker
*/
@ManagerMapping(value = "/{clientMoniker}/payment_card_permission", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR})
public void switchInternationalCard(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager){
clientManager.switchPermission(manager, clientMoniker, "enable_international_card", pass.getBooleanValue("allow"));
}
/**
* Letter of Offer pdf
*
* @param clientMoniker
*/
@ManagerMapping(value = "/{clientMoniker}/export/letter_of_offer_pdf", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR})
public void exportLetterOfferPDF(@PathVariable String clientMoniker,HttpServletResponse response){
clientManager.exportLetterOfferPDF(clientMoniker,response);
}
/**
* Promotional Offer pdf
*
* @param clientMoniker
*/
@ManagerMapping(value = "/{clientMoniker}/export/promotional_offer_pdf", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR})
public void exportPromotionalOfferPDF(@PathVariable String clientMoniker, @RequestParam("date")String date, HttpServletResponse response){
clientManager.exportPromotionalOfferPDF(clientMoniker,date,response);
}
/**
* Terms Conditions pdf
*
* @param clientMoniker
*/
@ManagerMapping(value = "/{clientMoniker}/export/terms_conditions_pdf", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR})
public void exportTermsConditionsPDF(@PathVariable String clientMoniker,HttpServletResponse response){
clientManager.exportTermsConditionsPDF(clientMoniker,response);
}
}

@ -1777,7 +1777,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
$http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) {
$scope.extParams = {};
$scope.paymentInfo = resp.data;
$scope.extParams = $scope.paymentInfo?JSON.parse($scope.paymentInfo.ext_params):null;
$scope.extParams = $scope.paymentInfo.ext_params?JSON.parse($scope.paymentInfo.ext_params):null;
$scope.convertExtParams = $scope.extParamsEditFlags()
$scope.ctrl.editSubMerchant = false;
$scope.ctrl.editAliSubMerchant = false;
@ -1966,10 +1966,8 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
$scope.refreshWechatInstitutionMerchantId = function () {
$http.put('/sys/partners/' + $scope.partner.client_moniker + '/wechat_institution_merchant_id', {wechat_institution_merchant_id: $scope.paymentInfo.wechat_institution_merchant_id}).then(function (resp) {
debugger
$scope.loadPartnerPaymentInfo();
}, function (resp) {
debugger
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
});
};
@ -2414,6 +2412,25 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
})
};
$scope.switchInternationalCard = function () {
if (!$scope.paymentInfo) {
return;
}
if (!$scope.init.enable_International_card) {
$scope.init.enable_International_card = true;
return;
}
$http.put('/sys/partners/' + $scope.partner.client_moniker + '/payment_card_permission', {allow: $scope.paymentInfo.enable_international_card}).then(function () {
$scope.loadPartnerPaymentInfo();
}, function (resp) {
commonDialog.alert({
title: 'failed to change international card permission status',
content: resp.data.message,
type: 'error'
})
})
};
$scope.changePaymentPage = function () {
if (!$scope.paymentInfo) {
return;

@ -489,6 +489,23 @@
</div>
</div>
</div>
<!-- 卡支付配置 -->
<div class="panel panel-default" ng-if="('111'|withRole) || ('retail_surcharge'|withFunc)">
<div class="panel-heading">Card Payment Config</div>
<div class="panel-body">
<div class="form-horizontal">
<!-- 是否启用国际卡支付 -->
<div class="form-group" ng-if="'111'|withRole">
<label class="col-sm-2 control-label">Enable International Card</label>
<div class="col-sm-10">
<input type="checkbox" ng-model="paymentInfo.enable_international_card" bs-switch
switch-change="switchInternationalCard()">
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default" ng-if="('111'|withRole) || ('retail_surcharge'|withFunc)">
<div class="panel-heading">Retail In Store Payment(App, WePayLite, Albert)</div>
<div class="panel-body">

Loading…
Cancel
Save