@ -12,7 +12,7 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct
controller : 'partnerDashboardCtrl'
} )
} ] ) ;
app . controller ( 'partnerDashboardCtrl' , [ '$scope' , '$http' , '$filter' , '$uibModal' , '$timeout' , 'chartParser' , function ( $scope , $http , $filter , $uibModal , $timeout , chartParser ) {
/ * a p p . c o n t r o l l e r ( ' p a r t n e r D a s h b o a r d C t r l ' , [ ' $ s c o p e ' , ' $ h t t p ' , ' $ f i l t e r ' , ' $ u i b M o d a l ' , ' $ t i m e o u t ' , ' c h a r t P a r s e r ' , f u n c t i o n ( $ s c o p e , $ h t t p , $ f i l t e r , $ u i b M o d a l , $ t i m e o u t , c h a r t P a r s e r ) {
$scope . params = { } ;
$scope . chooseShow = 'All' ;
$scope . clients = [ $scope . currentUser . client ] ;
@ -431,7 +431,7 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct
}
} ,
legend : {
data : [ 'Wechat' , 'Alipay' /*,'Bestpay'*/ ] ,
data : [ 'Wechat' , 'Alipay' / ! * , 'Bestpay' * ! / ] ,
bottom : 0 ,
height : '15%' ,
width : '80%' ,
@ -442,7 +442,7 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct
name : 'Exchange Rate' ,
min : 'auto'
}
/*color: colors* /
/!*color: colors*! /
} ,
xAxis : {
basic : {
@ -566,6 +566,534 @@ define(['angular','decimal', 'uiRouter', 'uiBootstrap', 'angularEcharts'], funct
commonDialog . alert ( { title : 'Error' , content : resp . data . message , type : 'error' } ) ;
} )
}
} ] ) ; * /
app . controller ( 'partnerDashboardCtrl' , [ '$scope' , '$http' , '$filter' , '$uibModal' , '$timeout' , 'chartParser' , function ( $scope , $http , $filter , $uibModal , $timeout , chartParser ) {
$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 ( ) - 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 ) ;
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 . loadDashboard = function ( ) {
loadBasicInfo ( )
loadTransCommon ( ) ;
getAvgOrderAndCustomer ( ) ;
} ;
$scope . loadDashboard ( ) ;
function loadBasicInfo ( ) {
$http . get ( '/dashboard/partner/' + $scope . clientMoniker + '/basic_info' ) . then ( function ( resp ) {
$scope . basicinfo = resp . data ;
} ) ;
}
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 ) {
$scope . transcommon = resp . data ;
} ) ;
}
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 ) ;
} ) ;
}
loadTradeAmountInTypes ( $scope . scales [ 4 ] . params ( ) ) ;
function getAvgOrderAndCustomer ( ) {
$http . get ( '/dashboard/partner/' + $scope . clientMoniker + '/avg_order_customer' ) . then ( function ( resp ) {
$scope . avgOrderAndCustomer = 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 ( $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' ) ;
loadFeeAnalysis ( params ) ;
}
}
}
} ,
yAxis : {
type : 'value' ,
name : '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 . trade _line = chartParser . parse ( analysisConfig , resp . data ) ;
} )
}
loadFeeAnalysis ( $scope . scales [ 4 ] . params ( ) ) ;
function getOrderCustomerChartAnalysis ( params ) {
$http . get ( '/dashboard/partner/customers' , { params : 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 ) ;
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 ) ;
} ) ;
}
getOrderCustomerChartAnalysis ( $scope . scales [ 4 ] . params ( ) ) ;
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 ( ) {
getOrderCustomerChartAnalysis ( $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' ) ;
getOrderCustomerChartAnalysis ( 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
}
]
} ;
} ;
/ * f u n c t i o n l o a d T r a d e T i m e A n a l y s i s ( p a r a m s ) {
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 . loadSettlementLogs = function ( page ) {
var params = angular . copy ( $scope . params ) ;
// if (params.datefrom) {
// params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd');
// }
// if (params.dateto) {
// params.dateto = $filter('date')(params.dateto, 'yyyyMMdd');
// }
params . page = page || $scope . pagination . page || 1 ;
params . limit = 8 ;
$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 ) ;
} ] ) ;
app . filter ( 'abs' , function ( ) {
return function ( value ) {
return Math . abs ( value ) ;
}
} ) ;
return app ;
} ) ;