You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

999 lines
45 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

/**
* Create by yishuqian on 2016-09-19
*/
define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], function (angular,decimal) {
'use strict';
var colors = ['#00c0ef', '#00a65a', '#ff851b', '#f39c12', '#d81b60', '#605ca8', '#dd4b39', '#008080', '#8B008B', '#D2691E', '#708090'];
var app = angular.module('partner_dashboard', ['ui.router', 'ui.bootstrap', 'ngEcharts']);
app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('partner_dashboard', {
url: '/partner_dashboard',
templateUrl: '/static/dashboard/templates/partner_dashboard.html',
controller: 'partnerDashboardCtrl'
})
}]);
/*app.controller('partnerDashboardCtrl', ['$scope', '$http', '$filter', '$uibModal','$timeout', 'chartParser', function ($scope, $http, $filter, $uibModal,$timeout, chartParser) {
$scope.params = {};
$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').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.switchScale($scope.scales[0]);
})
}
$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();
var params = angular.copy($scope.params);
loadFeeAnalysis(angular.merge(params, $scope.scales[2].params()));
};
$scope.scales = [
{
key: 'today',
label: 'Today',
params: function () {
return {
begin: $filter('date')(new Date(), 'yyyyMMdd'),
end: $filter('date')(new Date(), 'yyyyMMdd')
}
}
},
{
key: 'yesterday',
label: 'Yesterday',
params: function () {
var date = new Date();
date = date.setDate(date.getDate() - 1);
return {
begin: $filter('date')(date, 'yyyyMMdd'),
end: $filter('date')(date, 'yyyyMMdd')
}
}
},
{
key: 'seven',
label: 'Last 7 Days',
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: 'This Month',
params: function () {
var date = new Date();
var end = $filter('date')(date, 'yyyyMMdd');
date = date.setDate(1);
return {
begin: $filter('date')(date, 'yyyyMMdd'),
end: end
}
}
}
];
$scope.switchScale = function (scale) {
$scope.currentScale = scale;
$scope.params = angular.merge($scope.params, $scope.currentScale.params());
$scope.loadDashboard();
};
$scope.chart_config = {};
$scope.analysis = {};
$scope.loadDashboard = function () {
loadAnalysis();
loadTradeTimeAnalysis();
getExchangeRate();
};
loadExchangeRate();
$scope.displayExchangeRateHistory = function () {
$uibModal.open({
templateUrl: '/static/dashboard/templates/exchange_rate_history_dialog.html',
controller: 'exchangeRateHistoryDialogCtrl',
size: 'lg'
})
};
function loadExchangeRate() {
var params = {begin: $filter('date')(new Date(), 'yyyyMMdd'), end: $filter('date')(new Date(), 'yyyyMMdd')};
$http.get('/dashboard/system/exchange_rates', {params: params}).then(function (resp) {
$scope.analysis.exchange_rate = resp.data[0] ? resp.data[0].exchange_rate : "";
})
}
function loadAnalysis() {
$http.get('/dashboard/partner/common_analysis', {params: $scope.params}).then(function (resp) {
$scope.analysis.trade_count = resp.data.trade_count;
$scope.analysis.refund_amount = resp.data.refund_amount;
$scope.analysis.not_settled = resp.data.not_settled;
$scope.analysis.trade_amount = resp.data.trade_amount;
$scope.analysis.top_amount_order = resp.data.top_amount_order;
$scope.analysis.total_customers = resp.data.total_customers;
$scope.analysis.new_customers = resp.data.new_customers;
$scope.analysis.old_customers = resp.data.old_customers;
$scope.analysis.pre_amount = resp.data.pre_amount;
});
}
// var getClientUnClearedAmount = function () {
// $http.get('/client/trans_flow/settlement/unclear').then(function (resp) {
// $scope.analysis.not_settled = resp.data;
// });
// };
// getClientUnClearedAmount();
function getExchangeRate() {
$http.get('/dashboard/system/exchange_rates', {params: $scope.params}).then(function (resp) {
if (resp.data && resp.data.length > 0) {
$scope.wechat_rate = resp.data[0].Wechat.exchange_rate;
$scope.alipay_rate = resp.data[0].Alipay.exchange_rate;
$scope.exchange_date = resp.data[0].date.substr(0, 10);
}
});
}
$scope.switchScale($scope.scales[0]);
function loadTradeTimeAnalysis() {
var timeAnalysis = {
chart: {
tooltip: {
trigger: 'axis'
},
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: $scope.params}).then(function (resp) {
$scope.analysis.trade_time = chartParser.parse(timeAnalysis, resp.data);
})
}
function loadFeeAnalysis(params) {
var analysisConfig = {
chart: {
tooltip: {
trigger: 'axis',
formatter: '{b}:AUD {c}'
},
toolbox: {
show: true,
feature: {
mySeven: {
title: 'Last a week',
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 () {
var client_params = angular.copy($scope.params);
loadFeeAnalysis(angular.merge(client_params, $scope.scales[2].params()))
}
},
myThirty: {
title: 'Last a month',
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 client_params = angular.copy($scope.params);
var params = {};
var dt = new Date();
params.end = $filter('date')(dt, 'yyyyMMdd');
dt.setDate(dt.getDate() - 29);
params.begin = $filter('date')(dt, 'yyyyMMdd');
loadFeeAnalysis(angular.merge(client_params, params))
}
}
}
},
yAxis: {
type: 'value',
name: 'Transaction Amount(AUD)'
},
color: colors
},
xAxis: {
basic: {
type: 'category',
boundaryGap: false
},
key: 'date_str'
},
series: [
{
basic: {type: 'line', label: {normal: {show: true}}, showAllSymbols: true},
column: {key: 'aud_fee'}
}
]
};
$http.get('/dashboard/partner/fee_analysis', {params: params}).then(function (resp) {
$scope.analysis.trade_line = chartParser.parse(analysisConfig, resp.data);
})
}
var client_params = angular.copy($scope.params);
loadFeeAnalysis(angular.merge(client_params, $scope.scales[2].params()))
$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'
})
};
}]);
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'/!*,'Bestpay'*!/],
bottom: 0,
height: '15%',
width: '80%',
left: '10%'
},
yAxis: {
type: 'value',
name: 'Exchange Rate',
min: 'auto'
}
/!*color: colors*!/
},
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.controller('partnerDashboardCtrl', ['$scope', '$http', '$filter', '$uibModal','$timeout', 'chartParser','clearingDetailService','commonDialog', function ($scope, $http, $filter, $uibModal,$timeout, chartParser,clearingDetailService,commonDialog) {
$scope.sendMailCount = 0;
$scope.scales = [
{
key: 'today',
label: '今日',
params: function () {
return {
begin: $filter('date')(new Date(), 'yyyyMMdd'),
end: $filter('date')(new Date(), 'yyyyMMdd')
}
}
},
{
key: 'yesterday',
label: '昨日',
params: function () {
var date = new Date();
date = date.setDate(date.getDate() - 1);
return {
begin: $filter('date')(date, 'yyyyMMdd'),
end: $filter('date')(date, 'yyyyMMdd')
}
}
},
{
key: 'seven',
label: '近7日',
params: function () {
var date = new Date();
var end = $filter('date')(date, 'yyyyMMdd');
date = date.setDate(date.getDate() - 7);
return {
begin: $filter('date')(date, 'yyyyMMdd'),
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);
if (client.level3Clients) {
client.level3Clients.forEach(function (level3Client) {
$scope.clients.push(level3Client);
});
}
});
$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);
};
if (!$scope.currentUser.client.has_children){
$scope.loadDashboard();
}
function loadTransCommon() {
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) {
$scope.wechat_rate = resp.data[0].Wechat.exchange_rate;
$scope.alipay_rate = resp.data[0].Alipay.exchange_rate;
$scope.exchange_date = resp.data[0].date.substr(0, 10);
}
});
}
function loadTradeAmountInTypes(params) {
var tradeInTypeConfig = {
chart: {
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
toolbox: {
show: true,
feature: {
mySeven: {
title: 'Last a week',
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 () {
loadTradeAmountInTypes($scope.scales[2].params())
}
},
myThirty: {
title: 'Last a month',
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');
loadTradeAmountInTypes(params)
}
}
}
},
color: colors
},
series: [{
basic: {
name: '交易渠道', type: 'pie', itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
},
column: {key: 'aud_fee', name: 'gateway_label'}
}]
};
$http.get('/dashboard/partner/trans_type_analysis',{params:params}).then(function (resp) {
$scope.trade_type_chart = chartParser.parse(tradeInTypeConfig, resp.data);
});
}
function loadFeeAnalysis(params) {
var analysisConfig = {
chart: {
tooltip: {
trigger: 'axis',
formatter: '{b}:AUD {c}'
},
toolbox: {
show: true,
feature: {
mySeven: {
title: 'Last a week',
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(angular.merge($scope.scales[2].params(),$scope.params));
}
},
myThirty: {
title: 'Last a month',
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');
loadFeeAnalysis(angular.merge(params,$scope.params));
}
}
}
},
yAxis: {
type: 'value',
name: 'Amount(AUD)'
},
color: colors
},
xAxis: {
basic: {
type: 'category',
boundaryGap: false
},
key: 'date'
},
series: [
{
basic: {type: 'line', label: {normal: {show: true}}, showAllSymbols: true},
column: {key: 'total'}
}
]
};
$http.get('/dashboard/partner/fee_analysis', {params: params}).then(function (resp) {
$scope.trade_line = chartParser.parse(analysisConfig, resp.data);
})
}
function getOrderCustomerChartAnalysis(params) {
$http.get('/dashboard/partner/avg_order_customer',{params:params}).then(function (resp) {
$scope.avgOrderAndCustomer = resp.data;
});
$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.forEach(function (e) {
dates.push(e.date);
new_customers.push(e.new_customers);
old_customers.push(e.old_customers);
orders.push(e.orders);
total_amounts.push(e.total);
});
$scope.customersHistory = customersHistoryConfig(dates, old_customers, new_customers, orders);
});
}
var customersHistoryConfig = function (date, old_customers, new_customers, orders) {
return {
color: colors,
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
toolbox: {
show: true,
feature: {
mySeven: {
title: 'Last a week',
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(angular.merge($scope.scales[2].params(),$scope.params))
}
},
myThirty: {
title: 'Last a month',
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');
$scope.time_range = "Last a month";
getOrderCustomerChartAnalysis(angular.merge(params,$scope.params))
}
}
}
},
legend: {
data: ['Old Customers', 'New Customers', 'Order Counts']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: date
}
],
yAxis: [
{
type: 'value',
name: 'Customers'
}, {
type: 'value',
name: 'Orders'
}
],
series: [
{
name: 'Old Customers',
type: 'bar',
stack: 'customers',
data: old_customers
},
{
name: 'New Customers',
type: 'bar',
stack: 'customers',
data: new_customers
},
{
name: 'Order Counts',
type: 'line',
yAxisIndex: 1,
data: orders
}
]
};
};
$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.mail_confirm = resp.data.mail_confirm;
})
};
$scope.getCurrentPartner();
$scope.toShowUnSettledDialog = function () {
$uibModal.open({
templateUrl: '/static/dashboard/templates/partner_dashboard_unsettled_dialog.html',
controller: 'unSettledAmountHistoryDialogCtrl'
})
};
$scope.contactCustomerService = function () {
$uibModal.open({
templateUrl: 'static/dashboard/templates/dashboard_service_support.html',
controller: 'contactCustomerServiceDialogCtrl',
size: 'sm'
})
};
$scope.getClearingTransactions = function (client_id, detailId) {
clearingDetailService.clientClearingDetail(client_id, detailId, true)
};
$scope.checkStartGuidance = function () {
$http.get('/client/partner_info/compliance/files').then(function (resp) {
$scope.complianceFiles = resp.data;
if($scope.complianceFiles.client_id_file != null){
if($scope.complianceFiles.client_bank_file != null && $scope.complianceFiles.client_company_file != null){
$scope.toCommitFiles = true;
}
}
});
$http.get('/client/partner_info').then(function (resp) {
$scope.applyClient = resp.data;
if($scope.applyClient.logo_url != null && $scope.applyClient.description != null && $scope.applyClient.business_structure != null){
if(($scope.applyClient.store_photo != null && $scope.applyClient.company_photo != null) || $scope.applyClient.company_website != null){
if (($scope.applyClient.business_structure == "Company" && $scope.applyClient.acn != null) || $scope.applyClient.business_structure != 'Company' && $scope.applyClient.abn != null){
$scope.commitPartnerInfo = true;
}
}
}
$scope.source = resp.data.source;
$scope.approve_result = resp.data.approve_result;
})
};
if($scope.currentUser.client.source == 4 && $scope.currentUser.client.approve_result != 1){
$scope.checkStartGuidance();
}
$scope.checkEmail = function () {
if($scope.mail_confirm){
commonDialog.alert({title: 'Message', content: '邮件已验证,请勿重复发送', type: 'info'});
return;
}
if($scope.sendMailCount >=1){
commonDialog.alert({title: 'Message', content: '邮件已发送,请勿重复点击', type: 'info'});
return;
}
$http.put('/client/partner_info/verify/email').then(function (resp) {
$scope.sendMailCount = $scope.sendMailCount +1;
commonDialog.alert({title: 'Message', content: 'Verify that the message has been sent to your mailbox. Please complete the validation as soon as possible', type: 'info'});
})
}
/* '$scope', '$http','partner',*/
$scope.ComplianceToPrefect = function () {
$uibModal.open({
templateUrl: '/static/payment/partner/templates/compliance_files_advice.html',
backdrop: false,
resolve: {
partner: ['$http', function ($http) {
return $http.get('');
}]
}
})
};
$scope.ComplianceToPrefect();
}]);
app.controller('contactCustomerServiceDialogCtrl', ['$scope', '$http', function ($scope, $http) {
}]);
app.filter('abs', function () {
return function (value) {
return Math.abs(value);
}
});
return app;
});