Browse Source

恢复销售排行榜的数据获取方式

huxz 8 years ago
parent
commit
fa80263b9f

+ 9 - 23
src/main/webapp/resources/js/provider/controllers/ProviderFactoriesCtrl.js

@@ -32,30 +32,16 @@ define([ 'app/app', 'jquery-summernote' ], function(app) {
 			/**
 			 * 获取销售排行信息
 			 */
-			StoreAdsInformation.showSalesListWhenUserQuery({types: 'ORIGINAL_FACTORY'}, {}, function (data) {
-				if (angular.isArray(data) && data.length > 0) {
-					$scope.topSalesStores = data;
-					angular.forEach(data, function (storeAds) {
-						if (storeAds.store) {
-							storeAds.uuid = storeAds.store.uuid;
-							storeAds.logoUrl = storeAds.store.logoUrl;
-							storeAds.storeName = storeAds.store.storeName;
-							storeAds.description = storeAds.store.description;
-
-							// 获取店铺订单数量信息
-							Order.countOneStoreOrder({storeUuid : storeAds.store.uuid}, {}, function (data) {
-								storeAds.orderCount = data.orderCount || 0;
-							}, function () {
-								storeAds.orderCount = 0;
-							});
-						}
+			StoreInfo.findTopStoreBySales({ isOriginal: true }, {}, function (stores) {
+				$scope.topSalesStores = stores || [];
+				angular.forEach($scope.topSalesStores, function (store) {
+					Order.countOneStoreOrder({storeUuid : store.uuid}, {}, function (data) {
+						store.orderCount = data.orderCount || 0;
+					}, function () {
+						store.orderCount = 0;
 					});
-				} else {
-					$scope.topSalesStores = [];
-				}
-			}, function (error) {
-				console.log(error);
-				$scope.topSalesStores = [];
+				});
+			}, function (resp) {
 			});
 
 			/**

+ 9 - 23
src/main/webapp/resources/js/provider/controllers/ProviderHomeCtrl.js

@@ -32,30 +32,16 @@ define(['app/app'], function(app) {
 		/**
 		 * 获取销售排行信息
 		 */
-		StoreAdsInformation.showSalesListWhenUserQuery({types: 'AGENCY,DISTRIBUTION'}, {}, function (data) {
-			if (angular.isArray(data) && data.length > 0) {
-				$scope.topSalesStores = data;
-				angular.forEach(data, function (storeAds) {
-					if (storeAds.store) {
-						storeAds.uuid = storeAds.store.uuid;
-						storeAds.logoUrl = storeAds.store.logoUrl;
-						storeAds.storeName = storeAds.store.storeName;
-						storeAds.description = storeAds.store.description;
-
-						// 获取店铺订单数量信息
-						Order.countOneStoreOrder({storeUuid : storeAds.store.uuid}, {}, function (data) {
-							storeAds.orderCount = data.orderCount || 0;
-						}, function () {
-							storeAds.orderCount = 0;
-						});
-					}
+		StoreInfo.findTopStoreBySales({ isOriginal: false }, {}, function (stores) {
+			$scope.topSalesStores = stores || [];
+			angular.forEach($scope.topSalesStores, function (store) {
+				Order.countOneStoreOrder({storeUuid : store.uuid}, {}, function (data) {
+					store.orderCount = data.orderCount || 0;
+				}, function () {
+					store.orderCount = 0;
 				});
-			} else {
-				$scope.topSalesStores = [];
-			}
-		}, function (error) {
-			console.log(error);
-			$scope.topSalesStores = [];
+			});
+		}, function (resp) {
 		});
 
 		/**

+ 1 - 1
src/main/webapp/resources/view/provider/home/sale_outstanding_store.html

@@ -74,7 +74,7 @@
 			<span>销售排行榜</span>
 		</div>
 		<ul class="list-unstyled list-inline">
-			<li ng-repeat="store in topSalesStores | orderBy: '-orderCount'">
+			<li ng-repeat="store in topSalesStores">
 				<div class="rank" ng-switch="$index">
 					<img ng-switch-when="0" src="static/img/store/home/first.png" width="40" height="33" />
 					<img ng-switch-when="1" src="static/img/store/home/second.png" width="40" height="33" />