fix partner dashboard

master
yuan 7 years ago
parent fbae009d06
commit 33b3795a58

@ -50,4 +50,8 @@ public interface DashboardService {
void generateCustomersAndOrdersStatistics(Date analysisDate);
JSONObject getOrderAndCustomerPerDay(JSONObject partner,AnalysisBean partnerAnalysisBean);
List<JSONObject> getStatisticsCustomersAndOrdersInDays(JSONObject partner, AnalysisBean partnerAnalysisBean);
}

@ -7,6 +7,7 @@ import au.com.royalpay.payment.manage.analysis.core.DashboardService;
import au.com.royalpay.payment.manage.analysis.mappers.ClientAnalysisMapper;
import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper;
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.ExchangeRateMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
@ -16,6 +17,7 @@ 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.PageList;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.slf4j.Logger;
@ -55,6 +57,11 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
@Resource
private ExchangeRateMapper exchangeRateMapper;
@Resource
private TransactionMapper transactionMapper;
@Override
public JSONObject getCommonAnalysis1(JSONObject params) {
JSONObject res = transactionAnalysisMapper.getClientTransaction(params);
@ -237,10 +244,17 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
params.put("end",DateUtils.addDays(params.getDate("end"),-1));
JSONObject yes = getTransJSONO(params);
res.put("today",today);
BigDecimal not_settled = new BigDecimal(transactionAnalysisMapper.analysisNotSettled(params));
res.put("not_settled", not_settled);
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")));
BigDecimal latest_settle = logs.isEmpty()?BigDecimal.ZERO:logs.get(0).getBigDecimal("income");
res.put("latest_settle",latest_settle);
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("new_customers_rise", yes.getIntValue("new_customers") > 0 ? (today.getIntValue("new_customers")-yes.getIntValue("new_customers"))/yes.getIntValue("new_customers") : 0);
res.put("not_settled_rise",yes.getBigDecimal("not_settled").compareTo(BigDecimal.ZERO)>0 ? (today.getBigDecimal("not_settled").subtract(yes.getBigDecimal("not_settled"))).divide(yes.getBigDecimal("not_settled"),4):BigDecimal.ZERO);
res.put("not_settled_rise",not_settled.compareTo(BigDecimal.ZERO)>0 ? (not_settled.subtract(latest_settle)).divide(latest_settle,4):BigDecimal.ZERO);
res.put("yes",yes);
return res;
}
@ -249,7 +263,6 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
JSONObject object = transactionAnalysisMapper.getClientTransaction(params);
res.put("trade_amount", object.getBigDecimal("trade_amount"));
res.put("trade_count", object.getIntValue("trade_count"));
res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params));
res.put("new_customers", transactionAnalysisMapper.countNewCustomers(params));
return res;
}
@ -463,4 +476,32 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
resp.put("aliOnline_order_count",transactionAnalysisMapper.getPlatformAmount(params).getIntValue("order_count"));
return resp;
}
@Override
public JSONObject getOrderAndCustomerPerDay(JSONObject partner, AnalysisBean partnerAnalysisBean) {
String timezone = partner.getJSONObject("client").getString("timezone");
JSONObject params = partnerAnalysisBean.toParams(timezone);
try {
clientManager.validateClients(partner.getIntValue("client_id"), params);
} catch (Exception e) {
logger.error("Dashboard analysis request including not permission client_id");
params.remove("client_ids");
}
params.put("client_id", partner.getIntValue("client_id"));
return customerAndOrdersStatisticsMapper.getAvgOrderAndCustomerStatistics(params);
}
@Override
public List<JSONObject> getStatisticsCustomersAndOrdersInDays(JSONObject partner, AnalysisBean partnerAnalysisBean) {
String timezone = partner.getJSONObject("client").getString("timezone");
JSONObject params = partnerAnalysisBean.toParams(timezone);
try {
clientManager.validateClients(partner.getIntValue("client_id"), params);
} catch (Exception e) {
logger.error("Dashboard analysis request including not permission client_id");
params.remove("client_ids");
}
params.put("client_id", partner.getIntValue("client_id"));
return customerAndOrdersStatisticsMapper.getPartnerCustomerAndOrderStatistics(params);
}
}

@ -42,19 +42,13 @@ public class PartnerDashboardController {
@PartnerMapping("/fee_analysis")
public List<JSONObject> tradeInDays(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner,AnalysisBean partnerAnalysisBean) {
return dashboardService.getTradeAnalysisInDays(partner,partnerAnalysisBean);
return dashboardService.getStatisticsCustomersAndOrdersInDays(partner,partnerAnalysisBean);
}
@PartnerMapping("/customers")
public List<JSONObject> customersInDays(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner,AnalysisBean partnerAnalysisBean) {
return dashboardService.getCustomersAndOrdersInDays(partner,partnerAnalysisBean);
}
@PartnerMapping("/trans_common")
public JSONObject transCommon(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, AnalysisBean partnerAnalysisBean) {
return dashboardService.getCommonAnalysis(partner,partnerAnalysisBean);
}
@PartnerMapping("/trans_type_analysis")
public List<JSONObject> getTransTypesAnalysis(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner,AnalysisBean partnerAnalysisBean) {
JSONObject params = partnerAnalysisBean.toParams("timezone");
@ -62,9 +56,9 @@ public class PartnerDashboardController {
return dashboardService.getTradeInTypes(params);
}
@PartnerMapping("{client_moniker}/avg_order_customer")
public JSONObject getAvgOrderAndCustomer(@PathVariable String client_moniker, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner) {
return partnerCardDashboardService.getOrderAndCustomerPerDay(client_moniker);
@PartnerMapping("/avg_order_customer")
public JSONObject getAvgOrderAndCustomer(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner,AnalysisBean partnerAnalysisBean) {
return dashboardService.getOrderAndCustomerPerDay(partner,partnerAnalysisBean);
}
@PartnerMapping("{client_moniker}/settlement_logs")

@ -192,9 +192,14 @@
<![CDATA[
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 where client_id = #{client_id}
FROM statistics_customer_order s
]]>
where
<if test="client_id !=null ">
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>
</select>

@ -643,14 +643,13 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct
$scope.clientMoniker = $scope.currentUser.client_moniker;
$scope.loadDashboard = function () {
loadTransCommon();
getAvgOrderAndCustomer();
getExchangeRate();
};
$scope.loadDashboard();
function loadTransCommon() {
var params = {begin: $filter('date')(new Date(), 'yyyyMMdd'), end: $filter('date')(new Date(), 'yyyyMMdd')};
$http.get('/dashboard/partner/trans_common',{params:params}).then(function (resp) {
$http.get('/dashboard/partner/common_analysis',{params:params}).then(function (resp) {
$scope.transcommon = resp.data;
});
}
@ -716,11 +715,6 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct
});
}
loadTradeAmountInTypes($scope.scales[2].params());
function getAvgOrderAndCustomer() {
$http.get('/dashboard/partner/' + $scope.clientMoniker + '/avg_order_customer').then(function (resp) {
$scope.avgOrderAndCustomer = resp.data;
});
}
function loadFeeAnalysis(params) {
@ -767,12 +761,12 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct
type: 'category',
boundaryGap: false
},
key: 'date_str'
key: 'date'
},
series: [
{
basic: {type: 'line', label: {normal: {show: true}}, showAllSymbols: true},
column: {key: 'aud_fee'}
column: {key: 'total'}
}
]
};
@ -783,6 +777,9 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct
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) {
var dates = [];
var new_customers = [];
@ -817,6 +814,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 () {
$scope.time_range = "Last a week";
getOrderCustomerChartAnalysis($scope.scales[2].params())
}
},
@ -830,6 +828,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');
$scope.time_range = "Last a month";
getOrderCustomerChartAnalysis(params)
}
}
@ -1060,9 +1059,26 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct
})
}
loadTradeTimeAnalysis($scope.scales[4].params());*/
$scope.displayExchangeRateHistory = function () {
$uibModal.open({
templateUrl: '/static/dashboard/templates/exchange_rate_history_dialog.html',
controller: 'exchangeRateHistoryDialogCtrl',
size: 'lg'
})
};
$scope.getCurrentPartner = function () {
$http.get('/client/partner_info').then(function (resp) {
$scope.manual_settle = resp.data.manual_settle;
})
};
$scope.getCurrentPartner();
$scope.toShowUnSettledDialog = function () {
$uibModal.open({
templateUrl: '/static/dashboard/templates/partner_dashboard_unsettled_dialog.html',
controller: 'unSettledAmountHistoryDialogCtrl'
})
};
$scope.loadSettlementLogs = function (page) {
var params = angular.copy($scope.params);
params.page = page || $scope.pagination.page || 1;
@ -1088,6 +1104,184 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct
}]);
app.controller('exchangeRateHistoryDialogCtrl', ['$scope', '$http', '$filter', 'chartParser', function ($scope, $http, $filter, chartParser) {
$scope.loadExchangeRateHistory = function (days) {
var endDate = new Date();
var startDate = new Date();
startDate.setDate(startDate.getDate() - days);
$http.get('/dashboard/system/exchange_rates', {
params: {
begin: $filter('date')(startDate, 'yyyyMMdd'),
end: $filter('date')(endDate, 'yyyyMMdd')
}
}).then(function (resp) {
handleRateHistoryChart(resp.data);
})
};
$scope.loadExchangeRateHistory(7);
var rateHistoryConfig = {
chart: {
tooltip: {
trigger: 'axis',
},
toolbox: {
show: true,
feature: {
mySeven: {
title: 'Last 7 Days',
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 () {
$scope.loadExchangeRateHistory(7)
}
},
myThirty: {
title: 'Last 30 Days',
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 () {
$scope.loadExchangeRateHistory(30)
}
}
}
},
legend: {
data: ['Wechat', 'Alipay'],
bottom: 0,
height: '15%',
width: '80%',
left: '10%'
},
yAxis: {
type: 'value',
name: 'Exchange Rate',
min: 'auto'
}
},
xAxis: {
basic: {
type: 'category',
boundaryGap: false
},
key: 'date'
},
series: [
{
basic: {
name: 'Wechat',
type: 'line',
label: {normal: {show: true}},
showAllSymbols: true,
showSymbol: true,
yAxisIndex: 0,
itemStyle : {
normal : {
color:'#09bb07',
lineStyle:{
color:'#09bb07'
}
}
}
},
column: {key: 'Wechat.exchange_rate'}
},
{
basic: {
name: 'Alipay',
type: 'line',
label: {normal: {show: true}},
showAllSymbols: true,
showSymbol: true,
yAxisIndex: 0,
itemStyle : {
normal : {
color:'#00c0ef',
lineStyle:{
color:'#00c0ef'
}
}
}
},
column: {key: 'Alipay.exchange_rate'}
}
]
};
function handleRateHistoryChart(exchangeRates) {
$scope.rateHistory = chartParser.parse(rateHistoryConfig, exchangeRates);
}
}]);
app.controller('unSettledAmountHistoryDialogCtrl', ['$scope', '$http', '$filter','commonDialog', function ($scope, $http, $filter,commonDialog) {
$scope.params = {isAll:true};
$scope.settleParams = {};
$scope.unSettledAmountHistory = function () {
$http.get('/client/manual_settle/today').then(function (resp) {
$scope.currentSettle = resp.data;
$scope.settleParams = angular.copy($scope.currentSettle);
if($scope.currentSettle.settle_to){
$scope.params.isAll = false;
$scope.params.to_date = new Date($scope.currentSettle.settle_to);
}
$scope.params.maxData = $scope.currentSettle.unsettle[0].date_str;
})
};
$scope.unSettledAmountHistory();
$scope.changeIsAll = function () {
if($scope.params.isAll){
$scope.params.to_date = '';
$scope.settleParams = angular.copy($scope.currentSettle);
}else {
if($scope.currentSettle.settle_to){
$scope.params.to_date = new Date($scope.currentSettle.settle_to);
}else{
$scope.params.to_date = $scope.params.maxData;
}
}
};
$scope.$watch('params.to_date', function() {
$scope.settleParams = angular.copy($scope.currentSettle);
if($scope.params.to_date){
$scope.params.isAll=false;
$scope.to_date = $filter('date')($scope.params.to_date, 'yyyy-MM-dd');
var cashbackChoose = {};
var count = 0;
var total_settle_amount = 0.00;
angular.forEach($scope.currentSettle.unsettle, function (unsettle) {
if (new Date(unsettle.date_str).getTime() <= new Date($scope.to_date).getTime()) {
cashbackChoose[count] = unsettle;
if(unsettle.settle_amount != null){
total_settle_amount = decimal.add(unsettle.settle_amount,total_settle_amount).toFixed(2);
}
count++;
}
});
$scope.settleParams.unsettle = cashbackChoose;
$scope.settleParams.total_settle_amount = total_settle_amount;
}else {
$scope.params.isAll = true;
}
try {
$scope.$digest();
}catch (err){}
});
$scope.manualSettle = function () {
if($scope.currentSettle.locked){
alert("系统正好在执行清算任务,暂不能提现,请稍后再试!");
return;
}
$scope.settle_to = $scope.params.to_date || $scope.params.maxData;
$scope.settle_to = $filter('date')($scope.settle_to, 'yyyy-MM-dd');
$http.put('/client/manual_settle/today', {settle_to: $scope.settle_to}).then(function () {
commonDialog.alert({title: 'Success', content: 'Withdraw application has been submitted', type: 'success'});
$scope.$close();
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
})
}
}]);
app.filter('abs', function () {
return function (value) {
return Math.abs(value);

@ -235,13 +235,16 @@
<div class="mini-stat clearfix bg-info">
<span class="mini-stat-icon bg-light"><i class="glyphicon glyphicon-btc text-info"></i></span>
<div class="mini-stat-info text-right text-light">
<span class="counter text-white" ng-bind="transcommon.today.not_settled|currency:'AUD '">20544</span>
<span class="counter text-white" ng-bind="transcommon.not_settled|currency:'AUD '">20544</span>
UNSETTLED
</div>
<p class="mb-0 m-t-20 text-light">Latest settle: {{transcommon.yes.not_settled|currency:'AUD '}} <span class="pull-right" ng-class="{'text-red':transcommon.today.not_settled<transcommon.yes.not_settled}">
<i class="fa fa-caret-up m-r-5" ng-if="transcommon.today.not_settled >=transcommon.yes.not_settled"></i>
<i class="fa fa-caret-down m-r-5" ng-if="transcommon.today.not_settled<transcommon.yes.not_settled"></i>
{{transcommon.not_settled_rise|number:2|abs}}%</span></p>
<p class="mb-0 m-t-20 text-light">Latest: {{transcommon.latest_settle|currency:'AUD '}} <span class="pull-right" ng-class="{'text-red':transcommon.not_settled<transcommon.latest_settle}">
<i class="fa fa-caret-up m-r-5" ng-if="transcommon.not_settled >=transcommon.latest_settle"></i>
<i class="fa fa-caret-down m-r-5" ng-if="transcommon.not_settled<transcommon.latest_settle"></i>
{{transcommon.not_settled_rise|number:2|abs}}% </span>
<a role="button" ng-click="toShowUnSettledDialog()" ng-if="manual_settle&&([1]|withRole)">
<i class="fa fa-info-circle text-black" uib-tooltip="withdraw deposit" aria-hidden="true"></i></a>
</p>
</div>
</div>
</div>
@ -249,16 +252,18 @@
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="card m-b-30">
<div class="card-body">
<h4 class="mt-0 header-title">Transaction Time Analysis</h4>
<h4 class="mt-0 header-title">Transaction Trade Analysis</h4>
<ul class="list-inline widget-chart m-t-20 text-center">
<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>
<h6 class=""><b>{{wechat_rate}}%</b></h6>
<h6 class=""><b>{{wechat_rate}}</b></h6>
<img src="/static/images/wechatpay_sign.png"/> Wechat
</li>
<li>
<h6 class=""><b>{{alipay_rate}}%</b></h6>
<h6 class=""><b>{{alipay_rate}}</b></h6>
<img src="/static/images/alipay_sign.png"/> Alipay
</li>
</ul>
@ -276,6 +281,8 @@
<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>
<li>
<p class="text-muted m-b-0">{{avgOrderAndCustomer.old_customers.toFixed(0)||0}}</p>
<h6 class=""><b>AVG OLD CUSTOMER</b></h6>

Loading…
Cancel
Save