master
yuan 7 years ago
parent d367f9c615
commit e28adf6a23

@ -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<JSONObject> 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<JSONObject> 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){

@ -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);
}
}

@ -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
<if test="client_id !=null ">
s.client_id = #{client_id}
<where>
<if test="client_ids!=null">
AND s.client_id IN
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
#{client_id}
</foreach>
</if>
<if test="client_ids==null and client_id!= null">
and s.client_id=#{client_id}
</if>
<if test="begin!=null">and s.date &gt;= #{begin}</if>
<if test="end!=null">and s.date &lt; #{end}</if>
</where>
</select>

@ -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)
]]>
<if test="client_id!=null">AND l.client_id = #{client_id}</if>
<if test="client_ids!=null">
AND l.client_id IN
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
#{client_id}
</foreach>
</if>
<if test="client_ids==null and client_id != null">
and l.client_id=#{client_id}
</if>
<if test="begin!=null">and o.create_time &gt;= #{begin}</if>
<if test="end!=null">and o.create_time &lt;= #{end}</if>
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>

@ -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;
}

@ -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) {

@ -192,6 +192,20 @@
</section>
<section class="content">
<div class="row">
<div class="row margin-bottom">
<div class="col-sm-12">
<div class="btn-group pull-right" uib-dropdown ng-if="currentUser.client.has_children" style="padding-right: 15px">
<button id="single-button" type="button" class="btn btn-default" style="min-width: 100px"
uib-dropdown-toggle ng-disabled="disabled">
{{chooseShow}} <span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu aria-labelledby="single-button" style="min-width: 80px">
<li><a ng-click="chooseClient('All')">All</a></li>
<li ng-repeat="client in clients"><a ng-click="chooseClient(client)">{{client.short_name}}</a></li>
</ul>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="mini-stat clearfix bg-white">
<span class="mini-stat-icon bg-light"><i class="ion ion-social-usd text-danger"></i></span>
@ -255,14 +269,17 @@
<ul class="list-inline widget-chart m-t-20 text-center"
ng-click="displayExchangeRateHistory()"
role="button" title="Click it,Display Exchange Rate History.">
<li><b>Exchange Rate</b></li>
<li>
<p class="text-muted m-b-0"><b>Exchange Rate</b></p>
</li>
<li>
<h6 class=""><b>{{wechat_rate}}</b></h6>
<img src="/static/images/wechatpay_sign.png"/> Wechat
<p class="text-muted m-b-0"><img src="/static/images/wechatpay_sign.png"/> Wechat</p>
</li>
<li>
<h6 class=""><b>{{alipay_rate}}</b></h6>
<img src="/static/images/alipay_sign.png"/> Alipay
<p class="text-muted m-b-0"> <img src="/static/images/alipay_sign.png"/> Alipay</p>
</li>
</ul>
<div class="box-body">
@ -278,16 +295,20 @@
<div class="card-body">
<h4 class="mt-0 header-title">Customers Analysis</h4>
<ul class="list-inline widget-chart m-t-20 text-center">
<li ng-if="!time_range">Last a week</li>
<li ng-if="time_range">{{time_range}}</li>
<ul class="list-inline widget-chart m-t-20 text-center di_flex">
<li ng-if="!time_range">
<p class="text-muted m-b-0"><b>Last a week</b></p>
</li>
<li ng-if="time_range">
<p class="text-muted m-b-0"><b>{time_range}}</b></p>
</li>
<li>
<p class="text-muted m-b-0">{{avgOrderAndCustomer.old_customers.toFixed(0)||0}}</p>
<h6 class=""><b>AVG OLD CUSTOMER</b></h6>
<h6 class="">{{avgOrderAndCustomer.old_customers.toFixed(0)||0}}</h6>
<p class="text-muted m-b-0"><b>Avg Old Customers</b></p>
</li>
<li>
<p class="text-muted m-b-0">{{avgOrderAndCustomer.new_customers.toFixed(0)||0}}</p>
<h6 class=""><b>AVG NEW CUSTOME</b></h6>
<h6 class="">{{avgOrderAndCustomer.new_customers.toFixed(0)||0}}</h6>
<p class="text-muted m-b-0"><b>Avg New Customers</b></p>
</li>
</ul>
<div class="row">
@ -348,6 +369,9 @@
<a role="button" class="text-bold" ng-if="(log.clearing_time|limitTo:10) >= '2017-01-12'" ng-click="getClearingTransactions(log.client_id,log.clear_detail_id)" title="Detail">
<i class="fa fa-list-alt"></i>
</a>
<a ng-href="/client/clean_logs/{{currentUser.client.client_id}}/settlement_logs/{{log.clear_detail_id}}/export" target="_blank" ng-if="(log.clearing_time|limitTo:10) >= '2017-01-12'" title="Download">
<i class="fa fa-download"></i>
</a>
</td>
</tr>
</tbody>

Loading…
Cancel
Save