From e28adf6a236f3bac8a8154ef2c03d8ea7a943230 Mon Sep 17 00:00:00 2001 From: yuan <1551130722@qq.com> Date: Tue, 10 Apr 2018 11:12:08 +0800 Subject: [PATCH] fix bug --- .../core/impls/DashboardServiceImpl.java | 14 +- .../web/PartnerDashboardController.java | 9 - .../CustomerAndOrdersStatisticsMapper.xml | 13 +- .../mappers/TransactionAnalysisMapper.xml | 10 +- .../ui/static/css/new_partner_dashboard.css | 9 + .../ui/static/dashboard/partner-dashboard.js | 304 ++++-------------- .../templates/partner_dashboard.html | 44 ++- 7 files changed, 127 insertions(+), 276 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 4432474f4..06aa2ccd1 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 @@ -244,15 +244,15 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT params.put("end",DateUtils.addDays(params.getDate("end"),-1)); JSONObject yes = getTransJSONO(params); res.put("today",today); + res.put("yes",yes); res.put("not_settled", new BigDecimal(transactionAnalysisMapper.analysisNotSettled(params))); - JSONObject object = new JSONObject(); - object.put("client_id", partner.getIntValue("client_id")); - PageList logs = transactionMapper.listSettlementLog(object, new PageBounds(1, 1, Order.formString("clearing_time.desc"))); - res.put("latest_settle",logs.isEmpty()?BigDecimal.ZERO:logs.get(0).getBigDecimal("income")); - res.put("trade_amount_rise",yes.getBigDecimal("trade_amount").compareTo(BigDecimal.ZERO)>0 ? (today.getBigDecimal("trade_amount").subtract(yes.getBigDecimal("trade_amount"))).divide(yes.getBigDecimal("trade_amount"),4):BigDecimal.ZERO); - res.put("trade_count_rise", yes.getIntValue("trade_count") > 0 ? (today.getIntValue("trade_count")-yes.getIntValue("trade_count"))/yes.getIntValue("trade_count") : 0); + res.put("trade_amount_rise",yes.getBigDecimal("trade_amount").compareTo(BigDecimal.ZERO)>0 ? (today.getBigDecimal("trade_amount").subtract(yes.getBigDecimal("trade_amount"))).divide(yes.getBigDecimal("trade_amount"), 4, BigDecimal.ROUND_HALF_UP):BigDecimal.ZERO); + res.put("trade_count_rise", yes.getIntValue("trade_count") > 0 ? (today.getBigDecimal("trade_count").subtract(yes.getBigDecimal("trade_count"))).divide(yes.getBigDecimal("trade_count"), 4, BigDecimal.ROUND_HALF_UP) : 0); res.put("new_customers_rise", yes.getIntValue("new_customers") > 0 ? (today.getIntValue("new_customers")-yes.getIntValue("new_customers"))/yes.getIntValue("new_customers") : 0); - res.put("yes",yes); + params.remove("begin"); + params.remove("end"); + PageList logs = transactionMapper.listSettlementLog(params, new PageBounds(1, 1, Order.formString("clearing_time.desc"))); + res.put("latest_settle",logs.isEmpty()?BigDecimal.ZERO:logs.get(0).getBigDecimal("income")); return res; } private JSONObject getTransJSONO(JSONObject params){ diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerDashboardController.java b/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerDashboardController.java index de6766610..75e8f2337 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerDashboardController.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerDashboardController.java @@ -60,13 +60,4 @@ public class PartnerDashboardController { public JSONObject getAvgOrderAndCustomer(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner,AnalysisBean partnerAnalysisBean) { return dashboardService.getOrderAndCustomerPerDay(partner,partnerAnalysisBean); } - - @PartnerMapping("{client_moniker}/settlement_logs") - public JSONObject getPartnerSettlementLog(@PathVariable String client_moniker, TradeLogQuery query, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner) { - return partnerCardDashboardService.getSettlementLog(client_moniker, query); - } - @PartnerMapping("/{client_id}/settlement_logs/{detailId}") - public JSONObject listClearingTransactions(@PathVariable int client_id, @PathVariable String detailId) { - return cleanService.getCleanLogTransactions(client_id, detailId); - } } 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 20e2a813e..0193e2c0f 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 @@ -194,12 +194,19 @@ SELECT AVG(total) total,avg(orders) orders,avg(single_amount)single_amount,avg(customers) customers,avg(new_customers) new_customers,avg(old_customers)old_customers FROM statistics_customer_order s ]]> - where - - s.client_id = #{client_id} + + + AND s.client_id IN + + #{client_id} + + + + and s.client_id=#{client_id} and s.date >= #{begin} and s.date < #{end} + diff --git a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml index 0cc9af372..013fb8311 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml @@ -202,7 +202,15 @@ INNER JOIN pmt_orders o ON o.order_id = l.order_id WHERE (l.transaction_type = 'Credit' or l.refund_id is not null) ]]> - AND l.client_id = #{client_id} + + AND l.client_id IN + + #{client_id} + + + + and l.client_id=#{client_id} + and o.create_time >= #{begin} and o.create_time <= #{end} and l.org_id=#{org_id} diff --git a/src/main/ui/static/css/new_partner_dashboard.css b/src/main/ui/static/css/new_partner_dashboard.css index c7410eaf0..d491780db 100644 --- a/src/main/ui/static/css/new_partner_dashboard.css +++ b/src/main/ui/static/css/new_partner_dashboard.css @@ -101,3 +101,12 @@ mdi { .m-r-5 { margin-right: 5px; } +list-inline { + padding-left: 0; + list-style: none; +} +.widget-chart li { + width: 31.5%; + display: inline-block; + padding: 0; +} \ No newline at end of file diff --git a/src/main/ui/static/dashboard/partner-dashboard.js b/src/main/ui/static/dashboard/partner-dashboard.js index 7a2aed827..ddd6a1ff4 100644 --- a/src/main/ui/static/dashboard/partner-dashboard.js +++ b/src/main/ui/static/dashboard/partner-dashboard.js @@ -568,7 +568,7 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct } }]);*/ - app.controller('partnerDashboardCtrl', ['$scope', '$http', '$filter', '$uibModal','$timeout', 'chartParser', function ($scope, $http, $filter, $uibModal,$timeout, chartParser) { + app.controller('partnerDashboardCtrl', ['$scope', '$http', '$filter', '$uibModal','$timeout', 'chartParser','clearingDetailService', function ($scope, $http, $filter, $uibModal,$timeout, chartParser,clearingDetailService) { $scope.scales = [ { key: 'today', @@ -598,61 +598,71 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct params: function () { var date = new Date(); var end = $filter('date')(date, 'yyyyMMdd'); - date = date.setDate(date.getDate() - 6); - return { - begin: $filter('date')(date, 'yyyyMMdd'), - end: end - } - } - }, - { - key: 'month', - label: '本月', - params: function () { - var date = new Date(); - var end = $filter('date')(date, 'yyyyMMdd'); - date = date.setDate(1); + date = date.setDate(date.getDate() - 7); return { begin: $filter('date')(date, 'yyyyMMdd'), end: end } } }, - { - key: 'lastmonth', - label: '上月', - params: function () { - var date = new Date(); - date = date.setDate(1); - var oneDay=1000*60*60*24; - var end = $filter('date')(date-oneDay, 'yyyyMMdd'); - - var date2 = new Date(); - date2.setMonth(date2.getMonth() - 1); - date2 = date2.setDate(1); - var begin = $filter('date')(date2, 'yyyyMMdd'); - return { - begin: begin, - end: end - } - } - } ]; $scope.params = {}; $scope.pagination = {}; $scope.clientMoniker = $scope.currentUser.client_moniker; + $scope.chooseShow = 'All'; + $scope.clients = [$scope.currentUser.client]; + if ($scope.currentUser.client.has_children) { + $scope.params.client_ids = []; + $http.get('/client/partner_info/sub_partners',$scope.req).then(function (resp) { + var clientList = resp.data; + clientList.forEach(function (client) { + $scope.clients.push(client); + }); + $scope.clients.forEach(function (client) { + $scope.params.client_ids.push(client.client_id); + }); + $scope.loadDashboard(); + }) + } + $scope.chooseClient = function (sub) { + $scope.params.client_ids = []; + if (sub == 'All') { + $scope.chooseShow = 'All'; + $scope.clients.forEach(function (client) { + $scope.params.client_ids.push(client.client_id); + }); + } else { + $scope.params.client_ids = [sub.client_id]; + $scope.chooseShow = sub.short_name; + } + $scope.loadDashboard(); + }; + $scope.loadSettlementLogs = function (page) { + var params = {limit:10}; + $http.get('/client/trans_flow/settlement/log', {params: angular.merge(params,$scope.params)}).then(function (resp) { + $scope.settlementLogs = resp.data.data; + }); + }; $scope.loadDashboard = function () { loadTransCommon(); getExchangeRate(); + loadTradeAmountInTypes(angular.merge($scope.scales[2].params(),angular.copy($scope.params))); + loadFeeAnalysis(angular.merge($scope.scales[2].params(),angular.copy($scope.params))); + getOrderCustomerChartAnalysis(angular.merge($scope.scales[2].params(),angular.copy($scope.params))); + $scope.loadSettlementLogs(1); }; - $scope.loadDashboard(); + if (!$scope.currentUser.client.has_children){ + $scope.loadDashboard(); + } function loadTransCommon() { - var params = {begin: $filter('date')(new Date(), 'yyyyMMdd'), end: $filter('date')(new Date(), 'yyyyMMdd')}; + var params = angular.copy($scope.params); + params = angular.merge(params, $scope.scales[0].params()); $http.get('/dashboard/partner/common_analysis',{params:params}).then(function (resp) { $scope.transcommon = resp.data; }); } + function getExchangeRate() { $http.get('/dashboard/system/exchange_rates', {params: $scope.scales[0].params()}).then(function (resp) { if (resp.data && resp.data.length > 0) { @@ -714,7 +724,6 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct $scope.trade_type_chart = chartParser.parse(tradeInTypeConfig, resp.data); }); } - loadTradeAmountInTypes($scope.scales[2].params()); function loadFeeAnalysis(params) { @@ -732,7 +741,7 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct show: true, icon: 'path://M3.59-4.07L32.38-4.07L32.38 0.04Q22.25 25.11 17.19 46.34L10.65 46.34Q16.14 26.94 26.19 1.41L3.59 1.41L3.59-4.07Z', onclick: function () { - loadFeeAnalysis($scope.scales[2].params()); + loadFeeAnalysis(angular.merge($scope.scales[2].params(),$scope.params)); } }, myThirty: { @@ -745,7 +754,7 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct params.end = $filter('date')(dt, 'yyyyMMdd'); dt.setDate(dt.getDate() - 29); params.begin = $filter('date')(dt, 'yyyyMMdd'); - loadFeeAnalysis(params); + loadFeeAnalysis(angular.merge(params,$scope.params)); } } } @@ -774,20 +783,20 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct $scope.trade_line = chartParser.parse(analysisConfig, resp.data); }) } - loadFeeAnalysis($scope.scales[2].params()); + function getOrderCustomerChartAnalysis(params) { $http.get('/dashboard/partner/avg_order_customer',{params:params}).then(function (resp) { $scope.avgOrderAndCustomer = resp.data; }); - $http.get('/dashboard/partner/customers',{params:params}).then(function (resp) { + $http.get('/dashboard/partner/fee_analysis',{params:angular.merge(params,$scope.params)}).then(function (resp) { var dates = []; var new_customers = []; var old_customers = []; var total_amounts = []; var orders = []; - resp.data.reverse().forEach(function (e) { - dates.push(e.trade_date); + resp.data.forEach(function (e) { + dates.push(e.date); new_customers.push(e.new_customers); old_customers.push(e.old_customers); orders.push(e.orders); @@ -796,7 +805,7 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct $scope.customersHistory = customersHistoryConfig(dates, old_customers, new_customers, orders); }); } - getOrderCustomerChartAnalysis($scope.scales[2].params()); + var customersHistoryConfig = function (date, old_customers, new_customers, orders) { return { color: colors, @@ -815,7 +824,7 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct icon: 'path://M3.59-4.07L32.38-4.07L32.38 0.04Q22.25 25.11 17.19 46.34L10.65 46.34Q16.14 26.94 26.19 1.41L3.59 1.41L3.59-4.07Z', onclick: function () { $scope.time_range = "Last a week"; - getOrderCustomerChartAnalysis($scope.scales[2].params()) + getOrderCustomerChartAnalysis(angular.merge($scope.scales[2].params(),$scope.params)) } }, myThirty: { @@ -829,7 +838,7 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct dt.setDate(dt.getDate() - 29); params.begin = $filter('date')(dt, 'yyyyMMdd'); $scope.time_range = "Last a month"; - getOrderCustomerChartAnalysis(params) + getOrderCustomerChartAnalysis(angular.merge(params,$scope.params)) } } } @@ -881,184 +890,6 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct }; }; - /*function loadTradeTimeAnalysis(params) { - var timeAnalysis = { - chart: { - tooltip: { - trigger: 'axis' - }, - toolbox: { - show: true, - feature: { - mySeven: { - title: '最近7天', - show: true, - icon: 'path://M3.59-4.07L32.38-4.07L32.38 0.04Q22.25 25.11 17.19 46.34L10.65 46.34Q16.14 26.94 26.19 1.41L3.59 1.41L3.59-4.07Z', - onclick: function () { - loadTradeTimeAnalysis($scope.scales[2].params()); - } - }, - myThirty: { - title: '最近30天', - show: true, - icon: 'path://M12.52 17.02L16.10 17.02Q20.71 17.02 22.43 15.72Q25.66 13.23 25.66 8.23Q25.66-0.63 17.61-0.63Q10.93-0.63 9.42 6.93L3.73 6.93Q4.50 2.19 7.03-0.91Q10.90-5.51 17.61-5.51Q23.24-5.51 26.89-2.28Q31.22 1.52 31.22 8.02Q31.22 16.78 23.38 19.48Q32.84 23.14 32.84 32.81Q32.84 39.00 29.32 42.97Q25.10 47.79 17.72 47.79Q10.79 47.79 6.68 43.04Q3.66 39.56 3.02 33.44L8.93 33.44Q9.67 42.83 17.72 42.83Q21.45 42.83 23.98 40.72Q27.14 38.01 27.14 32.81Q27.14 21.63 16.10 21.63L12.52 21.63L12.52 17.02ZM54-5.51Q67.99-5.51 67.99 21.14Q67.99 47.79 54 47.79Q40.04 47.79 40.04 21.14Q40.04-5.51 54-5.51M46.97 33.65L59.84 4.30Q57.80-0.55 53.93-0.55Q45.95-0.55 45.95 21.14Q45.95 28.52 46.97 33.65M48.16 37.91Q50.13 42.83 54 42.83Q62.09 42.83 62.09 21.07Q62.09 13.86 61.07 8.66L48.16 37.91Z', - onclick: function () { - var params = {}; - var dt = new Date(); - params.end = $filter('date')(dt, 'yyyyMMdd'); - dt.setDate(dt.getDate() - 29); - params.begin = $filter('date')(dt, 'yyyyMMdd'); - loadTradeTimeAnalysis(params) - } - } - } - }, - legend: { - data: ['Total Amount', 'Total Count', 'Retail In-Store Amount', 'Retail In-Store Count', 'Retail API Amount', 'Retail API Count', - 'QR Code Amount', 'QR Code Count', - 'Online API Amount', 'Online API Count', 'WeChat HTML5 Amount', 'WeChat HTML5 Count'], - bottom: 0, - height: '15%', - width: '80%', - left: '10%' - }, - grid: { - top: 10, - bottom: '15%', - containLabel: true - }, - yAxis: [ - { - name: 'Avg Amount(AUD)', - type: 'value' - }, - { - name: 'Avg Count(Records)', - type: 'value' - } - ], - color: colors - }, - xAxis: { - basic: {type: 'category', boundaryGap: false, formatter: '{value}:00'}, - key: 'hour' - }, - series: [ - { - basic: { - name: 'Total Amount', - type: 'line', - symbol: 'triangle', - areaStyle: {normal: {}}, - yAxisIndex: 0 - }, - column: {key: 'total_fee'} - }, - { - basic: { - name: 'Total Count', - type: 'line', - yAxisIndex: 1 - }, - column: {key: 'total_count'} - }, - { - basic: { - name: 'Retail In-Store Amount', - type: 'line', - symbol: 'triangle', - areaStyle: {normal: {}}, - yAxisIndex: 0 - }, - column: {key: 'offline_fee'} - }, - { - basic: { - name: 'Retail In-Store Count', - type: 'line', - yAxisIndex: 1 - }, - column: {key: 'offline_count'} - }, - { - basic: { - name: 'Retail API Amount', - type: 'line', - symbol: 'triangle', - areaStyle: {normal: {}}, - yAxisIndex: 0 - }, - column: {key: 'offline_api_fee'} - }, - { - basic: { - name: 'Retail API Count', - type: 'line', - yAxisIndex: 1 - }, - column: {key: 'offline_api_count'} - }, - { - basic: { - name: 'QR Code Amount', - type: 'line', - symbol: 'triangle', - areaStyle: {normal: {}}, - yAxisIndex: 0 - }, - column: {key: 'client_code_fee'} - }, - { - basic: { - name: 'QR Code Count', - type: 'line', - yAxisIndex: 1 - }, - column: {key: 'client_code_count'} - }, - { - basic: { - name: 'Online API Amount', - type: 'line', - symbol: 'triangle', - areaStyle: {normal: {}}, - yAxisIndex: 0 - }, - column: {key: 'gateway_qrcode_fee'} - }, - { - basic: { - name: 'Online API Count', - type: 'line', - yAxisIndex: 1 - }, - column: {key: 'gateway_qrcode_count'} - }, - { - basic: { - name: 'WeChat HTML5 Amount', - type: 'line', - symbol: 'triangle', - areaStyle: {normal: {}}, - yAxisIndex: 0 - }, - column: {key: 'gateway_jsapi_fee'} - }, - { - basic: { - name: 'WeChat HTML5 Count', - type: 'line', - yAxisIndex: 1 - }, - column: {key: 'gateway_jsapi_count'} - } - ] - }; - $http.get('/dashboard/partner/trade_in_hours', {params: params}).then(function (resp) { - $scope.trade_time = chartParser.parse(timeAnalysis, resp.data); - }) - } - loadTradeTimeAnalysis($scope.scales[4].params());*/ $scope.displayExchangeRateHistory = function () { $uibModal.open({ templateUrl: '/static/dashboard/templates/exchange_rate_history_dialog.html', @@ -1079,29 +910,10 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct controller: 'unSettledAmountHistoryDialogCtrl' }) }; - $scope.loadSettlementLogs = function (page) { - var params = angular.copy($scope.params); - params.page = page || $scope.pagination.page || 1; - params.limit = 10; - $http.get('/dashboard/partner/' + $scope.clientMoniker + '/settlement_logs', {params: params}).then(function (resp) { - $scope.settlementLogs = resp.data.data; - $scope.pagination = resp.data.pagination; - }); - }; - $scope.getClearingTransactions = function (client_id,detail_id) { - $uibModal.open({ - templateUrl: '/static/analysis/templates/settlement_transactions.html', - controller: 'managerClearingDetailCtrl', - resolve: { - detail: ['$http', '$stateParams', function ($http) { - return $http.get('/dashboard/partner/' + client_id+'/settlement_logs/'+detail_id); - }] - }, - size: 'lg' - }); - }; - $scope.loadSettlementLogs(1); + $scope.getClearingTransactions = function (client_id, detailId) { + clearingDetailService.clientClearingDetail(client_id, detailId, true) + }; }]); app.controller('exchangeRateHistoryDialogCtrl', ['$scope', '$http', '$filter', 'chartParser', function ($scope, $http, $filter, chartParser) { diff --git a/src/main/ui/static/dashboard/templates/partner_dashboard.html b/src/main/ui/static/dashboard/templates/partner_dashboard.html index 91da75b2e..0c5fed6ae 100644 --- a/src/main/ui/static/dashboard/templates/partner_dashboard.html +++ b/src/main/ui/static/dashboard/templates/partner_dashboard.html @@ -192,6 +192,20 @@
+
+
+
+ + +
+
+
@@ -255,14 +269,17 @@
    -
  • Exchange Rate
  • +
  • +

    Exchange Rate

    +
  • {{wechat_rate}}
    - Wechat +

    Wechat

    +
  • {{alipay_rate}}
    - Alipay +

    Alipay

@@ -278,16 +295,20 @@

Customers Analysis

-
    -
  • Last a week
  • -
  • {{time_range}}
  • +
      +
    • +

      Last a week

      +
    • +
    • +

      {time_range}}

      +
    • -

      {{avgOrderAndCustomer.old_customers.toFixed(0)||0}}

      -
      AVG OLD CUSTOMER
      +
      {{avgOrderAndCustomer.old_customers.toFixed(0)||0}}
      +

      Avg Old Customers

    • -

      {{avgOrderAndCustomer.new_customers.toFixed(0)||0}}

      -
      AVG NEW CUSTOME
      +
      {{avgOrderAndCustomer.new_customers.toFixed(0)||0}}
      +

      Avg New Customers

    @@ -348,6 +369,9 @@ + + +