From 1fb4f23f9f9c3c53690a7020f12d8c286db067b5 Mon Sep 17 00:00:00 2001 From: duLingLing Date: Tue, 6 Aug 2019 17:02:02 +0800 Subject: [PATCH] =?UTF-8?q?Upd:=E3=80=90=E8=B4=A2=E5=8A=A1=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E3=80=91=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=A1=A8,=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=B1=95=E7=A4=BA=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../analysis/core/impls/DailyReportImp.java | 181 ++++++++++++++--- .../mappers/payment/TransactionMapper.java | 9 + .../mappers/payment/TransactionMapper.xml | 19 ++ .../templates/reports/daily_report.html | 184 +++++++++++++----- 4 files changed, 325 insertions(+), 68 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 a7b83e567..27cd6fd5c 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 @@ -6,6 +6,7 @@ import au.com.royalpay.payment.manage.mappers.financial.FinancialBDCommissionCon 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; +import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.redpack.ActPartnerLMLogMapper; import au.com.royalpay.payment.manage.mappers.system.ClientMapper; import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; @@ -27,11 +28,10 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.text.NumberFormat; import java.text.ParseException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; +import java.util.*; /** * Created by yishuqian on 16/11/2017. @@ -57,13 +57,19 @@ public class DailyReportImp implements DailyReport { @Resource private FinancialBDCommissionConfigMapper financialBDCommissionConfigMapper; private Logger logger = LoggerFactory.getLogger(getClass()); + @Resource + private TransactionMapper transactionMapper; @Override public void generateReport(String date, boolean sendMsg) { try { - Date dt = DateUtils.parseDate(date, new String[]{"yyyy-MM-dd"}); - String reportId =DateFormatUtils.format(dt,"yyyy-MM-dd"); + Date beginTime = DateUtils.parseDate(date, new String[]{"yyyy-MM-dd"}); + String reportId =DateFormatUtils.format(beginTime,"yyyy-MM-dd"); + Date yesterdayEndTime = DateUtils.addDays(beginTime, 1); + String endDate = DateFormatUtils.format(yesterdayEndTime, "yyyy-MM-dd"); + Date endTime = DateUtils.parseDate(endDate, new String[]{"yyyy-MM-dd"}); + JSONObject report = dailyReportMapper.findOne(reportId); if (report != null) { @@ -71,16 +77,16 @@ public class DailyReportImp implements DailyReport { } report = new JSONObject(); report.put("report_id", reportId); - report.put("analysis_date", dt); + report.put("analysis_date", beginTime); report.put("report_date", new Date()); - JSONObject creditReport = getCreditReport(dt); + JSONObject creditReport = getCreditReport(beginTime,endTime); report.put("credit", creditReport.toJSONString()); - JSONObject debitReport = getDebitReport(dt); + JSONObject debitReport = getDebitReport(beginTime); report.put("debit", JSON.toJSONString(debitReport)); - JSONObject kpiReport = getKPI(dt); + JSONObject kpiReport = getKPI(beginTime); report.put("kpi", JSON.toJSONString(kpiReport)); dailyReportMapper.save(report); @@ -199,23 +205,152 @@ public class DailyReportImp implements DailyReport { return report; } - private JSONObject getCreditReport(Date dt) { + private JSONObject getCreditReport(Date beginTime,Date endTime) { JSONObject report = new JSONObject(); - JSONObject settle = clearingLogMapper.getSettleDataDailyReport(dt); - BigDecimal total_credit = settle.getBigDecimal("royalpay_charge"); - BigDecimal settle_amount = settle.getBigDecimal("net_amount"); - JSONObject last_settle = clearingLogMapper.getSettleDataDailyReport(DateUtils.addDays(dt,-1)); - BigDecimal last_credit = last_settle.getBigDecimal("royalpay_charge"); - report.put("settle_amount",settle_amount); - report.put("total_credit",total_credit); - BigDecimal credit_compare = total_credit.subtract(last_credit); - report.put("compare",credit_compare); - report.put("compare_value",Math.abs(credit_compare.doubleValue())); - List channels = clearingLogMapper.getSettlementChannelsDailyReport(dt); - report.put("channels",channels); + List settles = transactionMapper.getSettleDataDailyReport(beginTime,endTime); + JSONObject yesterdayTotal = this.computerTotalAmount(settles); + BigDecimal yesterday_credit_amount = yesterdayTotal.getBigDecimal("total_credit_amount"); + BigDecimal yesterday_debit_amount = yesterdayTotal.getBigDecimal("total_debit_amount"); + BigDecimal yesterday_net_trading = yesterdayTotal.getBigDecimal("total_net_trading"); + BigDecimal yesterday_total_surcharge = yesterdayTotal.getBigDecimal("total_total_surcharge"); + BigDecimal yesterday_royal_surcharge = yesterdayTotal.getBigDecimal("total_royal_surcharge"); + BigDecimal yesterday_channel_surcharge = yesterdayTotal.getBigDecimal("total_channel_surcharge"); + BigDecimal yesterday_tax_amount = yesterdayTotal.getBigDecimal("total_tax_amount"); + + List last_settle = transactionMapper.getSettleDataDailyReport(DateUtils.addDays(beginTime,-1),DateUtils.addDays(endTime,-1)); + JSONObject lastTotal = this.computerTotalAmount(last_settle); + BigDecimal last_total_credit = lastTotal.getBigDecimal("total_credit_amount"); + BigDecimal last_debit_amount = lastTotal.getBigDecimal("total_debit_amount"); + BigDecimal last_net_trading = lastTotal.getBigDecimal("total_net_trading"); + BigDecimal last_total_surcharge = lastTotal.getBigDecimal("total_total_surcharge"); + BigDecimal last_royal_surcharge = lastTotal.getBigDecimal("total_royal_surcharge"); + BigDecimal last_channel_surcharge = lastTotal.getBigDecimal("total_channel_surcharge"); + BigDecimal last_tax_amount = lastTotal.getBigDecimal("total_tax_amount"); + + JSONObject percentage_yesterday_total_credit = this.percentage(yesterday_credit_amount, last_total_credit); + JSONObject percentage_yesterday_debit_amount = this.percentage(yesterday_debit_amount, last_debit_amount); + JSONObject percentage_yesterday_net_trading = this.percentage(yesterday_net_trading, last_net_trading); + JSONObject percentage_yesterday_total_surcharge = this.percentage(yesterday_total_surcharge, last_total_surcharge); + JSONObject percentage_yesterday_royal_surcharge = this.percentage(yesterday_royal_surcharge, last_royal_surcharge); + JSONObject percentage_yesterday_channel_surcharge = this.percentage(yesterday_channel_surcharge, last_channel_surcharge); + JSONObject percentage_yesterday_tax_amount = this.percentage(yesterday_tax_amount, last_tax_amount); + + report.put("channels",settles); + report.put("total_credit_amount",new JSONObject(){{ + put("amount",yesterday_credit_amount); + put("compare",percentage_yesterday_total_credit); + }}); + report.put("total_debit_amount",new JSONObject(){{ + put("amount",yesterday_debit_amount); + put("compare",percentage_yesterday_debit_amount); + }}); + report.put("total_net_trading",new JSONObject(){{ + put("amount",yesterday_net_trading); + put("compare",percentage_yesterday_net_trading); + }}); + report.put("total_total_surcharge",new JSONObject(){{ + put("amount",yesterday_total_surcharge); + put("compare",percentage_yesterday_total_surcharge); + }}); + report.put("total_royal_surcharge",new JSONObject(){{ + put("amount",yesterday_royal_surcharge); + put("compare",percentage_yesterday_royal_surcharge); + }}); + report.put("total_channel_surcharge",new JSONObject(){{ + put("amount",yesterday_channel_surcharge); + put("compare",percentage_yesterday_channel_surcharge); + }}); + report.put("total_tax_amount",new JSONObject(){{ + put("amount",yesterday_tax_amount); + put("compare",percentage_yesterday_tax_amount); + }}); + return report; } + private JSONObject computerTotalAmount(List settles){ + BigDecimal total_credit_amount = new BigDecimal("0.00"); + BigDecimal total_debit_amount = new BigDecimal("0.00"); + BigDecimal total_net_trading = new BigDecimal("0.00"); + BigDecimal total_total_surcharge = new BigDecimal("0.00"); + BigDecimal total_royal_surcharge = new BigDecimal("0.00"); + BigDecimal total_channel_surcharge = new BigDecimal("0.00"); + BigDecimal total_tax_amount = new BigDecimal("0.00"); + DecimalFormat df1 = new DecimalFormat("0.00"); + + for (int i=0;i getLastDaytransAmount(JSONObject params); List useAlipayOnlineClients(); + + /** + * 日清算 + * @param beginTime + * @param endTime + * @return + */ + List getSettleDataDailyReport(@Param("beginTime") Date beginTime,@Param("endTime")Date endTime); + } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml index 23ae1f780..b9856fc9a 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml @@ -1216,4 +1216,23 @@ WHERE order_channel='AlipayOnline' and create_time>='2019-01-01 00:00:00' + + diff --git a/src/main/resources/templates/reports/daily_report.html b/src/main/resources/templates/reports/daily_report.html index b04ca4c48..23d213f44 100644 --- a/src/main/resources/templates/reports/daily_report.html +++ b/src/main/resources/templates/reports/daily_report.html @@ -36,63 +36,97 @@
-
清算
-
-
-
-
-
清算金额(A$)
-
-
- +
+
Total 较昨日数据
+
+
+
+
总入账
+
+       +
+ +
-
-
-
交易手续费
-
-
-
-
-
交易渠道
-
RoyalPay手续费(A$)
-
-
-
-
-
+
+
+
总出账
+
+       +
+ +
- -
-
-
Total
-
总收入
-
+
净交易
+
+       +
+ + +
+
+
+
+
总手续费
+
+       +
+ + +
+
+
+
-
较昨天比较
+
平台手续费
+
+      
- - - + +
+
+
+
渠道成本手续费
+
+       +
+ + +
+
+
+
+
+
+
+       +
+ + +
+
+
+
+
+ Channel + +
+
+
- -
@@ -206,10 +240,70 @@
-
-
-
+