|
|
|
@ -12,6 +12,7 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts', './bd/analysis-b
|
|
|
|
|
}]);
|
|
|
|
|
app.controller('bdSaleAnalysisCtrl', ['$scope', '$http', '$filter', '$timeout', 'commonDialog', 'chartParser','industryMap',
|
|
|
|
|
function ($scope, $http, $filter, $timeout, commonDialog, chartParser,industryMap) {
|
|
|
|
|
$scope.showItems = true;
|
|
|
|
|
$scope.params = {};
|
|
|
|
|
$scope.today = new Date();
|
|
|
|
|
$scope.chooseToday = function () {
|
|
|
|
@ -151,9 +152,33 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts', './bd/analysis-b
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.loadRoyalpayindustry = function () {
|
|
|
|
|
$http.get('/static/data/royalpayindustry.json').then(function (resp) {
|
|
|
|
|
$scope.royalpayindustry = resp.data;
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
$scope.loadRoyalpayindustry();
|
|
|
|
|
var getType = function (industryCode) {
|
|
|
|
|
var industryLabel = '';
|
|
|
|
|
angular.forEach($scope.royalpayindustry, function (industry) {
|
|
|
|
|
if (industry.mccCode == industryCode) {
|
|
|
|
|
industryLabel = industry.label;
|
|
|
|
|
}else {
|
|
|
|
|
angular.forEach(industry.children, function (children){
|
|
|
|
|
if (children.mccCode == industryCode) {
|
|
|
|
|
industryLabel = children.label;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (!industryLabel) {
|
|
|
|
|
industryLabel = industryCode;
|
|
|
|
|
}
|
|
|
|
|
return industryLabel;
|
|
|
|
|
};
|
|
|
|
|
$scope.loadPartnersChart = function (bd_id, bd_name) {
|
|
|
|
|
$scope.chooseBdName = bd_name;
|
|
|
|
|
$scope.bd_id = bd_id
|
|
|
|
|
var params = angular.copy($scope.params);
|
|
|
|
|
if (params.begin) {
|
|
|
|
|
params.begin = $filter('date')(params.begin, 'yyyyMMdd');
|
|
|
|
@ -188,7 +213,7 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts', './bd/analysis-b
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
var getType = function (industryCode) {
|
|
|
|
|
/* var getType = function (industryCode) {
|
|
|
|
|
var industryLabel = '';
|
|
|
|
|
angular.forEach(industryMap.configs(), function (industry) {
|
|
|
|
|
if (industry.value == industryCode) {
|
|
|
|
@ -199,21 +224,22 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts', './bd/analysis-b
|
|
|
|
|
industryLabel = industryCode;
|
|
|
|
|
}
|
|
|
|
|
return industryLabel;
|
|
|
|
|
};
|
|
|
|
|
};*/
|
|
|
|
|
$http.get('/analysis/bd/sales/partners/report', {params: params}).then(function (resp) {
|
|
|
|
|
$scope.legends = [];
|
|
|
|
|
for (var i = 0; i < resp.data.length; i++) {
|
|
|
|
|
$scope.legends[i] = resp.data[i].partner_type;
|
|
|
|
|
var partner_type = getType(resp.data[i].industry);
|
|
|
|
|
/* $scope.legends[i] = resp.data[i].partner_type;*/
|
|
|
|
|
var partner_type = getType(resp.data[i].mccCode);
|
|
|
|
|
resp.data[i].partner_type = partner_type;
|
|
|
|
|
$scope.legends[i] = partner_type;
|
|
|
|
|
/* $scope.legends[i] = partner_type;*/
|
|
|
|
|
}
|
|
|
|
|
$scope.PartnerTypes = angular.copy(resp.data);
|
|
|
|
|
var legend = $scope.legends;
|
|
|
|
|
$scope.partners_type_chart = chartParser.parse(partnerTypesConfig(), $scope.PartnerTypes);
|
|
|
|
|
/* var legend = $scope.legends;*/
|
|
|
|
|
childrenType(0);
|
|
|
|
|
$scope.partners_type_chart = partnerTypesConfig($scope.PartnerTypes,$scope.children);
|
|
|
|
|
$scope.partnersAnalysischart = chartParser.parse(analysisPartner(), $scope.PartnerTypes);
|
|
|
|
|
|
|
|
|
|
function partnerTypesConfig() {
|
|
|
|
|
/*function partnerTypesConfig() {
|
|
|
|
|
return {
|
|
|
|
|
chart: {
|
|
|
|
|
tooltip: {
|
|
|
|
@ -237,7 +263,7 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts', './bd/analysis-b
|
|
|
|
|
column: {key: 'partner_counts', name: 'partner_type'}
|
|
|
|
|
}]
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};*/
|
|
|
|
|
|
|
|
|
|
function analysisPartner() {
|
|
|
|
|
return {
|
|
|
|
@ -279,7 +305,7 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts', './bd/analysis-b
|
|
|
|
|
}
|
|
|
|
|
,
|
|
|
|
|
column: {
|
|
|
|
|
key: 'total', name: 'total', color: function (idx) {
|
|
|
|
|
key: 'count_total', name: 'total', color: function (idx) {
|
|
|
|
|
return colors[idx % colors.length]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -292,6 +318,103 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts', './bd/analysis-b
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var partnerTypesConfig = function (innerData,outerData) {
|
|
|
|
|
outerData = outerData||[];
|
|
|
|
|
var innerSeriesTemplate = {
|
|
|
|
|
name: '商户类别',
|
|
|
|
|
type: 'pie',
|
|
|
|
|
radius: outerData.length==0?'80%':'40%',
|
|
|
|
|
center: ['50%', '40%'],
|
|
|
|
|
selectedMode: 'single',
|
|
|
|
|
itemStyle: {
|
|
|
|
|
emphasis: {
|
|
|
|
|
shadowBlur: 10,
|
|
|
|
|
shadowOffsetX: 0,
|
|
|
|
|
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
|
|
|
|
},
|
|
|
|
|
normal : {
|
|
|
|
|
label : {
|
|
|
|
|
position : 'inner'
|
|
|
|
|
},
|
|
|
|
|
labelLine : {
|
|
|
|
|
show : false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data:[]
|
|
|
|
|
};
|
|
|
|
|
angular.forEach(innerData,function (item) {
|
|
|
|
|
innerSeriesTemplate.data.push({
|
|
|
|
|
name:item.partner_type,
|
|
|
|
|
value:item.count_value,
|
|
|
|
|
selected:$scope.partners_type.partner_type===item.partner_type
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
var outerSeriesTemplate = {
|
|
|
|
|
name: '商户类别', type: 'pie',
|
|
|
|
|
radius : ['50%', '63%'],
|
|
|
|
|
center: ['50%', '40%'],
|
|
|
|
|
label: {
|
|
|
|
|
normal: {
|
|
|
|
|
formatter: '{b} : {c} ({d}%)'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
itemStyle: {
|
|
|
|
|
emphasis: {
|
|
|
|
|
shadowBlur: 10,
|
|
|
|
|
shadowOffsetX: 0,
|
|
|
|
|
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data:[]
|
|
|
|
|
};
|
|
|
|
|
angular.forEach(outerData,function (item) {
|
|
|
|
|
outerSeriesTemplate.data.push({
|
|
|
|
|
name:item.children_partner_type,
|
|
|
|
|
value:item.partner_counts})
|
|
|
|
|
});
|
|
|
|
|
var series = [innerSeriesTemplate];
|
|
|
|
|
if(outerData.length){
|
|
|
|
|
series.push(outerSeriesTemplate)
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
tooltip: {
|
|
|
|
|
trigger: 'item',
|
|
|
|
|
formatter: "{a} <br/>{b} : {c} ({d}%)"
|
|
|
|
|
},
|
|
|
|
|
color: colors,
|
|
|
|
|
/* legend: {
|
|
|
|
|
orient: 'horizontal',
|
|
|
|
|
/!*y: '450px',
|
|
|
|
|
left: 'right',*!/
|
|
|
|
|
x: 'center',
|
|
|
|
|
y: 'bottom',
|
|
|
|
|
data: $scope.legends
|
|
|
|
|
},*/
|
|
|
|
|
series: series
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
$scope.partner_type_chart = function (chart) {
|
|
|
|
|
chart.on('click', function (params) {
|
|
|
|
|
childrenType(params.dataIndex);
|
|
|
|
|
$scope.partners_type_chart = partnerTypesConfig($scope.PartnerTypes,$scope.children);
|
|
|
|
|
try {
|
|
|
|
|
$scope.$digest();
|
|
|
|
|
}catch (err){}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
var childrenType = function (index) {
|
|
|
|
|
$scope.partners_type = $scope.PartnerTypes[index];
|
|
|
|
|
$scope.children = $scope.partners_type.children;
|
|
|
|
|
for (var i = 0; i < $scope.children.length; i++) {
|
|
|
|
|
$scope.legends[i] = $scope.children.children_partner_type;
|
|
|
|
|
var children_partner_type= getType($scope.children[i].royalpayindustry);
|
|
|
|
|
$scope.children[i].children_partner_type = children_partner_type;
|
|
|
|
|
}
|
|
|
|
|
$scope.PartnerTypes[index].children = $scope.children;
|
|
|
|
|
/*$scope.type_count = $scope.PartnerTypes[index].count_value;*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$scope.exportMonthSale = function () {
|
|
|
|
|
var params = angular.copy($scope.params);
|
|
|
|
|
if (params.begin_month) {
|
|
|
|
@ -314,6 +437,36 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts', './bd/analysis-b
|
|
|
|
|
return url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$scope.exportExcelByBdOrDate = function (type) {
|
|
|
|
|
if (type=='data'){
|
|
|
|
|
url = '/analysis/bd/sales/partners/excel_data';
|
|
|
|
|
}
|
|
|
|
|
if (type=='bd'){
|
|
|
|
|
var url = '/analysis/bd/sales/partners/excel_bd';
|
|
|
|
|
}
|
|
|
|
|
var params = angular.copy($scope.params);
|
|
|
|
|
if (params.begin) {
|
|
|
|
|
params.begin = $filter('date')(params.begin, 'yyyyMMdd');
|
|
|
|
|
} else {
|
|
|
|
|
params.begin = $filter('date')('2016-01-01', 'yyyyMMdd');
|
|
|
|
|
}
|
|
|
|
|
if (params.end) {
|
|
|
|
|
params.end = $filter('date')(params.end, 'yyyyMMdd');
|
|
|
|
|
} else {
|
|
|
|
|
params.end = $filter('date')(new Date(), 'yyyyMMdd');
|
|
|
|
|
}
|
|
|
|
|
var connectSymbol = '?';
|
|
|
|
|
url += connectSymbol + 'begin=' + params.begin + '&' + 'end=' + params.end;
|
|
|
|
|
if (type=='bd') {
|
|
|
|
|
url += '&'+'bd_id=' + $scope.bd_id + '&'+ 'bd_name=' + $scope.chooseBdName;
|
|
|
|
|
}
|
|
|
|
|
if (params.org_id) {
|
|
|
|
|
url += '&' + 'org_id=' + params.org_id;
|
|
|
|
|
}
|
|
|
|
|
return url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
return app;
|
|
|
|
|