From 8bacdb61ea0ce4700b3edb46c00b4dc1fa125311 Mon Sep 17 00:00:00 2001 From: macminiuser Date: Mon, 26 Feb 2018 16:53:30 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BA=A4=E6=98=93=E9=A2=9D+=E9=80=80?= =?UTF-8?q?=E6=AC=BE+=E9=80=80=E6=AC=BE+=E9=80=80=E6=AC=BE=E7=AC=94?= =?UTF-8?q?=E6=95=B0+App=E6=B5=81=E6=B0=B4=E6=8E=A5=E5=8F=A3=E3=80=81?= =?UTF-8?q?=E4=BA=A4=E6=98=93=E9=A2=9D=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/db/modify.sql | 4 + .../mappers/TransactionAnalysisMapper.java | 1 + .../core/impls/RetailAppServiceImp.java | 18 +- .../manage/mappers/payment/OrderMapper.java | 2 + .../CustomerAndOrdersStatisticsMapper.xml | 1 + .../mappers/TransactionAnalysisMapper.xml | 28 ++- .../manage/mappers/payment/OrderMapper.xml | 171 ++++++++++++++---- 7 files changed, 178 insertions(+), 47 deletions(-) diff --git a/src/db/modify.sql b/src/db/modify.sql index 1a26ebc08..b194d6018 100644 --- a/src/db/modify.sql +++ b/src/db/modify.sql @@ -231,3 +231,7 @@ CREATE TABLE `sys_wx_merchant_apply` ( `operator` varchar(50) DEFAULT NULL, PRIMARY KEY (`merchant_app_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +alter table statistics_customer_order add column refund_orders int(10) DEFAULT NULL COMMENT '' AFTER `orders`; +alter table statistics_customer_order add column refund_amount DECIMAL(20,2) DEFAULT NULL COMMENT '' AFTER `total`; + diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.java b/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.java index 3e83dc242..99b8af194 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.java @@ -71,4 +71,5 @@ public interface TransactionAnalysisMapper { int getCountCustomers(@Param("date") Date date); + JSONObject getClientTransaction(JSONObject params); } diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java index d216cdea7..8156b029a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java @@ -173,10 +173,10 @@ public class RetailAppServiceImp implements RetailAppService { } JSONObject params = appQueryBean.toParams(); setAllClientIds(params, client_id); - JSONObject res = new JSONObject(); params.put("client_id", client_id); - res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); - res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); + JSONObject res = transactionAnalysisMapper.getClientTransaction(params); +// res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); +// res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); // res.put("refund_amount", transactionAnalysisMapper.analysisRefundAmount(params)); res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params)); res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params)); @@ -199,10 +199,11 @@ public class RetailAppServiceImp implements RetailAppService { } JSONObject params = appQueryBean.toParams(); setAllClientIds(params, client_id); - JSONObject res = new JSONObject(); params.put("client_id", client_id); - res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); - res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); + JSONObject res = transactionAnalysisMapper.getClientTransaction(params); + +// res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); +// res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params)); return res; } @@ -356,7 +357,10 @@ public class RetailAppServiceImp implements RetailAppService { params.put("dev_id", device.getString("dev_id")); } params.put("client_id", client_id); - PageList orders = orderMapper.listOrdersByClients(params, + +// PageList orders = orderMapper.listOrdersByClients(params, +// new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc"))); + PageList orders = orderMapper.listTransactionsForApp(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc"))); TimeZoneUtils.switchTimeZone(orders, query.getTimezone(), "create_time", "transaction_time", "confirm_time"); ArrayList date_contains = new ArrayList<>(); diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.java index 3c7f8f001..7c351ef10 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.java @@ -77,4 +77,6 @@ public interface OrderMapper { List listOrdersByClientsNoPages(JSONObject params); List listAnalysisClientCustomer(JSONObject params); + + PageList listTransactionsForApp(JSONObject params, PageBounds pageBounds); } diff --git a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml index a9d1f1e69..2a2a0027b 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/CustomerAndOrdersStatisticsMapper.xml @@ -39,6 +39,7 @@ + + \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml index 784b43597..4c3fe8f60 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml @@ -95,6 +95,8 @@ @@ -483,7 +514,8 @@ and o.create_time < #{to} and c.org_id=#{org_id} and c.org_id in - #{org_id} + #{org_id} + @@ -514,7 +546,8 @@ and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like - #{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or t.order_id = #{search_text}) + #{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or + t.order_id = #{search_text}) and p.client_moniker=#{search_text} @@ -541,15 +574,19 @@ and p.org_id=#{org_id} and p.org_id in - #{org_id} + #{org_id} + and o.create_time >= #{from} and o.create_time < #{to} and date(o.create_time)=date(#{date}) - and o.status=#{std} + and + o.status=#{std} - and o.channel=#{chan} + and + o.channel=#{chan} + GROUP BY o.order_id,t.refund_id @@ -558,24 +595,24 @@ + + From bf9a4f81e0a659f90d96827a5387a22340c32cea Mon Sep 17 00:00:00 2001 From: yuan <1551130722@qq.com> Date: Tue, 27 Feb 2018 16:52:23 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E8=B4=B9=E7=8E=87=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/impls/DashboardServiceImpl.java | 16 ++-- .../analysis/mappers/BDAnalysisMapper.xml | 11 ++- .../analysis/mappers/ClientAnalysisMapper.xml | 5 +- .../CustomerAndOrdersStatisticsMapper.xml | 18 +++- .../analysis/mappers/OrderAnalysisMapper.xml | 12 ++- .../mappers/TransactionAnalysisMapper.xml | 87 ++++++++++++++----- .../manage/mappers/payment/OrderMapper.xml | 13 ++- .../mappers/payment/TransactionMapper.xml | 12 ++- src/main/ui/static/dashboard/dashboard.js | 10 ++- 9 files changed, 141 insertions(+), 43 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java index d28c2ff4a..55c706383 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java @@ -57,7 +57,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT res.put("new_partners", clientAnalysisMapper.countNewClients(params)); res.put("total_partners", clientAnalysisMapper.countClients(params)); res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params)); - res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); + res.put("trade_amount", transactionAnalysisMapper.getClientTransaction(params).getBigDecimal("trade_amount")); // res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); // List topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc"))); // if (!topOrders.isEmpty()) { @@ -75,7 +75,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT // res.put("total_partners", clientAnalysisMapper.countClients(params)); // res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params)); // res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); - res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); + res.put("trade_count", transactionAnalysisMapper.getClientTransaction(params).getIntValue("trade_count")); List topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc"))); if (!topOrders.isEmpty()) { res.put("top_amount_order", topOrders.get(0)); @@ -212,7 +212,10 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT @Override public List getTradeAnalysisInDays(JSONObject params) { - return transactionAnalysisMapper.tradeAnalysisInDays(params); + if (!params.containsKey("client_ids") && !params.containsKey("org_id")) { + params.put("client_id", 0); + } + return customerAndOrdersStatisticsMapper.getSumCustomersAnalysis(params); } @Override @@ -227,9 +230,10 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT } JSONObject res = new JSONObject(); params.put("client_id", partner.getIntValue("client_id")); - res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); - res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); - res.put("refund_amount", transactionAnalysisMapper.analysisRefundAmount(params)); + JSONObject object = transactionAnalysisMapper.getClientTransaction(params); + res.put("trade_amount", object.getBigDecimal("trade_amount")); + res.put("trade_count", object.getIntValue("trade_count")); + res.put("refund_amount", object.getBigDecimal("refund_amount")); res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params)); res.put("pre_amount", transactionAnalysisMapper.analysisPreAmount(params)); List topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc"))); diff --git a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/BDAnalysisMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/BDAnalysisMapper.xml index f5f83a564..886be691b 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/BDAnalysisMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/BDAnalysisMapper.xml @@ -1,9 +1,11 @@ + + + + + + + GROUP BY s.date ORDER BY date DESC - + + --> - + + + + + + + + - + + - + + - + + + - + + + + - + + + + + + + + + + - + + --> + + + + + + = #{begin} AND @@ -696,7 +735,8 @@ and t.clearing_amount < #{amount_to} - + + + + + + SELECT temp.* FROM ( @@ -248,7 +250,9 @@ GROUP BY o.order_id,t.refund_id order by o.create_time - + + + + + + + + - + + + + SELECT sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)) @@ -516,7 +523,8 @@ GROUP BY so.org_id, trade_date,t.client_id ORDER BY c.org_id ASC, t.client_id ASC, trade_date ASC - + + SELECT d.bd_name,d.bd_id,sum(if(temp.transaction_type='Credit',temp.clearing_amount*d.proportion,0)) @@ -38,8 +36,6 @@ GROUP BY d.bd_id ORDER BY total DESC - - - - - - GROUP BY s.date ORDER BY date DESC - - + --> - - - - - - - - - - + - - + - - + - - - - - - - - - + - - + - - + - - + - - + --> - - + - - + - - + and t.clearing_amount < #{amount_to} - - + - - + SELECT temp.* FROM ( @@ -250,9 +249,7 @@ GROUP BY o.order_id,t.refund_id order by o.create_time - - + - - + - - + - - - - + - + - + SELECT sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)) @@ -523,8 +519,7 @@ GROUP BY so.org_id, trade_date,t.client_id ORDER BY c.org_id ASC, t.client_id ASC, trade_date ASC - - + SELECT - d.bd_name,d.bd_id,sum(if(temp.transaction_type='Credit',temp.clearing_amount*d.proportion,0)) + d.bd_name,d.bd_id,sum(if(temp.transaction_type='Credit',temp.clearing_amount*d.proportion,-temp.clearing_amount*d.proportion)) total, ifnull(sum(if(temp.refund_id is not null,if(temp.transaction_type='Debit',temp.clearing_amount,-temp.clearing_amount)*d.proportion,0)),0) refund_fee FROM @@ -38,7 +38,7 @@ SELECT c.industry,c.royalpayindustry, count(DISTINCT c.client_id) partner_counts, - IFNULL(sum(if(temp.transaction_type='Credit',temp.clearing_amount*d.proportion,0)),0) + IFNULL(sum(if(temp.transaction_type='Credit',temp.clearing_amount*d.proportion,-temp.clearing_amount*d.proportion)),0) total FROM (SELECT l.client_id,l.clearing_amount,l.transaction_type,l.refund_id,o.create_time FROM pmt_transactions l INNER JOIN pmt_orders o diff --git a/src/main/ui/static/dashboard/dashboard.js b/src/main/ui/static/dashboard/dashboard.js index c49cc3024..dec9f9dc4 100644 --- a/src/main/ui/static/dashboard/dashboard.js +++ b/src/main/ui/static/dashboard/dashboard.js @@ -128,6 +128,8 @@ define(['angular', 'uiRouter', 'uiBootstrap', 'angularEcharts'], function (angul $scope.analysis.total_partners = resp.data.total_partners; $scope.analysis.traded_partners = resp.data.traded_partners; $scope.analysis.trade_amount = resp.data.trade_amount; + $scope.analysis.trade_count = resp.data.trade_count; + // $scope.analysis.top_amount_order = resp.data.top_amount_order; // $scope.analysis.trade_count = resp.data.trade_count; // $scope.analysis.total_customers = resp.data.total_customers; @@ -140,7 +142,7 @@ define(['angular', 'uiRouter', 'uiBootstrap', 'angularEcharts'], function (angul // $scope.analysis.traded_partners = resp.data.traded_partners; // $scope.analysis.trade_amount = resp.data.trade_amount; $scope.analysis.top_amount_order = resp.data.top_amount_order; - $scope.analysis.trade_count = resp.data.trade_count; + // $scope.analysis.trade_count = resp.data.trade_count; $scope.analysis.total_customers = resp.data.total_customers; $scope.analysis.new_customers = resp.data.total_customers - resp.data.old_customers; $scope.analysis.old_customers = resp.data.old_customers;