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.
164 lines
6.8 KiB
164 lines
6.8 KiB
/**
|
|
* Created by yishuqian on 28/09/2016.
|
|
*/
|
|
define(['angular', 'static/commons/commons', 'static/commons/angular-ueditor', 'uiBootstrap', 'uiRouter', 'ngBootSwitch', 'ngFileUpload','./transaction/analysis-transaction'], function (angular) {
|
|
'use strict';
|
|
var app = angular.module('customerRankingAnalysisApp', ['ui.bootstrap', 'ui.router', 'frapontillo.bootstrap-switch']);
|
|
app.config(['$stateProvider', function ($stateProvider) {
|
|
$stateProvider.state('analysis_transaction.customerRankingAnalysis', {
|
|
url: '/customers',
|
|
templateUrl: '/static/analysis/templates/customer_analysis.html',
|
|
controller: 'customersListCtrl',
|
|
data: {label: 'Customers'}
|
|
})
|
|
}]);
|
|
app.controller('customersListCtrl', ['$scope', '$http','$filter', '$uibModal', 'commonDialog', 'orderService', 'refunder', function ($scope, $http,$filter, $uibModal, commonDialog, orderService, refunder) {
|
|
$scope.pagination = {};
|
|
$scope.params = {};
|
|
$scope.params.openid_type = '0';
|
|
|
|
$scope.today = new Date();
|
|
$scope.chooseToday = function () {
|
|
$scope.params.begin = $scope.params.end = new Date();
|
|
$scope.listCustomers(1);
|
|
};
|
|
$scope.chooseYesterday = function () {
|
|
var yesterday = new Date();
|
|
yesterday.setDate(yesterday.getDate() - 1);
|
|
$scope.params.begin = $scope.params.end = yesterday;
|
|
$scope.listCustomers(1);
|
|
};
|
|
$scope.chooseLast7Days = function () {
|
|
$scope.params.end = new Date();
|
|
var day = new Date();
|
|
day.setDate(day.getDate() - 7);
|
|
$scope.params.begin = day;
|
|
$scope.listCustomers(1);
|
|
};
|
|
$scope.thisMonth = function () {
|
|
$scope.params.end = new Date();
|
|
var monthBegin = new Date();
|
|
monthBegin.setDate(1);
|
|
$scope.params.begin = monthBegin;
|
|
$scope.listCustomers(1);
|
|
};
|
|
$scope.lastMonth = function () {
|
|
var monthFinish = new Date();
|
|
monthFinish.setDate(0);
|
|
$scope.params.end = monthFinish;
|
|
var monthBegin = new Date();
|
|
monthBegin.setDate(0);
|
|
monthBegin.setDate(1);
|
|
$scope.params.begin = monthBegin;
|
|
$scope.listCustomers(1);
|
|
};
|
|
$scope.thisYear = function () {
|
|
var yearFinish = new Date();
|
|
$scope.params.end = yearFinish;
|
|
var currentYearFirstDate = new Date(new Date().getFullYear(), 0, 1);
|
|
$scope.params.begin = currentYearFirstDate;
|
|
$scope.listCustomers(1);
|
|
};
|
|
// $scope.customer_loading = true;
|
|
$scope.listCustomers = function (page) {
|
|
$scope.customer_loading = true;
|
|
var params = angular.copy($scope.params);
|
|
params.page = page || $scope.pagination.page || 1;
|
|
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');
|
|
}
|
|
$http.get('/analysis/customers/ranking/'+$scope.params.openid_type, {params: params}).then(function (resp) {
|
|
$scope.customer_loading = false;
|
|
$scope.customers = resp.data.data;
|
|
$scope.customers_type = resp.data.openid_type;
|
|
$scope.customers_analysis = resp.data.analysis;
|
|
$scope.pagination = resp.data.pagination;
|
|
if($scope.customers.length>0){
|
|
$scope.order_params.customer_id = $scope.customers[0].customer_id;
|
|
$scope.customer_loading = false;
|
|
$scope.listCustomerOrders(1);
|
|
}else{
|
|
$scope.orders=[];
|
|
}
|
|
|
|
});
|
|
};
|
|
//$scope.listCustomers(1);
|
|
|
|
//orders
|
|
$scope.order_params = {};
|
|
$scope.orderPagination = {};
|
|
// $scope.today = new Date();
|
|
// $scope.chooseToday = function () {
|
|
// $scope.order_params.datefrom = $scope.order_params.dateto = new Date();
|
|
// $scope.listCustomerOrders(1);
|
|
// };
|
|
// $scope.chooseYesterday = function () {
|
|
// var yesterday = new Date();
|
|
// yesterday.setDate(yesterday.getDate() - 1);
|
|
// $scope.order_params.datefrom = $scope.order_params.dateto = yesterday;
|
|
// $scope.listCustomerOrders(1);
|
|
// };
|
|
// $scope.chooseLast7Days = function () {
|
|
// $scope.order_params.dateto = new Date();
|
|
// var day = new Date();
|
|
// day.setDate(day.getDate() - 7);
|
|
// $scope.order_params.datefrom = day;
|
|
// $scope.listCustomerOrders(1);
|
|
// };
|
|
// $scope.thisMonth = function () {
|
|
// $scope.order_params.dateto = new Date();
|
|
// var monthBegin = new Date();
|
|
// monthBegin.setDate(1);
|
|
// $scope.order_params.datefrom = monthBegin;
|
|
// $scope.listCustomerOrders(1);
|
|
// };
|
|
// $scope.lastMonth = function () {
|
|
// var monthFinish = new Date();
|
|
// monthFinish.setDate(0);
|
|
// $scope.order_params.dateto = monthFinish;
|
|
// var monthBegin = new Date();
|
|
// monthBegin.setDate(0);
|
|
// monthBegin.setDate(1);
|
|
// $scope.order_params.datefrom = monthBegin;
|
|
// $scope.listCustomerOrders(1);
|
|
// };
|
|
// $scope.order_loading = true;
|
|
$scope.listCustomerOrders = function (page) {
|
|
$scope.order_loading = true;
|
|
var params = angular.copy($scope.order_params) || {};
|
|
if (params.datefrom) {
|
|
params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd');
|
|
}
|
|
if (params.dateto) {
|
|
params.dateto = $filter('date')(params.dateto, 'yyyyMMdd');
|
|
}
|
|
params.gateway = [0, 1];
|
|
params.page = page || $scope.orderPagination.page || 1;
|
|
$http.get('/analysis/customers/' + $scope.order_params.customer_id + '/orders', {params: params}).then(function (resp) {
|
|
$scope.orders = resp.data.data;
|
|
$scope.orderPagination = resp.data.pagination;
|
|
$scope.order_loading = false;
|
|
// $scope.analysis = resp.data.analysis;
|
|
});
|
|
};
|
|
$scope.chooseToday();
|
|
|
|
$scope.orderDetail = function (order) {
|
|
orderService.managerOrderDetail(order)
|
|
};
|
|
$scope.refundOrder = function (order) {
|
|
refunder.refunded(order.order_id)
|
|
};
|
|
|
|
}]);
|
|
|
|
return app;
|
|
}); |