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..a31e8e6a6 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,166 @@ 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); - return report; + List settles = transactionMapper.getSettleDataDailyReport(beginTime,endTime); + JSONObject yesterdayTotal = this.computerTotalAmount(settles); + BigDecimal yesterday_settle_amount = yesterdayTotal.getBigDecimal("total_settle_amount"); + 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_settle_amount = lastTotal.getBigDecimal("total_settle_amount"); + 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_settle_amount = this.percentage(yesterday_settle_amount, last_settle_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_settle_amount",new JSONObject(){{ + put("amount",yesterday_settle_amount); + put("compare",percentage_yesterday_settle_amount); + }}); + 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_settle_amount = new BigDecimal("0.00"); + 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..a90f672a1 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,24 @@ 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..e97ad6f4d 100644 --- a/src/main/resources/templates/reports/daily_report.html +++ b/src/main/resources/templates/reports/daily_report.html @@ -36,63 +36,108 @@
-
清算
-
-
-
-
-
清算金额(A$)
-
-
- +
+
Total 较昨日数据
+
+
+
+
入账
+
+       +
+ +
-
-
-
交易手续费
-
-
-
-
-
交易渠道
-
RoyalPay手续费(A$)
-
-
-
-
-
+
+
+
出账
+
+       +
+ + +
+
+
+
+
+
清算额
+
+       +
+ +
- -
-
-
Total
-
总收入
-
+
净交易
+
+       +
+ + +
+
+
+
+
+
手续费
+
+       +
+ + +
+
+
+
+
平台手续费
+
+       +
+ + +
+
+
+
-
较昨天比较
+
渠道成本手续费
+
+      
- - - + +
+
+
+
税费
+
+       +
+ + +
+
+
+
+
+ Channel + +
+
+
- -
@@ -206,10 +251,71 @@
-
-
-
+