diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index e78be6bb6..18eca9b1c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -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); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 9e3f7fac3..3edd05647 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -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; + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java index 8a0fa3db1..6da1c017c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java @@ -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); + } } diff --git a/src/main/resources/templates/letter_of_offer.pdf b/src/main/resources/templates/letter_of_offer.pdf new file mode 100644 index 000000000..b9fa8f7e0 Binary files /dev/null and b/src/main/resources/templates/letter_of_offer.pdf differ diff --git a/src/main/resources/templates/pdf/letter_of_offer.pdf b/src/main/resources/templates/pdf/letter_of_offer.pdf new file mode 100644 index 000000000..e22fcdb24 Binary files /dev/null and b/src/main/resources/templates/pdf/letter_of_offer.pdf differ diff --git a/src/main/resources/templates/pdf/promotional_offer.pdf b/src/main/resources/templates/pdf/promotional_offer.pdf new file mode 100644 index 000000000..0977927a4 Binary files /dev/null and b/src/main/resources/templates/pdf/promotional_offer.pdf differ diff --git a/src/main/resources/templates/pdf/terms_and_conditions.pdf b/src/main/resources/templates/pdf/terms_and_conditions.pdf new file mode 100644 index 000000000..c741f21e1 Binary files /dev/null and b/src/main/resources/templates/pdf/terms_and_conditions.pdf differ diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index 2db44bf3f..558192fb3 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -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; diff --git a/src/main/ui/static/payment/partner/templates/partner_payment_info.html b/src/main/ui/static/payment/partner/templates/partner_payment_info.html index 80df579ba..aff94a22e 100644 --- a/src/main/ui/static/payment/partner/templates/partner_payment_info.html +++ b/src/main/ui/static/payment/partner/templates/partner_payment_info.html @@ -489,6 +489,23 @@ + +
+
Card Payment Config
+
+
+ +
+ +
+ +
+
+
+
+
+
Retail In Store Payment(App, WePayLite, Albert)