add RP商户类别交易统计

master
luoyang 5 years ago
parent fd0b6c3e1d
commit c403863648

@ -9,7 +9,7 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId> <artifactId>manage</artifactId>
<version>1.4.6</version> <version>1.4.7</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.8.0</jib-maven-plugin.version> <jib-maven-plugin.version>1.8.0</jib-maven-plugin.version>

@ -100,4 +100,12 @@ public interface TransactionAnalysisMapper {
BigDecimal getCnyAmount(JSONObject params); BigDecimal getCnyAmount(JSONObject params);
List<JSONObject> getOneDayOrgMerchantSaleList(JSONObject params); List<JSONObject> getOneDayOrgMerchantSaleList(JSONObject params);
List<JSONObject> getRpIndustryEchartsData(@Param("from") String from, @Param("to") String to, @Param("industry") String industry,
@Param("bd_user") String bdUser);
PageList<JSONObject> getTopRpIndustryData(@Param("transDate") String transDate,
@Param("industry") String industry,
PageBounds pageBounds,
@Param("bd_user") String bdUser);
} }

@ -2,6 +2,9 @@ package au.com.royalpay.payment.manage.dataAnalysis.core;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.text.ParseException;
import java.util.List;
/** /**
* @Author lvjian * @Author lvjian
* @Date 2018/6/28 18:40 * @Date 2018/6/28 18:40
@ -32,4 +35,8 @@ public interface DataAnalysisService {
* @return * @return
*/ */
JSONObject getCnyAmount(JSONObject params, JSONObject response); JSONObject getCnyAmount(JSONObject params, JSONObject response);
List<JSONObject> getRpIndustryEchartsData(String from, String to, String industry,String managerId) throws ParseException;
JSONObject getRpTop20IndustryData(String industry, String transDate, int page, String managerId);
} }

@ -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.ClientAnalysisMapper;
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
import au.com.royalpay.payment.tools.utils.PageListUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; 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 org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.ParseException;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -62,4 +66,17 @@ public class DataAnalysisServiceImpl implements DataAnalysisService {
response.put("cny_amount", transactionAnalysisMapper.getCnyAmount(params)); response.put("cny_amount", transactionAnalysisMapper.getCnyAmount(params));
return response; return response;
} }
@Override
public List<JSONObject> 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<JSONObject> logs = transactionAnalysisMapper.getTopRpIndustryData(transDate, industry,
new PageBounds(page, 20), managerId);
return PageListUtils.buildPageListResult(logs);
}
} }

@ -1,16 +1,18 @@
package au.com.royalpay.payment.manage.dev.web; package au.com.royalpay.payment.manage.dev.web;
import au.com.royalpay.payment.manage.analysis.core.BDAnalysisService; 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.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List;
@RestController @RestController
@RequestMapping("/analysis") @RequestMapping("/analysis")
@ -18,6 +20,8 @@ public class AnalysisController {
@Resource @Resource
private BDAnalysisService bdAnalysisService; private BDAnalysisService bdAnalysisService;
@Resource
private DataAnalysisService dataAnalysisService;
@GetMapping("/report/bd/sales") @GetMapping("/report/bd/sales")
@ -25,4 +29,27 @@ public class AnalysisController {
Date newDate = new SimpleDateFormat("yyyy-MM-dd").parse(date); Date newDate = new SimpleDateFormat("yyyy-MM-dd").parse(date);
bdAnalysisService.generateReport(DateFormatUtils.format(newDate, "yyyy-MM-dd")); bdAnalysisService.generateReport(DateFormatUtils.format(newDate, "yyyy-MM-dd"));
} }
@GetMapping("/rp_industry/echarts")
public List<JSONObject> 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);
}
} }

@ -1084,5 +1084,80 @@
org.org_id org.org_id
</select> </select>
<!-- <select id="getRpIndustryEchartsData" resultType="com.alibaba.fastjson.JSONObject">-->
<!-- SELECT-->
<!-- DATE_FORMAT( t.transaction_time, '%Y-%m-%d' ) AS trans_date,-->
<!-- nullif( sum( IF ( t.transaction_type = 'Credit', t.clearing_amount,- t.clearing_amount ) ), 0 ) AS total_amount,-->
<!-- nullif( COUNT( DISTINCT t.order_id, IF ( t.transaction_type = 'Credit', TRUE, NULL ) ), 0 ) AS orders-->
<!-- FROM-->
<!-- pmt_transactions t-->
<!-- <if test="industry != null and industry!=0">-->
<!-- <bind name="industry" value="industry+'%'"/>-->
<!-- INNER JOIN sys_clients c ON c.client_id = t.client_id-->
<!-- AND c.is_valid = 1-->
<!-- AND c.royalpayindustry like #{industry}-->
<!-- </if>-->
<!-- WHERE-->
<!-- t.transaction_time >= #{from}-->
<!-- AND t.transaction_time &lt; #{to}-->
<!-- AND t.channel != 'Settlement'-->
<!-- AND t.channel != 'System'-->
<!-- AND t.system_generate = 0-->
<!-- GROUP BY-->
<!-- trans_date-->
<!-- </select>-->
<select id="getRpIndustryEchartsData" resultType="com.alibaba.fastjson.JSONObject">
SELECT
sum(so.total) as total_amount,
sum(so.orders) as orders,
DATE_FORMAT(so.date, '%Y-%m-%d' ) as trans_date
FROM
statistics_customer_order so
inner JOIN sys_clients c ON so.client_id = c.client_id
AND c.is_valid = 1
<if test="industry != null and industry!=0">
<bind name="industry" value="industry+'%'"/>
AND c.royalpayindustry like #{industry}
</if>
and so.date >= #{from}
and so.date &lt; #{to}
and so.client_id!=0
<if test="bd_user!=null">
INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and
(d.end_date is null or date(d.end_date)&gt;= now()) and
d.is_valid=1
</if>
GROUP BY
trans_date
order by trans_date asc
</select>
<select id="getTopRpIndustryData" resultType="com.alibaba.fastjson.JSONObject">
SELECT
sum(so.total) as total_amount,
sum(so.orders) as orders,
DATE_FORMAT(so.date, '%Y-%m-%d' ) as trans_date,
c.client_moniker,
c.short_name
FROM
statistics_customer_order so
inner JOIN sys_clients c ON so.client_id = c.client_id
AND c.is_valid = 1
<if test="industry != null and industry!=0">
<bind name="industry" value="industry+'%'"/>
AND c.royalpayindustry like #{industry}
</if>
and so.date= #{transDate}
and so.client_id!=0
<if test="bd_user!=null">
INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and
(d.end_date is null or date(d.end_date)&gt;= now()) and
d.is_valid=1
</if>
GROUP BY
so.client_id
order by total_amount desc
</select>
</mapper> </mapper>

@ -385,6 +385,11 @@ margin-bottom: 10%;"/>
<i class="fa fa-area-chart"></i> <span>CBBank渠道交易统计</span> <i class="fa fa-area-chart"></i> <span>CBBank渠道交易统计</span>
</a> </a>
</li> </li>
<li ui-sref-active="active" ng-if="(currentUser.org_id==null || currentUser.org_id==1)">
<a ui-sref="analysis_industry" ui-sref-opts="{reload:true}">
<i class="fa fa-area-chart"></i> <span>RP商户类别交易统计</span>
</a>
</li>
</ul> </ul>
</li> </li>

@ -22,6 +22,10 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts'], function (angul
url: '/cbbanktrans_analysis', url: '/cbbanktrans_analysis',
templateUrl: '/static/analysis/templates/cbbank_channel_trans_analysis.html', templateUrl: '/static/analysis/templates/cbbank_channel_trans_analysis.html',
controller: 'cbbankTransAnalysisCtrl' 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(); $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; return app;
}); });

@ -0,0 +1,155 @@
<style>
.cen table {
text-align: center;
}
.cen table th {
text-align: center;
}
</style>
<section class="content">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li ui-sref-active="active">
<a style="font-size: 30px;">RP商户类别交易趋势统计</a>
</li>
</ul>
<div class="tab-content">
<div class="row">
<div class="col-sm-12">
<div class="box box-warning">
<div class="box-header">
<div class="form-horizontal">
<div class="form-group col-xs-12">
<label class="control-label col-xs-4 col-sm-2">Date Range</label>
<div class="col-sm-10">
<div class="form-control-static form-inline">
<div style="display: inline-block">
<input class="form-control" id="date-from-input" ng-model="params.from"
uib-datepicker-popup size="15" placeholder="From"
is-open="dateBegin.open" ng-click="dateBegin.open=true"
datepicker-options="{maxDate:params.end}">
</div>
<div style="display: inline-block;margin: 0 10px;">
~
</div>
<div style="display: inline-block">
<input class="form-control" id="date-to-input" ng-model="params.to"
uib-datepicker-popup size="15" placeholder="To"
is-open="dateTo.open" ng-click="dateTo.open=true"
datepicker-options="{minDate:params.begin,maxDate:today}">
</div>
<div style="display: inline-block">
<input style="margin-left: 20px;"
class="form-control" id="royalpayindustry"
name="royalpayindustry" readonly
ng-value="params.industry|partner_royalpay_industry"
multi-level-select-popup="royalpayindustry"
on-select="onRoyalPayIndustrySelect($selected)"
chose-one-level="true">
</div>
</div>
<div class="form-control-static form-inline">
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm"
ng-click="chooseToday()">Today</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm"
ng-click="chooseYesterday()">Yesterday</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm"
ng-click="chooseLast7Days()">Last 7 Days</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm" ng-click="thisMonth()">This
Month</a>
</div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm" ng-click="lastMonth()">Last
Month</a>
</div>
<button class="btn btn-success" type="button" ng-click="doAnalysis()">
<i class="fa fa-search"></i>
</button>
</div>
</div>
</div>
<div class="col-xs-12" style="text-align: center">
<loadingbar ng-if="future_loading"></loadingbar>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row cen">
<div class="col-sm-12">
<div class="box">
<div class="box-header with-border">
<span style="font-weight: 900;" ng-if="params.royalpay_label">[{{params.royalpay_label}}]</span>
行业总交易量</div>
<div class="box-body">
<div class="chart" echarts="amountAnalysis" style="height: 300px"
chart-setter="choseDayEchart($chart)"
ng-class="{nodata:amountAnalysis.nodata}"></div>
<div class="chart" echarts="ordersAnalysis" style="height: 300px"
chart-setter="choseDayEchart($chart)"
ng-class="{nodata:ordersAnalysis.nodata}"></div>
</div>
</div>
</div>
</div>
<div class="row cen" ng-if="chooseDay">
<div class="col-sm-12">
<div class="box">
<div class="box-header with-border">
[<span style="font-weight: 900;">{{chooseDay}}{{params.royalpay_label}}</span>]
行业Top交易额商户列表</div>
<div class="box-body">
<div class="box-body table-responsive">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Client Moniker</th>
<th>Short Name</th>
<th>Total Amount</th>
<th>Orders</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="partner in partners">
<td ng-bind="partner.client_moniker"></td>
<td ng-bind="partner.short_name"></td>
<td ng-bind="partner.total_amount|currency:''"></td>
<td ng-bind="partner.orders"></td>
</tr>
</tbody>
</table>
</div>
<div class="box-footer">
<uib-pagination class="pagination"
total-items="pagination.totalCount"
boundary-links="true"
ng-model="pagination.page"
items-per-page="pagination.limit"
max-size="10"
ng-change="loadTopTransPartners()"
previous-text="&lsaquo;"
next-text="&rsaquo;"
first-text="&laquo;"
last-text="&raquo;"></uib-pagination>
<div class="row">
<div class="col-xs-12">Total Records:{{pagination.totalCount}};Total Pages:{{pagination.totalPages}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>

@ -203,6 +203,16 @@
</div> </div>
</a> </a>
</div> </div>
<div ng-if="(currentUser.org_id==null || currentUser.org_id==1)" class="col-sm-2 col-xs-6">
<a ui-sref="analysis_industry" ui-sref-opts="{reload:true}">
<div class="description-block">
<img src="/static/images/main_menu/transaction_original_statistics.png"/>
<div class="description-text">
<span class="description-text">RP商户类别交易统计</span>
</div>
</div>
</a>
</div>
</div> </div>
</div> </div>
<div class="list-group" ng-if="role=='riskmanager'"> <div class="list-group" ng-if="role=='riskmanager'">

Loading…
Cancel
Save