| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- define([ 'app/app' ], function(app) {
- //在售商品信息统计
- app.register.controller('statsDataCtrl', ['$scope', 'ngTableParams', 'BaseService','Goods', 'toaster', 'ComponentActive', 'BrandActive', 'CommonCountAPI', 'User', '$http', '$q', 'Loading',
- function($scope, ngTableParams, BaseService, Goods, toaster, ComponentActive, BrandActive, CommonCountAPI, User, $http, $q, Loading) {
- $scope.detailOpen = false;
- $scope.dateArea = 'oneMonth';
- var _formatDate = function (date, fmt) {
- if (!date) {
- return null;
- }
- if (typeof date === 'string') {
- date = new Date(Date.parse(date.replace(/-/g, '/')));
- }
- var o = {
- 'M+': date.getMonth() + 1, // 月份
- 'd+': date.getDate(), // 日
- 'h+': date.getHours(), // 小时
- 'm+': date.getMinutes(), // 分
- 's+': date.getSeconds(), // 秒
- 'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
- 'S': date.getMilliseconds() // 毫秒
- }
- if (/(y+)/.test(fmt)) {
- fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
- }
- for (var k in o) {
- if (new RegExp('(' + k + ')').test(fmt)) {
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)));
- }
- }
- return fmt;
- };
- var _getClearDay = function (date) {
- return new Date(_formatDate(date, 'yyyy-MM-dd')).getTime() - 8 * 60 * 60 * 1000
- };
- var currentTime = _getClearDay(new Date());
- $scope.startDate = new Date(currentTime - 30 * 24 * 60 * 60 * 1000);
- $scope.endDate = new Date(currentTime + 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 59 * 1000);
- $scope.startFormatDate = _formatDate($scope.startDate, 'yyyy-MM-dd');
- $scope.endFormatDate = _formatDate($scope.endDate, 'yyyy-MM-dd');
- var addStartDate = new Date($scope.startDate.getTime() + 24 * 60 * 60 * 1000)
- var addEndDate = new Date($scope.endDate.getTime() + 24 * 60 * 60 * 1000)
- $scope.addStartFormatDate = _formatDate(addStartDate, 'yyyy-MM-dd');
- $scope.addEndFormatDate = _formatDate(addEndDate, 'yyyy-MM-dd');
- $scope.setFilters = function (type, val) {
- $scope[type] = val;
- if (type == 'dateArea') {
- // 时间筛选
- var currentTime = _getClearDay(new Date());
- var endDate = new Date(currentTime + 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 59 * 1000);
- if (val == 'oneMonth') {
- $scope.startDate = new Date(currentTime - 30 * 24 * 60 * 60 * 1000);
- $scope.endDate = endDate;
- } else if (val == 'threeMonth') {
- $scope.startDate = new Date(currentTime - 3 * 30 * 24 * 60 * 60 * 1000);
- $scope.endDate = endDate;
- } else if (val == 'sixMonth') {
- $scope.startDate = new Date(currentTime - 6 * 30 * 24 * 60 * 60 * 1000);
- $scope.endDate = endDate;
- }
- }
- if (val != 'autoMonth') {
- initData();
- } else {
- // $scope.startDate = '';
- // $scope.endDate = '';
- }
- };
- $scope.setFiltersAll = function () {
- initData()
- }
- $scope.condition = [];
- var start = {
- open : false
- };
- var end = {
- open : false
- };
- $scope.condition.push(start);
- $scope.condition.push(end);
- // 打开日期选择框
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- openParam == 0 ? $scope.condition[1].open = false : $scope.condition[0].open = false;
- item[openParam].open = !item[openParam].open;
- };
- $scope.onDateCondition = function (bool, date) {
- if (bool == 1) {
- $scope.startDate = date;
- } else {
- $scope.endDate = date;
- }
- var startTime = $scope.startDate ? $scope.startDate.getTime() : null;
- var endTime = $scope.endDate ? $scope.endDate.getTime() : null;
- if (startTime && endTime && startTime > endTime) {
- if (bool == 1) {
- toaster.pop('info', '起始时间不能大于结束时间');
- $scope.startDate = null;
- } else {
- toaster.pop('info', '结束时间不能小于起始时间');
- $scope.endDate = null;
- }
- }
- if ($scope.endDate && bool == 2) {
- $scope.endDate = new Date($scope.endDate.getFullYear(), $scope.endDate.getMonth(), $scope.endDate.getDate())
- $scope.endDate = new Date($scope.endDate.getTime() - 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 59 * 1000);
- }
- $scope.startDate = new Date($scope.startDate.getTime() - 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 59 * 1000);
- };
- $scope.detailOpenClick = function (type) {
- $scope.detailOpen = type;
- };
- var getSeekInfo = function (commonUrl) {
- // 询价信息
- var defer = $q.defer();
- $http({
- method: 'get',
- dataType: 'json',
- url: commonUrl + '/inquiry/public/getInquiryCountData',
- params: {startDate: $scope.startFormatDate, endDate: $scope.endFormatDate}
- }).success(function (data) {
- defer.resolve(data);
- }).error(function (err) {
- defer.reject(err);
- });
- return defer.promise;
- }
- var getAddEnUserCount = function (ssoUrl) {
- // 新增企业用户数
- var defer = $q.defer();
- $http({
- method: 'get',
- dataType: 'json',
- url: ssoUrl + '/api/userspace/inputTime/count/apps',
- params: {start: $scope.addStartFormatDate, end: $scope.addEndFormatDate, fromApps:'mall,b2b'}
- }).success(function (data) {
- defer.resolve(data);
- }).error(function (err) {
- defer.reject(err);
- });
- return defer.promise;
- }
- var getAddUserCount = function (ssoUrl) {
- // 新增个人用户
- var defer = $q.defer();
- $http({
- method: 'get',
- dataType: 'json',
- url: ssoUrl + '/api/user/inputTime/count/apps',
- params: {start: $scope.addStartFormatDate, end: $scope.addEndFormatDate, fromApps:'mall,b2b'}
- }).success(function (data) {
- defer.resolve(data);
- }).error(function (err) {
- defer.reject(err);
- });
- return defer.promise;
- }
- var getNoLoginInfo = function (ssoUrl) {
- // 半年未登录用户数
- var defer = $q.defer();
- $http({
- method: 'get',
- dataType: 'json',
- url: ssoUrl + '/api/user/count/notlgoin/month',
- params: {start: $scope.addStartFormatDate, end: $scope.addEndFormatDate, months: '6,12,24'}
- }).success(function (data) {
- defer.resolve(data);
- }).error(function (err) {
- defer.reject(err);
- });
- return defer.promise;
- }
- var getProductData = function () {
- // 上传产品个数
- var defer = $q.defer();
- Goods.getProductsCmp({fromDate: $scope.startDate && $scope.startDate.getTime(), toDate: $scope.endDate && $scope.endDate.getTime()}, function (data) {
- defer.resolve(data.data);
- }, function (err) {
- defer.reject(err);
- toaster.pop('error', '数据获取失败,请重试')
- });
- return defer.promise;
- }
- // 获取帐户中心数据和询价接口数据
- var getAllData = function (addStartFormatDate, addEndFormatDate, startFormatDate, endFormatDate) {
- var defer = $q.defer();
- User.isDevOrProd(null, function (data) {
- var ssoUrl = data.data == 'success' ? 'https://sso.ubtob.com' : 'https://test-sso-server.uuzcc.cn',
- // uasUrl = data.data == 'success' ? 'http://uas.ubtob.com' : 'http://192.168.253.12:9000/b2b-test',
- commonUrl = data.data == 'success' ? 'https://api-inquiry.usoftchina.com' : 'https://test-inquiry.uuzcc.cn';
- defer.resolve([
- getSeekInfo(commonUrl),
- getAddEnUserCount(ssoUrl),
- getAddUserCount(ssoUrl),
- getNoLoginInfo(ssoUrl),
- getProductData()
- ]);
- }, function (response) {
- toaster.pop('error', '获取运行环境失败');
- defer.reject(response);
- });
- return defer.promise;
- };
- // 获取不同时间阶段的相关数据
- var initData = function () {
- var addStartDate = $scope.startDate && new Date($scope.startDate.getTime() + 24 * 60 * 60 * 1000),
- addEndDate = $scope.endDate && new Date($scope.endDate.getTime() + 24 * 60 * 60 * 1000);
- $scope.addStartFormatDate = _formatDate(addStartDate, 'yyyy-MM-dd');
- $scope.addEndFormatDate = _formatDate(addEndDate, 'yyyy-MM-dd');
- $scope.startFormatDate = _formatDate($scope.startDate, 'yyyy-MM-dd');
- $scope.endFormatDate = _formatDate($scope.endDate, 'yyyy-MM-dd');
- $q.all([getAllData()]).then(function (resolve) {
- Loading.show();
- $q.all(resolve[0]).then(function (dataListResolve) {
- $scope.inquiryData = dataListResolve[0];
- $scope.newAddUserSpaceData = dataListResolve[1].content;
- $scope.newAddUserData = dataListResolve[2].content;
- $scope.monthLogoData = dataListResolve[3];
- $scope.productsCount = dataListResolve[4];
- Loading.hide();
- }, function (dataListReject) {
- console.log(dataListReject);
- Loading.hide();
- })
- }, function (reject) {
- console.log(reject);
- })
- };
- initData();
- Goods.getAllCmp({}, function (data) {
- angular.forEach(data, function(value) {
- switch(value.item) {
- case '规格书':
- $scope.start1 = value.count;
- break;
- case '品牌':
- $scope.start2 = value.count;
- break;
- case '现货':
- $scope.start3 = value.count;
- break;
- case '当前器件总数':
- $scope.start4 = value.count;
- break;
- case '本月新增器件数':
- $scope.start5 = value.count;
- break;
- case '上月新增器件数':
- $scope.start6 = value.count;
- break;
- case '本月新增品牌数':
- $scope.start7 = value.count;
- break;
- case '当前类目总数':
- $scope.start8 = value.count;
- break;
- case '本月更新器件数':
- $scope.start9 = value.count;
- break;
- case '库存合计':
- $scope.start10 = value.count;
- break;
- case '在售商品品牌数量':
- $scope.start11 = value.count;
- break;
- case '在售商品类目数量':
- $scope.start12 = value.count;
- break;
- case '在售商品型号数量':
- $scope.start13 = value.count;
- break;
- case '含税金额合计(RMB)':
- $scope.start14 = value.count;
- break;
- case '未税金额合计(RMB)':
- $scope.start15 = value.count;
- break;
- case '上年交易金额':
- $scope.start16 = value.count;
- break;
- case '本年交易金额':
- $scope.start17 = value.count;
- break;
- case '上月器件总数':
- $scope.start18 = value.count;
- break;
- case '上月品牌总数':
- $scope.start19 = value.count;
- break;
- case '上月开通店铺数量':
- $scope.start20 = value.count;
- break;
- case '上个月用户注册量':
- $scope.start21 = value.count;
- break;
- case '上个月企业注册量':
- $scope.start22 = value.count;
- break;
- case '供应商总数':
- $scope.start23 = value.count;
- break;
- case '店铺总数':
- $scope.start24 = value.count;
- break;
- case '本月新增店铺数':
- $scope.start25 = value.count;
- break;
- case '上月新增店铺数':
- $scope.start26 = value.count;
- break;
- case '优软云个人用户数':
- $scope.start27 = value.count;
- break;
- case '注册总数量':
- $scope.start28 = value.count;
- break;
- case '当月注册数量':
- $scope.start29 = value.count;
- break;
- case '上月注册汇总':
- $scope.start30 = value.count;
- break;
- case '手机UU用户数':
- $scope.start31 = value.count;
- break;
- case '在售商品类目(标准)':
- $scope.start32 = value.count;
- break;
- case '在售商品类目(非标准)':
- $scope.start33 = value.count;
- break;
- case '在售商品品牌(标准)':
- $scope.start34 = value.count;
- break;
- case '在售商品品牌(非标准)':
- $scope.start35 = value.count;
- break;
- }
- });
- }, function(res) {
- toaster.pop('error', '提示', '获取数据失败,请刷新页面')
- });
- //table设置
- $scope.tableParams = new ngTableParams({
- page : 1,
- size : 10
- }, {
- total : 0,
- getData : function ($defer, params) {
- // $scope.loading = true;
- var param = BaseService.parseParams(params.url());
- // param.keyword = $scope.keyword;
- param.startTime = $scope.startFormatDate;
- param.endTime = $scope.endFormatDate;
- Goods.loadUploadProductDetail(param, function (data) {
- params.total(data.totalElements);
- $defer.resolve(data.content);
- }, function (response) {
- toaster.pop('error', '获取上传产品详情列表失败');
- });
- }
- });
- // 根据关键词搜索
- $scope.onSearch = function() {
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- window.location.href = 'store-service/export?startTime='+ $scope.startFormatDate + '&endTime=' + $scope.endFormatDate
- }
- }]);
- });
|