Browse Source

Merge remote-tracking branch 'origin/feature-logisticsModify-hulh-1128' into logisticsModify-hb-1129

hangb 8 years ago
parent
commit
13d9040859

+ 5 - 0
src/main/java/com/uas/platform/b2c/external/erp/order/service/impl/OrderServiceImpl.java

@@ -123,4 +123,9 @@ public class OrderServiceImpl implements OrderService {
 		}
 		return true;
 	}
+
+	@Override
+	public Long findAdminuu() {
+		return null;
+	}
 }

+ 53 - 0
src/main/java/com/uas/platform/b2c/logistics/constant/TipType.java

@@ -0,0 +1,53 @@
+package com.uas.platform.b2c.logistics.constant;
+
+/**
+ * 提示类型码
+ * @author hulh 10点16分
+ */
+public enum TipType {
+	/**
+	 * {@code 1201 适用于普通订单}
+	 */
+	TIP_LOGISTICS(101, "配送规则提示");
+
+
+	TipType(int value, String phrase) {
+		this.value = value;
+		this.phrase = phrase;
+	}
+	private final int value;
+
+	private final String phrase;
+
+	public int getValue() {
+		return this.value;
+	}
+
+	public String getPhrase() {
+		return this.phrase;
+	}
+
+	/**
+	 * @param statusCode 状态的编码
+	 * @return 状态
+	 * @throws IllegalArgumentException
+	 *             如果statusCode不存在的话
+	 */
+	public static TipType valueOf(int statusCode) {
+		for (TipType status : values()) {
+			if (status.value == statusCode) {
+				return status;
+			}
+		}
+		throw new IllegalArgumentException("没有与编号 [" + statusCode + "]匹配的类型");
+	}
+
+	/**
+	 * 返回状态码的编号
+	 * @return
+	 */
+	@Override
+	public String toString() {
+		return Integer.toString(value);
+	}
+}

+ 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

+ 28 - 0
src/main/java/com/uas/platform/b2c/logistics/controller/TipRecordController.java

@@ -0,0 +1,28 @@
+package com.uas.platform.b2c.logistics.controller;
+
+import com.uas.platform.b2c.logistics.model.TipRecord;
+import com.uas.platform.b2c.logistics.service.TipRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 提示记录Controller
+ * @author hulh
+ */
+@RestController
+@RequestMapping("/tip/record")
+public class TipRecordController {
+
+	@Autowired
+	private TipRecordService tipRecordService;
+
+	/**
+	 * 根据当前userUu查询配送规则提示
+	 */
+	@RequestMapping(value = "/rule", method = RequestMethod.GET)
+	public TipRecord findUnavailable() {
+		return tipRecordService.findByUserUuOfRule();
+	}
+}

+ 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

+ 21 - 0
src/main/java/com/uas/platform/b2c/logistics/dao/TipRecordDao.java

@@ -0,0 +1,21 @@
+package com.uas.platform.b2c.logistics.dao;
+
+import com.uas.platform.b2c.logistics.model.TipRecord;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+/**
+ * 提示记录dao层
+ */
+@Repository
+public interface TipRecordDao extends JpaSpecificationExecutor<TipRecord>, JpaRepository<TipRecord, Long> {
+
+	/**
+	 * 根据类型返回提示记录
+	 * @param useruu
+	 * @param type
+	 * @return
+	 */
+	TipRecord findByUseruuAndType(Long useruu, Integer type);
+}

+ 84 - 0
src/main/java/com/uas/platform/b2c/logistics/model/TipRecord.java

@@ -0,0 +1,84 @@
+package com.uas.platform.b2c.logistics.model;
+
+import javax.persistence.*;
+
+/**
+ * 提示记录
+ * @author hulh
+ */
+@Entity
+@Table(name = "tip_record")
+public class TipRecord {
+
+	/**
+	 * 主键id
+	 */
+	@Id
+	@GeneratedValue
+	@Column(name = "tip_id")
+	private Long id;
+
+	/**
+	 * 用户uu
+	 */
+	@Column(name = "tip_uu")
+	private Long useruu;
+
+	/**
+	 * 企业enuu
+	 */
+	@Column(name = "tip_enuu")
+	private Long enuu;
+
+	/**
+	 * 是否再提示 1 再提示 0 不再提示
+	 */
+	@Column(name = "tip_again")
+	private Short tipAgain;
+
+	/**
+	 * 提示类型
+	 */
+	@Column(name = "tip_type")
+	private Integer type;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Long getUseruu() {
+		return useruu;
+	}
+
+	public void setUseruu(Long useruu) {
+		this.useruu = useruu;
+	}
+
+	public Long getEnuu() {
+		return enuu;
+	}
+
+	public void setEnuu(Long enuu) {
+		this.enuu = enuu;
+	}
+
+	public Short getTipAgain() {
+		return tipAgain;
+	}
+
+	public void setTipAgain(Short tipAgain) {
+		this.tipAgain = tipAgain;
+	}
+
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+}

+ 2 - 1
src/main/java/com/uas/platform/b2c/logistics/model/UsableRuleInfo.java

@@ -21,7 +21,8 @@ public class UsableRuleInfo {
 					TAKE_SELF_RULE = new UsableRuleInfo();
 					TAKE_SELF_RULE.setMethod(Type.Delivery_BySelf_Code.value());
 					TAKE_SELF_RULE.setRuleName(TAKE_SELF_NAME);
-					TAKE_SELF_RULE.setFare(0d);
+					TAKE_SELF_RULE.setFare(0d); //运费默认为0
+					TAKE_SELF_RULE.setFareType((short)1); //运费类型默认为统一运费
 				}
 			}
 		}

+ 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

+ 16 - 0
src/main/java/com/uas/platform/b2c/logistics/service/TipRecordService.java

@@ -0,0 +1,16 @@
+package com.uas.platform.b2c.logistics.service;
+
+import com.uas.platform.b2c.logistics.model.TipRecord;
+
+/**
+ * 提示记录Service
+ * @author hulh
+ */
+public interface TipRecordService {
+
+	/**
+	 * 根据userUu查询配送规则提示记录
+	 * @return
+	 */
+	TipRecord findByUserUuOfRule();
+}

+ 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

+ 43 - 0
src/main/java/com/uas/platform/b2c/logistics/service/impl/TipRecordServiceImpl.java

@@ -0,0 +1,43 @@
+package com.uas.platform.b2c.logistics.service.impl;
+
+import com.uas.platform.b2c.common.account.model.User;
+import com.uas.platform.b2c.core.constant.ShortConstant;
+import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.logistics.constant.TipType;
+import com.uas.platform.b2c.logistics.dao.TipRecordDao;
+import com.uas.platform.b2c.logistics.model.TipRecord;
+import com.uas.platform.b2c.logistics.service.TipRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author hulh
+ */
+@Service
+public class TipRecordServiceImpl implements TipRecordService {
+
+	@Autowired
+	private TipRecordDao tipRecordDao;
+
+	@Override
+	public TipRecord findByUserUuOfRule() {
+		User user = SystemSession.getUser();
+		TipRecord record =  tipRecordDao.findByUseruuAndType(user.getUserUU(),
+				TipType.TIP_LOGISTICS.getValue());
+		if (record == null){
+			return newOneRecord(user);
+		}
+		return record;
+	}
+
+	@Transactional
+	private TipRecord newOneRecord(User user){
+		TipRecord record = new TipRecord();
+		record.setEnuu(user.getEnterprise().getUu());
+		record.setUseruu(user.getUserUU());
+		record.setType(TipType.TIP_LOGISTICS.getValue());
+		record.setTipAgain(ShortConstant.NO_SHORT);
+		return tipRecordDao.save(record);
+	}
+}

+ 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>