From ac00e9052ae3e934b7e42b3dd564798c72652f36 Mon Sep 17 00:00:00 2001 From: luoyang Date: Tue, 21 May 2019 16:45:26 +0800 Subject: [PATCH 1/6] =?UTF-8?q?add=20=E5=90=8E=E6=B8=85=E7=AE=97invoice?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../ClearingDistributedSurchargeMapper.java | 3 + .../core/SurchargeAccountService.java | 2 + .../impl/SurchargeAccountServiceImpl.java | 87 ++++++++++++++++++- .../web/SurchargeAccountController.java | 7 ++ .../static/payment/partner/partner-manage.js | 5 +- .../templates/client_partner_detail.html | 2 +- .../partner/templates/partner_detail.html | 2 +- .../partner_surcharge_account_dialog.html | 2 +- ...artner_surcharge_account_month_dialog.html | 2 +- 10 files changed, 102 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 08118d1cf..5ab2a115a 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ UTF-8 1.1.2 - 1.0.4 + 1.0.5 diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.java index e04890a4a..11f8b00e6 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.java @@ -22,6 +22,9 @@ public interface ClearingDistributedSurchargeMapper { @AutoSql(type = SqlType.INSERT) void save(JSONObject transactions); + @AutoSql(type = SqlType.SELECT) + JSONObject findByClearingId(@Param("client_id") int clientId, @Param("clearing_detail_id") String clearingDetailId); + List getMonthDetailByClientId(@Param("datefrom") Date datefrom, @Param("dateto") Date dateto); List findSurchargeTransactionsByDetailId(@Param("client_id") int clientId, @Param("detailId") String detailId); diff --git a/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/SurchargeAccountService.java b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/SurchargeAccountService.java index a5250a2be..ba97930ce 100644 --- a/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/SurchargeAccountService.java +++ b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/SurchargeAccountService.java @@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.surchargeAccount.core; import com.alibaba.fastjson.JSONObject; +import javax.servlet.http.HttpServletResponse; import java.util.List; public interface SurchargeAccountService { @@ -12,4 +13,5 @@ public interface SurchargeAccountService { void fillMothsSurcharge(JSONObject manager, String detailId); + void exportInvoicePDF(int clientId, String clearingDetailIdJSONObject,JSONObject manager, HttpServletResponse httpResponse); } diff --git a/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java index ddd70edac..df89a5844 100644 --- a/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java @@ -1,6 +1,9 @@ package au.com.royalpay.payment.manage.surchargeAccount.core.impl; +import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; +import au.com.royalpay.payment.manage.mappers.log.ClearingDetailAnalysisMapper; import au.com.royalpay.payment.manage.mappers.system.ClearingDistributedSurchargeMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientMapper; import au.com.royalpay.payment.manage.mappers.system.ClientsSurchargeAccountsMapper; import au.com.royalpay.payment.manage.mappers.system.FinancialSurchargeAccountDetailMapper; import au.com.royalpay.payment.manage.surchargeAccount.core.SurchargeAccountService; @@ -10,7 +13,9 @@ import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import au.com.royalpay.payment.tools.lock.Locker; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; +import au.com.royalpay.payment.tools.utils.PdfUtils; import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.time.DateFormatUtils; import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,11 +23,14 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; import java.math.BigDecimal; -import java.util.Comparator; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.math.RoundingMode; +import java.util.*; import java.util.stream.Collectors; @Service @@ -33,6 +41,10 @@ public class SurchargeAccountServiceImpl implements SurchargeAccountService { @Resource private FinancialSurchargeAccountDetailMapper financialSurchargeAccountDetailMapper; @Resource + private ClientMapper clientMapper; + @Resource + private ClearingDetailAnalysisMapper clearingDetailAnalysisMapper; + @Resource private Locker locker; @Resource private ClientsSurchargeAccountsMapper clientsSurchargeAccountsMapper; @@ -129,4 +141,71 @@ public class SurchargeAccountServiceImpl implements SurchargeAccountService { locker.unlock(detail.getIntValue("client_id") + "_" + detail.getString("settle_month") + "_fill"); } } + + @Override + public void exportInvoicePDF(int clientId, String clearingDetailId,JSONObject manager, HttpServletResponse httpResponse) { + JSONObject client = clientMapper.findClient(clientId); + if (client == null) { + throw new InvalidShortIdException(); + } + JSONObject distributedDetail = clearingDistributedSurchargeMapper.findByClearingId(clientId, clearingDetailId); + String date = DateFormatUtils.format(distributedDetail.getDate("settle_date"), "dd MMM yyyy", Locale.US); + httpResponse.setContentType("application/pdf"); + httpResponse.setHeader("content-disposition", "attachment;filename="+ client.getString("client_moniker") + "_Invoice_" + date + ".pdf"); + ServletOutputStream sos = null; + JSONObject pdfInfo = new JSONObject(); + + try { + sos = httpResponse.getOutputStream(); + List clearingAnalysis = clearingDetailAnalysisMapper.listReportChannels(clearingDetailId); + invoiceChannelAmount(clearingAnalysis, pdfInfo); + httpResponse.getOutputStream(); + pdfInfo.put("date", date); + pdfInfo.put("company_name", client.getString("company_name")); + pdfInfo.put("address", client.getString("address")); + pdfInfo.put("suburb", client.getString("suburb") +" " + client.getString("state") +" " +client.getString("postcode")); + pdfInfo.put("country", client.getString("country")); + PdfUtils pdu = new PdfUtils(); + pdu.setTemplatePdfPath("https://file.royalpay.com.au/open/2019/05/21/1558428021205_9pyF7U1rEloxVOXx2k7bTeRxzJaXi0.pdf"); + pdu.setPdfTemplate(pdfInfo); + File file = new File(client.getString("client_moniker") + "_Invoice_"+ date + ".pdf"); + ByteArrayOutputStream bos = pdu.templetPdfBos(file); + sos.write(bos.toByteArray()); + sos.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void invoiceChannelAmount(List analysis,JSONObject pdfInfo) { + BigDecimal wechatSurcharge = BigDecimal.ZERO; + BigDecimal wechatTaxAmount = BigDecimal.ZERO; + BigDecimal wechatAmount = BigDecimal.ZERO; + BigDecimal alipaySurcharge = BigDecimal.ZERO; + BigDecimal alipayTaxAmount = BigDecimal.ZERO; + BigDecimal alipayAmount = BigDecimal.ZERO; + for (JSONObject detail : analysis) { + switch (detail.getString("channel")) { + case "Wechat": + wechatSurcharge = detail.getBigDecimal("total_charge"); + wechatTaxAmount = detail.getBigDecimal("tax_amount"); + wechatAmount = detail.getBigDecimal("distributed_surcharge"); + break; + case "Alipay": + alipaySurcharge = detail.getBigDecimal("total_charge"); + alipayTaxAmount = detail.getBigDecimal("tax_amount"); + alipayAmount = detail.getBigDecimal("distributed_surcharge"); + break; + default: + break; + } + } + pdfInfo.put("surcharge_wechat", wechatSurcharge); + pdfInfo.put("amount_wechat", wechatSurcharge); + pdfInfo.put("surcharge_alipay", alipaySurcharge); + pdfInfo.put("amount_alipay", alipaySurcharge); + pdfInfo.put("amount", wechatSurcharge.add(alipaySurcharge)); + pdfInfo.put("gst", wechatTaxAmount.add(alipayTaxAmount)); + pdfInfo.put("total_amount", (wechatAmount.add(alipayAmount)).setScale(2, RoundingMode.DOWN)); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/web/SurchargeAccountController.java b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/web/SurchargeAccountController.java index bd021e8a6..6c7a893fa 100644 --- a/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/web/SurchargeAccountController.java +++ b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/web/SurchargeAccountController.java @@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import java.util.List; @RequestMapping("/sys/surcharge_account") @@ -26,4 +27,10 @@ public class SurchargeAccountController { public void fillMothsSurcharge(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String detailId) { surchargeAccountService.fillMothsSurcharge(manager, detailId); } + + @ManagerMapping(value = "/{clientId}/settlement_logs/{clearingDetailId}/export", role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.FINANCIAL_STAFF}, method = RequestMethod.GET) + public void exportInvoicePDF(@PathVariable int clientId, @PathVariable String clearingDetailId, + @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, HttpServletResponse httpResponse) throws Exception { + surchargeAccountService.exportInvoicePDF(clientId, clearingDetailId, manager, httpResponse); + } } diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index 53c85d1e3..0eb1c26be 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -2404,13 +2404,12 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter }]); app.controller('surchargeAccountDetailCtrl', ['$scope', '$http', 'balance', 'partner', 'transactions', 'commonDialog', function ($scope, $http, balance, partner, transactions, commonDialog) { $scope.surcharge = angular.copy(balance); - $scope.transactions = angular.copy(transactions.data); + $scope.surchargeDetailData = angular.copy(transactions.data); $scope.partner = angular.copy(partner); $scope.canAddDetail = false; $scope.params = {}; $scope.getBalance = function () { - if ($scope.partner.surcharge_mode != undefined && $scope.partner.surcharge_mode == "distributed") { $http.get('/sys/partners/' + $scope.partner.client_moniker + '/surcharge_account').then(function (resp) { $scope.surcharge = resp.data; @@ -2421,7 +2420,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $scope.getTransactions = function () { $http.get('/sys/partners/' + $scope.partner.client_moniker + '/account/transactions').then(function (resp) { - $scope.transactions = resp.data; + $scope.surchargeDetailData = resp.data; }); } diff --git a/src/main/ui/static/payment/partner/templates/client_partner_detail.html b/src/main/ui/static/payment/partner/templates/client_partner_detail.html index 0e1ccad1a..6ebd7bb0e 100644 --- a/src/main/ui/static/payment/partner/templates/client_partner_detail.html +++ b/src/main/ui/static/payment/partner/templates/client_partner_detail.html @@ -315,7 +315,7 @@
- +

diff --git a/src/main/ui/static/payment/partner/templates/partner_detail.html b/src/main/ui/static/payment/partner/templates/partner_detail.html index e1e775dd4..fbc94df1f 100644 --- a/src/main/ui/static/payment/partner/templates/partner_detail.html +++ b/src/main/ui/static/payment/partner/templates/partner_detail.html @@ -708,7 +708,7 @@
- +

diff --git a/src/main/ui/static/payment/surchargeaccount/templates/partner_surcharge_account_dialog.html b/src/main/ui/static/payment/surchargeaccount/templates/partner_surcharge_account_dialog.html index 10729bd43..87e709b28 100644 --- a/src/main/ui/static/payment/surchargeaccount/templates/partner_surcharge_account_dialog.html +++ b/src/main/ui/static/payment/surchargeaccount/templates/partner_surcharge_account_dialog.html @@ -49,7 +49,7 @@ {{surcharge.remark}} - diff --git a/src/main/ui/static/payment/surchargeaccount/templates/partner_surcharge_account_month_dialog.html b/src/main/ui/static/payment/surchargeaccount/templates/partner_surcharge_account_month_dialog.html index 4c2f98838..1e41d32d6 100644 --- a/src/main/ui/static/payment/surchargeaccount/templates/partner_surcharge_account_month_dialog.html +++ b/src/main/ui/static/payment/surchargeaccount/templates/partner_surcharge_account_month_dialog.html @@ -51,7 +51,7 @@ - From 049e6705a3ddec1f4e66829d0165b698c5de3084 Mon Sep 17 00:00:00 2001 From: luoyang Date: Tue, 21 May 2019 16:59:32 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix=20=E5=90=8E=E6=B8=85=E7=AE=97=E6=89=8B?= =?UTF-8?q?=E7=BB=AD=E8=B4=B9Invoice=E6=A8=A1=E6=9D=BF=20=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=9B=9E=E6=BB=9A=E6=B8=85=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/ClearingDistributedSurchargeMapper.java | 2 +- .../core/impl/SurchargeAccountServiceImpl.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.java index 11f8b00e6..950877f1e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClearingDistributedSurchargeMapper.java @@ -23,7 +23,7 @@ public interface ClearingDistributedSurchargeMapper { void save(JSONObject transactions); @AutoSql(type = SqlType.SELECT) - JSONObject findByClearingId(@Param("client_id") int clientId, @Param("clearing_detail_id") String clearingDetailId); + List findByClearingId(@Param("client_id") int clientId, @Param("clearing_detail_id") String clearingDetailId); List getMonthDetailByClientId(@Param("datefrom") Date datefrom, @Param("dateto") Date dateto); diff --git a/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java index df89a5844..f53d0f34c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/surchargeAccount/core/impl/SurchargeAccountServiceImpl.java @@ -148,8 +148,12 @@ public class SurchargeAccountServiceImpl implements SurchargeAccountService { if (client == null) { throw new InvalidShortIdException(); } - JSONObject distributedDetail = clearingDistributedSurchargeMapper.findByClearingId(clientId, clearingDetailId); - String date = DateFormatUtils.format(distributedDetail.getDate("settle_date"), "dd MMM yyyy", Locale.US); + List distributedDetail = clearingDistributedSurchargeMapper.findByClearingId(clientId, clearingDetailId); + if (distributedDetail.size() > 1) { + throw new BadRequestException("此次清算扣款已回滚"); + } + JSONObject detial = distributedDetail.get(0); + String date = DateFormatUtils.format(detial.getDate("settle_date"), "dd MMM yyyy", Locale.US); httpResponse.setContentType("application/pdf"); httpResponse.setHeader("content-disposition", "attachment;filename="+ client.getString("client_moniker") + "_Invoice_" + date + ".pdf"); ServletOutputStream sos = null; From bb41d026b4a394ffa5fa30d214b61910100d3d0f Mon Sep 17 00:00:00 2001 From: "james.zhao" Date: Wed, 22 May 2019 11:10:23 +0800 Subject: [PATCH 3/6] =?UTF-8?q?kpi=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../analysis/core/impls/DailyReportImp.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DailyReportImp.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DailyReportImp.java index cfd767040..823285900 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DailyReportImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DailyReportImp.java @@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.analysis.core.impls; import au.com.royalpay.payment.manage.analysis.core.DailyReport; import au.com.royalpay.payment.manage.mappers.cashback.CashbackRecordsMapper; +import au.com.royalpay.payment.manage.mappers.financial.FinancialBDCommissionConfigMapper; import au.com.royalpay.payment.manage.mappers.financial.FinancialBDPrizeLogMapper; import au.com.royalpay.payment.manage.mappers.log.ClearingLogMapper; import au.com.royalpay.payment.manage.mappers.log.DailyReportMapper; @@ -22,7 +23,6 @@ import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -54,6 +54,8 @@ public class DailyReportImp implements DailyReport { private MpWechatApiProvider mpWechatApiProvider; @Resource private FinancialBDPrizeLogMapper financialBDPrizeLogMapper; + @Resource + private FinancialBDCommissionConfigMapper financialBDCommissionConfigMapper; private Logger logger = LoggerFactory.getLogger(getClass()); @@ -98,8 +100,8 @@ public class DailyReportImp implements DailyReport { private JSONObject getKPI(Date dt){ JSONObject report = new JSONObject(); List kpiList =new ArrayList<>(); - List prizeAmountAndBdTypeList = financialBDPrizeLogMapper.findBdPrizeAmountMonth(DateUtils.truncate(DateUtils.addDays(dt,-1), Calendar.DATE),DateUtils.truncate(dt, Calendar.DATE),DateUtils.truncate(DateUtils.addDays(dt,-1), Calendar.MONTH)); - List prizeAmountAndBdTypeListYesterDay = financialBDPrizeLogMapper.findBdPrizeAmountMonth(DateUtils.truncate(DateUtils.addDays(dt,-2), Calendar.DATE),DateUtils.truncate(DateUtils.addDays(dt,-1), Calendar.DATE),DateUtils.truncate(DateUtils.addDays(dt,-2), Calendar.MONTH)); + List prizeAmountAndBdTypeList = financialBDPrizeLogMapper.findBdPrizeAmountMonth(DateUtils.truncate(dt, Calendar.DATE),DateUtils.truncate(DateUtils.addDays(dt,1), Calendar.DATE),DateUtils.truncate(dt, Calendar.MONTH)); + List prizeAmountAndBdTypeListYesterDay = financialBDPrizeLogMapper.findBdPrizeAmountMonth(DateUtils.truncate(DateUtils.addDays(dt,-1), Calendar.DATE),DateUtils.truncate(dt, Calendar.DATE),DateUtils.truncate(DateUtils.addDays(dt,-1), Calendar.MONTH)); List clientsAmount = clientMapper.createClientsByGroup(DateUtils.truncate(DateUtils.addDays(dt,-1), Calendar.DATE),DateUtils.truncate(dt, Calendar.DATE)); //BD团队总KPI BigDecimal total_kpi_amount = BigDecimal.ZERO; @@ -114,7 +116,8 @@ public class DailyReportImp implements DailyReport { kpi.put("total_amount",p.getBigDecimal("total_amount")); //当月数据 kpi.put("month_amount",p.getBigDecimal("month_amount")); - kpi.put("kpi_amount",p.getBigDecimal("kpi_amount")); + BigDecimal kpi_amount = financialBDCommissionConfigMapper.findCurrentCommissionMaxAmount(DateFormatUtils.format(DateUtils.truncate(dt,Calendar.MONTH),"yyyy-MM"), p.getIntValue("bd_type")); + kpi.put("kpi_amount",kpi_amount); for(JSONObject prize : prizeAmountAndBdTypeListYesterDay){ if(prize.getString("bd_group").equals(kpi.getString("bd_group"))){ BigDecimal compare = kpi.getBigDecimal("total_amount").subtract(prize.getBigDecimal("total_amount")); @@ -122,14 +125,14 @@ public class DailyReportImp implements DailyReport { kpi.put("compare_value",Math.abs(compare.doubleValue())); } } - kpi.put("kpi_percent", p.getBigDecimal("month_amount").divide(p.getBigDecimal("kpi_amount"),4,BigDecimal.ROUND_HALF_DOWN).multiply(BigDecimal.valueOf(100)).toString().substring(0,5)+"%"); + kpi.put("kpi_percent", p.getBigDecimal("month_amount").divide(kpi_amount,4,BigDecimal.ROUND_HALF_DOWN).multiply(BigDecimal.valueOf(100)).toString().substring(0,5)+"%"); for(JSONObject clientAmount :clientsAmount ){ if(clientAmount.getString("bd_group").equals(kpi.getString("bd_group"))){ kpi.put("clients_history",clientAmount.getIntValue("clients_history")); kpi.put("clients_yesterday",clientAmount.getIntValue("clients_yesterday")); } } - total_kpi_amount = total_kpi_amount.add(p.getBigDecimal("kpi_amount")); + total_kpi_amount = total_kpi_amount.add(kpi_amount); total_month_amount = total_month_amount.add(p.getBigDecimal("month_amount")); kpiList.add(kpi); } From 3192310b80d211c2654933eee769b41132d664a2 Mon Sep 17 00:00:00 2001 From: "james.zhao" Date: Wed, 22 May 2019 11:53:55 +0800 Subject: [PATCH 4/6] =?UTF-8?q?kpi=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/manage/analysis/core/impls/DailyReportImp.java | 4 ++-- .../royalpay/payment/manage/mappers/system/ClientMapper.java | 2 +- .../royalpay/payment/manage/mappers/system/ClientMapper.xml | 4 ++-- src/main/resources/templates/reports/daily_report.html | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DailyReportImp.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DailyReportImp.java index 823285900..f68e87375 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DailyReportImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DailyReportImp.java @@ -102,7 +102,7 @@ public class DailyReportImp implements DailyReport { List kpiList =new ArrayList<>(); List prizeAmountAndBdTypeList = financialBDPrizeLogMapper.findBdPrizeAmountMonth(DateUtils.truncate(dt, Calendar.DATE),DateUtils.truncate(DateUtils.addDays(dt,1), Calendar.DATE),DateUtils.truncate(dt, Calendar.MONTH)); List prizeAmountAndBdTypeListYesterDay = financialBDPrizeLogMapper.findBdPrizeAmountMonth(DateUtils.truncate(DateUtils.addDays(dt,-1), Calendar.DATE),DateUtils.truncate(dt, Calendar.DATE),DateUtils.truncate(DateUtils.addDays(dt,-1), Calendar.MONTH)); - List clientsAmount = clientMapper.createClientsByGroup(DateUtils.truncate(DateUtils.addDays(dt,-1), Calendar.DATE),DateUtils.truncate(dt, Calendar.DATE)); + List clientsAmount = clientMapper.createClientsByGroup(DateUtils.truncate(dt, Calendar.DATE),DateUtils.truncate(DateUtils.addDays(dt,1), Calendar.DATE),DateUtils.truncate(dt, Calendar.MONTH)); //BD团队总KPI BigDecimal total_kpi_amount = BigDecimal.ZERO; //BD团队当月总销售额 @@ -128,7 +128,7 @@ public class DailyReportImp implements DailyReport { kpi.put("kpi_percent", p.getBigDecimal("month_amount").divide(kpi_amount,4,BigDecimal.ROUND_HALF_DOWN).multiply(BigDecimal.valueOf(100)).toString().substring(0,5)+"%"); for(JSONObject clientAmount :clientsAmount ){ if(clientAmount.getString("bd_group").equals(kpi.getString("bd_group"))){ - kpi.put("clients_history",clientAmount.getIntValue("clients_history")); + kpi.put("clients_month",clientAmount.getIntValue("clients_month")); kpi.put("clients_yesterday",clientAmount.getIntValue("clients_yesterday")); } } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java index 50c765812..28b157084 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java @@ -119,5 +119,5 @@ public interface ClientMapper { @Select("select client_id from sys_clients where parent_client_id=#{parent_client_id}") List childClientId(@Param("parent_client_id") int parent_client_id); - List createClientsByGroup(@Param("start_date") Date start_date,@Param("end_date") Date end_date); + List createClientsByGroup(@Param("start_date") Date start_date,@Param("end_date") Date end_date,@Param("start_date_month") Date start_date_month); } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml index 9efbb7400..de3f5474c 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml @@ -553,7 +553,7 @@ fbc.bd_name, fbc.bd_group, fbc.bd_type, - count( * ) clients_history + count( * ) clients_month FROM sys_clients sc INNER JOIN sys_client_bd d ON sc.client_id = d.client_id @@ -561,7 +561,7 @@ INNER JOIN financial_bd_config fbc ON fbc.manager_id = c.bd_group WHERE sc.org_id = 1 - AND sc.create_time < #{start_date} + AND sc.create_time >= #{start_date_month} AND d.is_valid = 1 AND c.bd_group IS NOT NULL AND d.start_date <= now( ) AND d.is_valid = 1 AND ( d.end_date IS NULL OR d.end_date > now( ) diff --git a/src/main/resources/templates/reports/daily_report.html b/src/main/resources/templates/reports/daily_report.html index 713c403be..8130f4909 100644 --- a/src/main/resources/templates/reports/daily_report.html +++ b/src/main/resources/templates/reports/daily_report.html @@ -183,7 +183,7 @@
-
昨日开户数(历史开户数)
+
昨日开户数(当月开户数)
@@ -192,7 +192,7 @@
+ th:text="${kpi.clients_yesterday}+'('+${kpi.clients_month}+')'">
From ae9346e6706a6c842f006dc13c47a8e0a18c1eab Mon Sep 17 00:00:00 2001 From: "james.zhao" Date: Wed, 22 May 2019 14:01:12 +0800 Subject: [PATCH 5/6] =?UTF-8?q?kpi=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/manage/analysis/core/impls/DailyReportImp.java | 3 +++ src/main/resources/templates/reports/daily_report.html | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DailyReportImp.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DailyReportImp.java index f68e87375..cd462889d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DailyReportImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DailyReportImp.java @@ -139,6 +139,9 @@ public class DailyReportImp implements DailyReport { report.put("kpiList",kpiList); report.put("kpi_percent_total",total_month_amount.divide(total_kpi_amount,4,BigDecimal.ROUND_HALF_DOWN).multiply(BigDecimal.valueOf(100)).toString().substring(0,5)+"%"); report.put("total_month_amount",total_month_amount); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(dt); + report.put("time_percent",BigDecimal.valueOf(calendar.get(Calendar.DAY_OF_MONTH)).divide(BigDecimal.valueOf(calendar.getActualMaximum(Calendar.DAY_OF_MONTH)),4,BigDecimal.ROUND_HALF_DOWN).multiply(BigDecimal.valueOf(100)).toString().substring(0,5)+"%"); return report; } diff --git a/src/main/resources/templates/reports/daily_report.html b/src/main/resources/templates/reports/daily_report.html index 8130f4909..31d58f921 100644 --- a/src/main/resources/templates/reports/daily_report.html +++ b/src/main/resources/templates/reports/daily_report.html @@ -145,6 +145,11 @@
+
+
时间进度
+
+
Date: Wed, 22 May 2019 16:13:35 +0800 Subject: [PATCH 6/6] =?UTF-8?q?fix=20=E5=8E=BB=E6=8E=89representative=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../manage/merchants/core/ClientManager.java | 4 +-- .../core/impls/ClientManagerImpl.java | 16 ++-------- .../web/PartnerManageController.java | 8 ++--- .../static/payment/partner/partner-manage.js | 31 ++++++------------- 5 files changed, 18 insertions(+), 43 deletions(-) diff --git a/pom.xml b/pom.xml index 5ab2a115a..de462a78c 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ UTF-8 1.1.2 - 1.0.5 + 1.0.6 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 2f085f777..b3b9a7b10 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 @@ -323,9 +323,9 @@ public interface ClientManager { String subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager); - void registerAlipayGms(String clientMoniker, JSONObject representative_id, JSONObject manager); + void registerAlipayGms(String clientMoniker, JSONObject manager); - void registerAlipayOnlineGms(String clientMoniker, JSONObject representative_id, JSONObject manager); + void registerAlipayOnlineGms(String clientMoniker, JSONObject manager); String queryAlipayGmsStatus(String clientMoniker, JSONObject manager); 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 2626bc65a..a6fc718a9 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 @@ -3979,7 +3979,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } @Override - public void registerAlipayGms(String clientMoniker, JSONObject representative_id, JSONObject manager) { + public void registerAlipayGms(String clientMoniker, JSONObject manager) { JSONObject client = getClientInfoByMoniker(clientMoniker); if (client == null) { throw new InvalidShortIdException(); @@ -4002,13 +4002,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new BadRequestException("Alipay Industry can't be null"); } - if (!"Company".equals(client.getString("business_structure"))) { - if (StringUtils.isBlank(representative_id.getString("representative_id"))) { - throw new BadRequestException("ID or passport number can't be null"); - } - client.put("representative_id", representative_id.getString("representative_id")); - } - AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayRetailMerchant(); Element resultElement = alipayClient.registerGmsPortal(mch.getPid(), client); if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) { @@ -4117,7 +4110,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } @Override - public void registerAlipayOnlineGms(String clientMoniker, JSONObject representative_id, JSONObject manager) { + public void registerAlipayOnlineGms(String clientMoniker, JSONObject manager) { JSONObject client = getClientInfoByMoniker(clientMoniker); if (client == null) { throw new InvalidShortIdException(); @@ -4140,11 +4133,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } client.put("bank_id", client_bank.getString("account_no")); - if (StringUtils.isBlank(representative_id.getString("representative_id"))) { - throw new BadRequestException("ID or passport number can't be null"); - } - client.put("representative_id", representative_id.getString("representative_id")); - AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayOnlineMerchant(); Element resultElement = alipayClient.registerOnlineGmsPortal(mch.getPid(), client); if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) { 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 d324988f5..bb2f39f80 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 @@ -628,8 +628,8 @@ public class PartnerManageController { } @ManagerMapping(value = "/{clientMoniker}/register/alipay_gms", method = RequestMethod.POST, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN}) - public void registerAlipayGms(@PathVariable String clientMoniker,@RequestBody JSONObject representative_id,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { - clientManager.registerAlipayGms(clientMoniker, representative_id, manager); + public void registerAlipayGms(@PathVariable String clientMoniker,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + clientManager.registerAlipayGms(clientMoniker, manager); } @ManagerMapping(value = "/{clientMoniker}/query/alipay_gms", method = RequestMethod.GET, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN}) @@ -638,8 +638,8 @@ public class PartnerManageController { } @ManagerMapping(value = "/{clientMoniker}/register/alipayOnline_gms", method = RequestMethod.POST, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN}) - public void registerAlipayOnlineGms(@PathVariable String clientMoniker,@RequestBody JSONObject representative_id,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { - clientManager.registerAlipayOnlineGms(clientMoniker, representative_id, manager); + public void registerAlipayOnlineGms(@PathVariable String clientMoniker,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + clientManager.registerAlipayOnlineGms(clientMoniker, manager); } @ManagerMapping(value = "/{clientMoniker}/query/alipayOnline_gms", method = RequestMethod.GET, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN}) diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index 0eb1c26be..4ccf01a20 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -1588,26 +1588,16 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter $http.get('/sys/partners/' + $scope.partner.client_moniker + '/query/alipay_gms_json').then(function (resp) { $scope.alipay_gms_json = resp.data; commonDialog.confirm({ - title: 'Warning', - content: '是否使用该商户的现有信息进件?', - json:$scope.alipay_gms_json + title: 'Warning', + content: '是否使用该商户的现有信息进件?', + json: $scope.alipay_gms_json }).then(function () { - if ($scope.partner.business_structure === "Company") { - $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipay_gms', {representative_id: ""}).then(function () { + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipay_gms').then(function () { commonDialog.alert({title: 'Success', content: 'Alipay进件成功', type: 'success'}); }, function (resp) { commonDialog.alert({title: 'Error', content: "进件失败:" + resp.data.message, type: 'error'}); }) - } else { - commonDialog.inputText({title: '请输入商户身份证或护照号码'}).then(function (text) { - $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipay_gms', {representative_id: text}).then(function () { - commonDialog.alert({title: 'Success', content: '提示:Alipay进件成功', type: 'success'}); - }, function (resp) { - commonDialog.alert({title: 'Error', content: "进件失败:" + resp.data.message, type: 'error'}); - }) - }); - } - }) + }); }) }; $scope.queryAlipayGms = function () { @@ -1625,14 +1615,11 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter content: '是否使用该商户的现有信息进件?', json:$scope.alipayOnline_gms_json }).then(function () { - commonDialog.inputText({title: '请输入商户身份证或护照号码'}).then(function (text) { - $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipayOnline_gms', {representative_id: text}).then(function () { - commonDialog.alert({title: 'Success', content: '提示:AlipayOnline进件成功', type: 'success'}); - }, function (resp) { - commonDialog.alert({title: 'Error', content: "进件失败:" + resp.data.message, type: 'error'}); - }) + $http.post('/sys/partners/' + $scope.partner.client_moniker + '/register/alipayOnline_gms').then(function () { + commonDialog.alert({title: 'Success', content: '提示:AlipayOnline进件成功', type: 'success'}); + }, function (resp) { + commonDialog.alert({title: 'Error', content: "进件失败:" + resp.data.message, type: 'error'}); }); - }) }); };