Browse Source

配送规则和产品管理添加提示

hulh 8 years ago
parent
commit
eef9c07762

+ 9 - 0
src/main/java/com/uas/platform/b2c/logistics/controller/DistributionRuleController.java

@@ -90,6 +90,15 @@ public class DistributionRuleController {
 		return distributionRuleService.findCountRule();
 	}
 
+	/**
+	 * 返回当前enuu启用配送规则总数
+	 * @return
+	 */
+	@RequestMapping(value = "/active/count", method = RequestMethod.GET)
+	public ResultMap findActiveRuleCount(){
+		return distributionRuleService.findCountActiveRule();
+	}
+
 	/**
 	 * 查找配送规则名是否存在
 	 * @param id

+ 8 - 0
src/main/java/com/uas/platform/b2c/logistics/dao/DistributionRuleDao.java

@@ -33,6 +33,14 @@ public interface DistributionRuleDao extends JpaSpecificationExecutor<Distributi
 	@Query(value = "select count(1) from DistributionRule d where d.enuu = :enuu")
 	int findCountByEnuu(@Param("enuu") Long enuu);
 
+	/**
+	 * 根据enuu查询启用的配送规则数
+	 * @param enuu
+	 * @return
+	 */
+	@Query(value = "select count(1) from DistributionRule d where d.enuu = :enuu and d.active = 1")
+	int findCountByEnuuAndActive(@Param("enuu") Long enuu);
+
 	/**
 	 * 根据enuu获取所有的配送规则
 	 * @param enuu

+ 7 - 0
src/main/java/com/uas/platform/b2c/logistics/service/DistributionRuleService.java

@@ -58,6 +58,13 @@ public interface DistributionRuleService {
 	 */
 	ResultMap findCountRule();
 
+	/**
+	 * 返回当前enuu下启用配送规则总数
+	 * @return
+	 */
+	ResultMap findCountActiveRule();
+
+
 	/**
 	 * 查找是否已存在该名称
 	 * @param id

+ 14 - 0
src/main/java/com/uas/platform/b2c/logistics/service/impl/DistributionRuleServiceImpl.java

@@ -227,6 +227,20 @@ public class DistributionRuleServiceImpl implements DistributionRuleService{
 		return ResultMap.success(count);
 	}
 
+	/**
+	 * 查询已设置配送规则的数量,启用的
+	 * @return
+	 */
+	@Override
+	public ResultMap findCountActiveRule() {
+		Long enuu = SystemSession.getUser().getEnterprise().getUu();
+		List<StoreIn> storeList = storeInDao.findByEnUU(enuu);
+		int count = distributionRuleDao.findCountByEnuuAndActive(enuu);
+		if (count == 0 && !CollectionUtils.isEmpty(storeList))
+			return ResultMap.success(true);
+		return ResultMap.success(false);
+	}
+
 	/**
 	 * 根据配送规则名称查询是否已存在
 	 * @param id

+ 4 - 0
src/main/webapp/resources/js/common/query/logisticsPort.js

@@ -107,6 +107,10 @@ define([ 'ngResource' ], function() {
 				url: 'trade/distributionRule/count',
 				method: 'GET'
 			},
+			findCountOfActiveRule : {
+				url: 'trade/distributionRule/active/count',
+				method: 'GET'
+			},
 			checkRuleName : {
 				url: 'trade/distributionRule/checkName',
 				method: 'GET'

+ 16 - 1
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_index_ctrl.js

@@ -4,7 +4,7 @@
  */
 define(['app/app', 'calendar'], function(app) {
     'use strict';
-    app.register.controller('vendorIndexCtrl', ['$scope', 'toaster', 'VendorService', '$rootScope', 'News', '$filter', function($scope, toaster, VendorService, $rootScope, News, $filter) {
+    app.register.controller('vendorIndexCtrl', ['$scope', 'toaster', 'VendorService', '$rootScope', 'News', '$filter', 'DistributionRule', function($scope, toaster, VendorService, $rootScope, News, $filter, DistributionRule) {
         document.title = '卖家中心-优软商城';
         $rootScope.active = 'index';
         VendorService.getVendorInfo(null, function(data){
@@ -36,6 +36,21 @@ define(['app/app', 'calendar'], function(app) {
         // }, function (res) {
         //
         // });
+
+        var initRuleCount = function () {
+            DistributionRule.findCountOfActiveRule({},{},function (data) {
+                if (data.success){
+                    $scope.needShowTip = data.data;
+                }
+            }, function (error) {
+                toaster.pop("error", error.data);
+            })
+        };
+        initRuleCount();
+
+        $scope.cancelDelete = function () {
+            $scope.showNoRuleTip = false;
+        }
         
     }]);
 });

+ 21 - 3
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_materialCtrl.js

@@ -1,6 +1,6 @@
 define([ 'app/app' ], function(app) {
 	'use strict';
-	app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService) {
+	app.register.controller('vendor_materialCtrl', ['$scope', '$rootScope', 'Material', 'toaster', 'ComponentActive', 'Enterprise', '$q', 'NumberService', 'DistributionRule', function ($scope, $rootScope, Material, toaster, ComponentActive, Enterprise, $q, NumberService, DistributionRule) {
 		$rootScope.active = 'vendor_material';
 		document.title = '卖家产品库-优软商城';
 		$scope.tab = 'material';
@@ -154,6 +154,17 @@ define([ 'app/app' ], function(app) {
 			checkChoosedAll();
 		};
 
+		var initRuleCount = function () {
+			DistributionRule.findCountOfActiveRule({},{},function (data) {
+				if (data.success){
+					$scope.needShowTip = data.data;
+				}
+			}, function (error) {
+				toaster.pop("error", error.data);
+			})
+		};
+		initRuleCount();
+
 		//获取选中之后的信息
 		$scope.getChoosedInfo = function () {
 			angular.forEach($scope.currenctMaterial, function (material) {
@@ -510,8 +521,11 @@ define([ 'app/app' ], function(app) {
 		function publishGoods(product) {
 			if (!validateGoods($scope.goods)) return ;
 
-			console.log('product', product);
-			console.log($scope.goods);
+			if ($scope.needShowTip) {
+				$scope.showNoRuleTip = true;
+				return;
+			}
+
 			$scope.goods.breakUp = 1 === $scope.goods.breakUp;
 			$scope.isSelfSupport = 1 === $scope.goods.isSelfSupport;
 			Material.newStockByStandardProduct({ id: product.id, isSelfSupport: $scope.isSelfSupport}, $scope.goods, function (result) {
@@ -526,6 +540,10 @@ define([ 'app/app' ], function(app) {
 			});
 		}
 
+		$scope.cancelDelete = function () {
+			$scope.showNoRuleTip = false;
+		};
+
 		/**
 		 * 验证商品信息
 		 *

+ 3 - 3
src/main/webapp/resources/view/vendor/forstore/vendor_index.html

@@ -180,12 +180,12 @@
     </div>
 </div>
 <!--未设置配送规则提醒-->
-<div class="com-del-box">
+<div class="com-del-box" ng-if="showNoRuleTip">
     <div class="title">
-        <a ng-click="cancleDelete()"><i class="fa fa-close fa-lg"></i></a>
+        <a ng-click="cancelDelete()"><i class="fa fa-close fa-lg"></i></a>
     </div>
     <div class="content">
         <p><i class="fa fa-exclamation-circle"></i><span>您的店铺尚未设置配送规则,无法计算运费,建议尽快设置!</span></p>
-        <div><a ng-click="cancleDelete()">以后再说</a><a ng-click="cancleDelete()">立即设置</a></div>
+        <div><a ng-click="cancelDelete()">以后再说</a><a href="">立即设置</a></div>
     </div>
 </div>

+ 3 - 3
src/main/webapp/resources/view/vendor/forstore/vendor_material.html

@@ -709,13 +709,13 @@
 	</div>
 </div>
 <!--上架设置提醒-->
-<div class="com-del-box">
+<div class="com-del-box" ng-if="showNoRuleTip">
 	<div class="title">
-		<a ng-click="cancleDelete()"><i class="fa fa-close fa-lg"></i></a>
+		<a ng-click="cancelDelete()"><i class="fa fa-close fa-lg"></i></a>
 	</div>
 	<div class="content">
 		<p><i class="fa fa-exclamation-circle"></i><span>您当前尚未设置配送规则,买家将无法下单,建议尽快设置!</span></p>
-		<div><a ng-click="cancleDelete()">立即设置</a></div>
+		<div><a >立即设置</a></div>
 	</div>
 </div>