diff --git a/pom.xml b/pom.xml index 40cde2909..48f1995eb 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 manage - 1.4.6 + 1.4.7 UTF-8 1.8.0 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 3be3a6e55..ec639acad 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 @@ -100,4 +100,12 @@ public interface TransactionAnalysisMapper { BigDecimal getCnyAmount(JSONObject params); List getOneDayOrgMerchantSaleList(JSONObject params); + + List getRpIndustryEchartsData(@Param("from") String from, @Param("to") String to, @Param("industry") String industry, + @Param("bd_user") String bdUser); + + PageList getTopRpIndustryData(@Param("transDate") String transDate, + @Param("industry") String industry, + PageBounds pageBounds, + @Param("bd_user") String bdUser); } diff --git a/src/main/java/au/com/royalpay/payment/manage/dataAnalysis/core/DataAnalysisService.java b/src/main/java/au/com/royalpay/payment/manage/dataAnalysis/core/DataAnalysisService.java index 2097387e8..224e0fe68 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dataAnalysis/core/DataAnalysisService.java +++ b/src/main/java/au/com/royalpay/payment/manage/dataAnalysis/core/DataAnalysisService.java @@ -2,6 +2,9 @@ package au.com.royalpay.payment.manage.dataAnalysis.core; import com.alibaba.fastjson.JSONObject; +import java.text.ParseException; +import java.util.List; + /** * @Author lvjian * @Date 2018/6/28 18:40 @@ -32,4 +35,8 @@ public interface DataAnalysisService { * @return */ JSONObject getCnyAmount(JSONObject params, JSONObject response); + + List getRpIndustryEchartsData(String from, String to, String industry,String managerId) throws ParseException; + + JSONObject getRpTop20IndustryData(String industry, String transDate, int page, String managerId); } diff --git a/src/main/java/au/com/royalpay/payment/manage/dataAnalysis/core/DataAnalysisServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/dataAnalysis/core/DataAnalysisServiceImpl.java index 96f7ec5ca..bd1784484 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dataAnalysis/core/DataAnalysisServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/dataAnalysis/core/DataAnalysisServiceImpl.java @@ -2,13 +2,17 @@ package au.com.royalpay.payment.manage.dataAnalysis.core; import au.com.royalpay.payment.manage.analysis.mappers.ClientAnalysisMapper; import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; +import au.com.royalpay.payment.tools.utils.PageListUtils; import com.alibaba.fastjson.JSONObject; -import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; -import org.springframework.beans.factory.annotation.Autowired; +import com.github.miemiedev.mybatis.paginator.domain.PageList; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.commons.lang3.time.DateUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.text.ParseException; +import java.util.Date; import java.util.List; /** @@ -62,4 +66,17 @@ public class DataAnalysisServiceImpl implements DataAnalysisService { response.put("cny_amount", transactionAnalysisMapper.getCnyAmount(params)); return response; } + + @Override + public List getRpIndustryEchartsData(String from, String to, String industry, String managerId) throws ParseException { + Date modifyTo = DateUtils.addDays(DateUtils.parseDate(to, "yyyy-MM-dd"), 1); + return transactionAnalysisMapper.getRpIndustryEchartsData(from, DateFormatUtils.format(modifyTo, "yyyy-MM-dd HH:mm:ss"), industry, managerId); + } + + @Override + public JSONObject getRpTop20IndustryData(String industry, String transDate, int page, String managerId) { + PageList logs = transactionAnalysisMapper.getTopRpIndustryData(transDate, industry, + new PageBounds(page, 20), managerId); + return PageListUtils.buildPageListResult(logs); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/dev/web/AnalysisController.java b/src/main/java/au/com/royalpay/payment/manage/dev/web/AnalysisController.java index 46216c5b4..09c22c963 100644 --- a/src/main/java/au/com/royalpay/payment/manage/dev/web/AnalysisController.java +++ b/src/main/java/au/com/royalpay/payment/manage/dev/web/AnalysisController.java @@ -1,16 +1,18 @@ package au.com.royalpay.payment.manage.dev.web; import au.com.royalpay.payment.manage.analysis.core.BDAnalysisService; +import au.com.royalpay.payment.manage.dataAnalysis.core.DataAnalysisService; +import au.com.royalpay.payment.tools.CommonConsts; +import au.com.royalpay.payment.tools.permission.enums.ManagerRole; +import com.alibaba.fastjson.JSONObject; import org.apache.commons.lang3.time.DateFormatUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.List; @RestController @RequestMapping("/analysis") @@ -18,6 +20,8 @@ public class AnalysisController { @Resource private BDAnalysisService bdAnalysisService; + @Resource + private DataAnalysisService dataAnalysisService; @GetMapping("/report/bd/sales") @@ -25,4 +29,27 @@ public class AnalysisController { Date newDate = new SimpleDateFormat("yyyy-MM-dd").parse(date); bdAnalysisService.generateReport(DateFormatUtils.format(newDate, "yyyy-MM-dd")); } + + @GetMapping("/rp_industry/echarts") + public List rpIndustryEchartsData(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, + @RequestParam("from") String from, + @RequestParam("to") String to, + @RequestParam(value = "industry",defaultValue = "0") String industry) throws ParseException{ + String managerId = null; + if (ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))) { + managerId = manager.getString("manager_id"); + } + return dataAnalysisService.getRpIndustryEchartsData(from, to, industry, managerId); + } + + @GetMapping("/rp_industry/top_data") + public JSONObject rpTop20IndustryData(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestParam(value = "industry", defaultValue = "0") String industry, + @RequestParam("trans_date") String transDate, + @RequestParam("page") int page) { + String managerId = null; + if (ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))) { + managerId = manager.getString("manager_id"); + } + return dataAnalysisService.getRpTop20IndustryData(industry, transDate, page, managerId); + } } 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 c71b6d2ae..3506f47a6 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 @@ -1084,5 +1084,80 @@ org.org_id + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/ui/manage.html b/src/main/ui/manage.html index 6f9ec83f5..98c17f388 100644 --- a/src/main/ui/manage.html +++ b/src/main/ui/manage.html @@ -385,6 +385,11 @@ margin-bottom: 10%;"/> CBBank渠道交易统计 +
  • + + RP商户类别交易统计 + +
  • diff --git a/src/main/ui/static/analysis/transaction/analysis-transaction.js b/src/main/ui/static/analysis/transaction/analysis-transaction.js index 739a83e05..afee22de4 100644 --- a/src/main/ui/static/analysis/transaction/analysis-transaction.js +++ b/src/main/ui/static/analysis/transaction/analysis-transaction.js @@ -22,6 +22,10 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts'], function (angul url: '/cbbanktrans_analysis', templateUrl: '/static/analysis/templates/cbbank_channel_trans_analysis.html', controller: 'cbbankTransAnalysisCtrl' + }).state('analysis_industry', { + url: '/analysis/transaction/industry', + templateUrl: '/static/analysis/transaction/templates/industry_analysis_transaction.html', + controller: 'industryTransCtrl' }) }]); @@ -437,5 +441,165 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts'], function (angul }; $scope.chooseLast7Days(); }]); + app.controller('industryTransCtrl', ['$scope', '$http', '$filter', 'chartParser', function ($scope, $http, $filter, chartParser) { + $scope.params = {industry: 0}; + $scope.today = new Date(); + $scope.pagination = {limit:20}; + + $scope.loadRoyalpayindustry = function () { + $http.get('/static/data/royalpayindustry.json').then(function (resp) { + $scope.royalpayindustry = resp.data; + var selectAll = { + "label": "All", + "mccCode": "0", + "children":{} + }; + $scope.royalpayindustry.unshift(selectAll); + }) + }; + + $scope.loadRoyalpayindustry(); + + $scope.onRoyalPayIndustrySelect = function (selectedItem) { + $scope.params.royalpay_label = selectedItem.label; + $scope.params.industry = selectedItem.mccCode; + $scope.doAnalysis(); + }; + + $scope.chooseToday = function () { + $scope.params.from = $scope.params.to = new Date(); + $scope.doAnalysis(); + }; + $scope.chooseYesterday = function () { + var yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + $scope.params.from = $scope.params.to = yesterday; + $scope.doAnalysis(); + }; + $scope.chooseLast7Days = function () { + $scope.params.to = new Date(); + var day = new Date(); + day.setDate(day.getDate() - 7); + $scope.params.from = day; + $scope.doAnalysis(); + }; + $scope.thisMonth = function () { + $scope.params.to = new Date(); + var monthBegin = new Date(); + monthBegin.setDate(1); + $scope.params.from = monthBegin; + $scope.doAnalysis(); + }; + $scope.lastMonth = function () { + var monthFinish = new Date(); + monthFinish.setDate(0); + $scope.params.to = monthFinish; + var monthBegin = new Date(); + monthBegin.setDate(0); + monthBegin.setDate(1); + $scope.params.from = monthBegin; + $scope.doAnalysis(); + }; + var amountAnalysis = { + chart: { + tooltip: { + trigger: 'axis', + formatter: '{b}:AUD {c}' + }, + yAxis: { + type: 'value', + name: '交易金额(AUD)' + }, + color: colors + }, + xAxis: { + basic: { + type: 'category', + boundaryGap: false + }, + key: 'trans_date' + }, + series: [ + { + basic: {type: 'line', label: {normal: {show: true}}, showAllSymbols: true}, + column: {key: 'total_amount'} + } + ] + }; + var ordersAnalysis = { + chart: { + tooltip: { + trigger: 'axis', + formatter: '{b}:AUD {c}' + }, + yAxis: { + type: 'value', + name: '订单数' + }, + color: colors + }, + xAxis: { + basic: { + type: 'category', + boundaryGap: false + }, + key: 'trans_date' + }, + series: [ + { + basic: {type: 'line', label: {normal: {show: true}}, showAllSymbols: true}, + column: {key: 'orders'} + } + ] + }; + + $scope.doAnalysis = function () { + $scope.future_loading = true; + var params = angular.copy($scope.params); + if (params.from) { + params.from = $filter('date')(params.from, 'yyyy-MM-dd'); + } + if (params.to) { + params.to = $filter('date')(params.to, 'yyyy-MM-dd'); + } + delete params.royalpay_label; + $http.get('/analysis/rp_industry/echarts', {params: params}).then(function (resp) { + $scope.analysisData = resp.data; + $scope.amountAnalysis = chartParser.parse(amountAnalysis, resp.data); + $scope.ordersAnalysis = chartParser.parse(ordersAnalysis, resp.data); + $scope.future_loading = false; + $scope.chooseDay = $filter('date')($scope.params.from, 'yyyy-MM-dd'); + $scope.loadTopTransPartners(1); + }); + + }; + $scope.thisMonth(); + $scope.loadTopTransPartners = function (page) { + var requestParams = angular.copy($scope.params); + if (requestParams.from) { + requestParams.from = $filter('date')(requestParams.from, 'yyyy-MM-dd'); + } + if (requestParams.to) { + requestParams.to = $filter('date')(requestParams.to, 'yyyy-MM-dd'); + } + requestParams.trans_date = $scope.chooseDay || requestParams.from; + requestParams.page = page || $scope.pagination.page || 1; + $http.get('/analysis/rp_industry/top_data', {params: requestParams}).then(function (resp) { + $scope.pagination = resp.data.pagination; + $scope.partners = resp.data.data; + }); + }; + + $scope.choseDayEchart = function (chart) { + chart.on('click', function (params) { + var trans_date = $scope.analysisData[params.dataIndex].trans_date; + $scope.chooseDay = trans_date; + $scope.loadTopTransPartners(1); + }) + }; + + + + }]); return app; -}); \ No newline at end of file +}); diff --git a/src/main/ui/static/analysis/transaction/templates/industry_analysis_transaction.html b/src/main/ui/static/analysis/transaction/templates/industry_analysis_transaction.html new file mode 100644 index 000000000..d39e4ceb4 --- /dev/null +++ b/src/main/ui/static/analysis/transaction/templates/industry_analysis_transaction.html @@ -0,0 +1,155 @@ + +
    + +
    diff --git a/src/main/ui/static/menu/templates/main_menu.html b/src/main/ui/static/menu/templates/main_menu.html index 55788bdfd..c9325827b 100644 --- a/src/main/ui/static/menu/templates/main_menu.html +++ b/src/main/ui/static/menu/templates/main_menu.html @@ -203,6 +203,16 @@ +