Sfoglia il codice sorgente

配送规则增加空值判断

hulh 8 anni fa
parent
commit
2b875541a9

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

@@ -49,7 +49,7 @@ public class DistributionRuleController {
 	 * @return
 	 */
 	@RequestMapping(value = "/save", method = RequestMethod.POST)
-	public DistributionRule saveRule(Boolean isAdd, Boolean isActive, @RequestBody String json){
+	public ResultMap saveRule(Boolean isAdd, Boolean isActive, @RequestBody String json){
 		System.out.println(json + "=" + isActive + "=" + isAdd);
 		DistributionRule rule = FastjsonUtils.fromJson(json, DistributionRule.class);
 		return distributionRuleService.saveDistributionRule(isAdd, isActive, rule);

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

@@ -27,7 +27,7 @@ public interface DistributionRuleService {
 	 * @param rule
 	 * @return
 	 */
-	DistributionRule saveDistributionRule(Boolean isAdd, Boolean isActive, DistributionRule rule);
+	ResultMap saveDistributionRule(Boolean isAdd, Boolean isActive, DistributionRule rule);
 
 	/**
 	 * 根据id删除指定配送规则

+ 18 - 4
src/main/java/com/uas/platform/b2c/logistics/service/impl/DistributionRuleServiceImpl.java

@@ -6,6 +6,7 @@ import com.uas.platform.b2c.logistics.dao.DistributionRuleDao;
 import com.uas.platform.b2c.logistics.model.DistributionRule;
 import com.uas.platform.b2c.logistics.model.RuleQtyArea;
 import com.uas.platform.b2c.logistics.service.DistributionRuleService;
+import com.uas.platform.b2c.trade.support.CodeType;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
@@ -48,7 +49,19 @@ public class DistributionRuleServiceImpl implements DistributionRuleService{
 	}
 
 	@Override
-	public DistributionRule saveDistributionRule(Boolean isAdd, Boolean isActive, DistributionRule rule) {
+	public ResultMap saveDistributionRule(Boolean isAdd, Boolean isActive, DistributionRule rule) {
+		if (rule.getShippingMethod() == null){
+			return new ResultMap(CodeType.NO_INFO, "请选择配送方式");
+		}
+		if (rule.getRuleName() == null || rule.getRuleName().isEmpty()){
+			return new ResultMap(CodeType.NO_INFO, "请填写规则名称");
+		}
+		if (rule.getQtyArea() == null || rule.getQtyArea().isEmpty()){
+			return new ResultMap(CodeType.NO_INFO, "您还没有选择任何地区");
+		}
+		if (rule.getFareType() == 2 && (rule.getQtyFare() == null || rule.getQtyArea().isEmpty())){
+			return new ResultMap(CodeType.NO_INFO, "请完善计费方式");
+		}
 		if (rule.getId() == null){
 			Long uu = SystemSession.getUser().getUserUU();
 			Long enuu = SystemSession.getUser().getEnterprise().getUu();
@@ -97,7 +110,8 @@ public class DistributionRuleServiceImpl implements DistributionRuleService{
 				}
 			}
 		}
-		return distributionRuleDao.save(rule);
+		distributionRuleDao.save(rule);
+		return ResultMap.success(null);
 	}
 
 	public void sortRule(Long id, int num){
@@ -108,7 +122,7 @@ public class DistributionRuleServiceImpl implements DistributionRuleService{
 			if (rule.getId() != id){
 				if (start == num){
 					start++;
-					System.out.println("start=" + start);
+//					System.out.println("start=" + start);
 				}
 				rule.setNum(start++);
 			}
@@ -117,7 +131,7 @@ public class DistributionRuleServiceImpl implements DistributionRuleService{
 	}
 
 	public void sortRule(int num){
-		System.out.println("num=" + num);
+//		System.out.println("num=" + num);
 		Long enuu = SystemSession.getUser().getEnterprise().getUu();
 		List<DistributionRule> ruleList = distributionRuleDao.findAllByEnuu(enuu);
 		int start = 1;

+ 11 - 8
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_deliveryRule_ctrl.js

@@ -186,7 +186,7 @@ define([ 'app/app' ], function(app) {
                 }
             }
             if ($scope.nameError){
-                toaster.pop("error", "最多可输入10个文字")
+                toaster.pop("error", "规则名称,最多可输入10个文字")
                 return;
             }
         };
@@ -242,10 +242,6 @@ define([ 'app/app' ], function(app) {
         };
 
         $scope.inputUniform = function () {
-            // if(!$scope.modifyRule.uniformPrice) {
-            //     $scope.modifyRule.uniformPrice = 0;
-            //     return false;
-            // }
             if(isNaN($scope.modifyRule.uniformPrice)){
                 $scope.modifyRule.uniformPrice = "";
                 toaster.pop('warning', '提示', '运费必须是整数');
@@ -331,7 +327,7 @@ define([ 'app/app' ], function(app) {
                 return false;
             }
             if($scope.nameError){
-                toaster.pop('error', "最多可输入10个文字");
+                toaster.pop('error', "规则名称,最多可输入10个文字");
                 return false;
             }
             if($scope.repeatError){
@@ -401,7 +397,6 @@ define([ 'app/app' ], function(app) {
                         $scope.repeatError = data[0].data;
                     }
                     var valid = checkRuleError();
-                    console.log(valid);
                     if (!valid){
                         return;
                     }
@@ -426,7 +421,7 @@ define([ 'app/app' ], function(app) {
 
                     if (valid){
                         DistributionRule.saveRule({isAdd:isAdd, isActive:$scope.isActive}, $scope.modifyRule , function (data) {
-                            if (data){
+                            if (data.success){
                                 $scope.editFrame = false;
                                 $scope.tab = 'deliverRule';
                                 if (isAdd){
@@ -434,6 +429,9 @@ define([ 'app/app' ], function(app) {
                                 }else{
                                     toaster.pop('info', "新增规则成功");
                                 }
+                            }else {
+                                toaster.pop('error', data.message);
+                                return;
                             }
                         },function (error) {
                             toaster.pop('error', "保存配送规则失败");
@@ -467,6 +465,11 @@ define([ 'app/app' ], function(app) {
         $scope.resetData = function (items) {
             angular.forEach(items, function (item) {
                 item.checked = false;
+                if (item.parent == null){
+                    item.folded = false;
+                }else {
+                    item.folded = true;
+                }
                 item.selectedNum = 0;
                 if (item.items){
                     $scope.resetData(item.items);

+ 97 - 57
src/main/webapp/resources/view/vendor/forstore/vendor_delivery_rule.html

@@ -319,36 +319,36 @@
 			<div class="rule-content">
 				<!--暂时注释,在以后的开发中在释放出来-->
 				<!--<div class="row check-1">-->
-					<!--<span><strong>*</strong>适用类型</span>-->
-					<!--<label class="check-act">-->
-						<!--<input type="checkbox" id="1" ng-model="orderType.normal"/>-->
-						<!--<label for="1"></label>-->
-						<!--普通订单-->
-					<!--</label>-->
-					<!--<label class="check-act">-->
-						<!--<input type="checkbox" id="2" ng-model="orderType.preSale"/>-->
-						<!--<label for="2"></label>-->
-						<!--预售订单-->
-					<!--</label>-->
-					<!--<label class="check-act">-->
-						<!--<input type="checkbox" id="3" ng-modle="orderType.bill"/>-->
-						<!--<label for="3"></label>-->
-						<!--发票-->
-					<!--</label>-->
-					<!--<span>适用用户</span>-->
-					<!--<select class="select-adder form-control for-people" ng-model="modifyRule.userType">-->
-						<!--<option value="1301">所有用户</option>-->
-					<!--</select>-->
+				<!--<span><strong>*</strong>适用类型</span>-->
+				<!--<label class="check-act">-->
+				<!--<input type="checkbox" id="1" ng-model="orderType.normal"/>-->
+				<!--<label for="1"></label>-->
+				<!--普通订单-->
+				<!--</label>-->
+				<!--<label class="check-act">-->
+				<!--<input type="checkbox" id="2" ng-model="orderType.preSale"/>-->
+				<!--<label for="2"></label>-->
+				<!--预售订单-->
+				<!--</label>-->
+				<!--<label class="check-act">-->
+				<!--<input type="checkbox" id="3" ng-modle="orderType.bill"/>-->
+				<!--<label for="3"></label>-->
+				<!--发票-->
+				<!--</label>-->
+				<!--<span>适用用户</span>-->
+				<!--<select class="select-adder form-control for-people" ng-model="modifyRule.userType">-->
+				<!--<option value="1301">所有用户</option>-->
+				<!--</select>-->
 				<!--</div>-->
 				<div class="row" style="position: relative;">
 					<span><strong>*</strong>适用地区</span>
 					<div class="area-content" ng-if="mapArray.length >0">
-						<span ng-repeat="data in mapArray" ng-click="deleteMapItem($index)">
+						<span ng-repeat="data in mapArray">
 							<em ng-if="!data.province">{{data.mainland}}</em>
 							<em ng-if="data.province">{{data.province}}</em>
 							<em ng-if="data.city">/{{data.city}}</em>
 							<em ng-if="data.area">/{{data.area}}</em>
-							<i class="fa fa-minus-circle"></i>
+							<i class="fa fa-minus-circle" ng-click="deleteMapItem($index)"></i>
 						</span>
 					</div>
 					<button ng-click="chooseAddress()">选择地区</button>
@@ -439,7 +439,7 @@
 				</div>
 				<!--统一规定运费-->
 				<div class="style-regulations common-style" ng-if="modifyRule.fareType==1">
-					<div class="row dot">
+					<div class="row dot" style="padding-bottom: 10px;">
 						<span>统一运费</span>
 						<div class="price-input">
 							<i class="currency" ng-bind="currencySymbol"></i>
@@ -450,8 +450,8 @@
 						<span class="f14" style="margin-right: 10px;">计算说明</span>
 						<!--&lt;!&ndash;可编辑&ndash;&gt;-->
 						<!--<div class="edit" style="margin-top: 6px;">-->
-							<!--<textarea class="form-control" placeholder="全国统一运费 $20"></textarea>-->
-							<!--<div class="prompt"><strong>*</strong>公式说明内容将会在购物车中显示,可自行修改</div>-->
+						<!--<textarea class="form-control" placeholder="全国统一运费 $20"></textarea>-->
+						<!--<div class="prompt"><strong>*</strong>公式说明内容将会在购物车中显示,可自行修改</div>-->
 						<!--</div>-->
 						<!--不可以编辑的状态-->
 						<div class="no-edit" style="margin-top: 6px;">全国统一运费
@@ -460,31 +460,52 @@
 						</div>
 					</div>
 				</div>
+				<style>
+					.rule-main .rule-content .common-style .hr01{
+						float: left;
+						width: 14px;
+						text-align: center;
+						color: #666;
+					}
+					.rule-main .rule-content .common-style .price-input input.none{
+						background: #dad8d8;
+					}
+					.rule-main .rule-content .common-style .price-input input.none:hover{
+						cursor: not-allowed;
+					}
+					.add-box{
+						margin-right: 412px;
+						float: right;
+					}
+				</style>
 				<!--按总金额计算-->
 				<div class="style-price common-style" ng-if="modifyRule.fareType==2">
-					<div class="row" ng-repeat="data in fareArray" ng-class="{'dot' : $index==0}">
-						<span>总金额在</span>
+					<div class="row" ng-repeat="data in fareArray" ng-class="{'dot' : $index==0,'active': $index == fareArray.length - 1}">
+						<span style="margin-right: 7px;">总金额在</span>
 						<div class="price-input" ng-if="$index == 0">
 							<i class="currency" ng-bind="currencySymbol"></i>
-							<input type="text" class="form-control" placeholder="请输入金额" ng-blur="inputQtyFare(data, $index)" ng-model="data.end" />
-							以下,
+							<span ng-bind="data.start"></span>
+							<!--<input type="text" class="form-control none" ng-model="data.start" disabled/>-->
 						</div>
 						<div class="price-input" ng-if="$index != 0 && $index != fareArray.length - 1">
-							<em>
-								<i ng-bind="currencySymbol"></i><i ng-if="fareArray[$index-1].end">{{fareArray[$index-1].end}}</i>以上,
-							</em>
-							<i class="currency" ng-if="currencySymbol">¥</i>
+							<i class="currency" ng-bind="currencySymbol"></i>
+							<span ng-bind="fareArray[$index-1].end"></span>
+							<!--<input type="text" class="form-control none" ng-model="data.start" disabled/>-->
+						</div>
+						<div class="hr01" ng-if="$index != fareArray.length - 1">&#150;</div>
+						<div class="price-input" ng-if="$index != fareArray.length - 1">
+							<i class="currency" ng-bind="currencySymbol"></i>
 							<input type="text" class="form-control" placeholder="请输入金额" ng-blur="inputQtyFare(data, $index)" ng-model="data.end" />
-							<em>以下,</em>
 						</div>
 						<div class="price-input" ng-if="$index == fareArray.length - 1">
-							<em>
-								<i ng-bind="currencySymbol"></i><i ng-if="fareArray[$index-1].end">{{fareArray[$index-1].end}}</i>以上,
-							</em>
+							<i class="currency" ng-bind="currencySymbol"></i>
+							<span ng-bind="fareArray[$index-1].end"></span>
+							<!--<input type="text" class="form-control none" ng-model="fareArray[$index-1].end" disabled/>-->
+							&nbsp;&nbsp;&nbsp;以上
 						</div>
 						<div class="price-input">
-							<em>运费为</em>
-							<i class="currency" ng-if="currencySymbol">¥</i>
+							<em>运费为</em>
+							<i class="currency" ng-bind="currencySymbol"></i>
 							<input type="text" class="form-control" placeholder="请输入运费" ng-blur="inputFare(data)" ng-model="data.fare" />
 						</div>
 						<div class="add-box">
@@ -510,27 +531,27 @@
 						<div class="no-edit" style="margin-top: 6px;">
 							<div ng-repeat="data in fareArray">
 								<p ng-if="$index == 0">
-									总价在
-									<i class="currency" ng-bind="currencySymbol">¥</i><i class="input-text" ng-bind="data.end"></i>以下,
+									总金额在
+									<i class="currency" ng-bind="currencySymbol">¥</i><i class="input-text" ng-bind="data.start"></i>
+									-&nbsp;<i class="input-text" ng-bind="data.end"></i>&nbsp;,
 									运费为
 									<i class="currency" ng-bind="currencySymbol">¥</i>{{data.fare}}
 								</p>
 								<p ng-if="$index != 0 && $index != fareArray.length - 1">
-									总
+									总金额
 									<i class="currency" ng-bind="currencySymbol">¥</i>
-									<i class="input-text">{{data.start}}</i>以上(含
+									<i class="input-text" ng-bind="data.start"></i>
+									-&nbsp;<i class="input-text" ng-bind="data.end"></i>(含
 									<i class="currency" ng-bind="currencySymbol">¥</i>{{data.start}}),
-									<i class="currency" ng-bind="currencySymbol">¥</i>
-									<i class="input-text">{{data.end}}</i>以下,
 									运费为
-									<i class="currency" ng-bind="currencySymbol">¥</i>{{data.fare}}
+									<i class="currencys" ng-bind="currencySymbol">¥</i>{{data.fare}}
 								</p>
 								<p ng-if="$index == fareArray.length-1">
-									总
+									总金额
 									<i class="currency" ng-bind="currencySymbol">¥</i>
-									<i class="input-text">{{data.start}}</i>以上(含
+									<i class="input-text">{{data.start}}</i>(含
 									<i class="currency" ng-bind="currencySymbol">¥</i>
-									{{data.start}}),运费为
+									{{data.start}})以上,运费为
 									<i class="currency" ng-bind="currencySymbol">¥</i>{{data.fare}}
 								</p>
 							</div>
@@ -729,11 +750,15 @@
 		margin-right: 0 auto;
 	}
 	.rule-main .rule-content .common-style .row{
-		padding: 8px;
+		padding: 0 8px;
+		padding-top: 10px;
 		background: #e8e7e7;
-		min-height: 40px;
+		/*min-height: 40px;*/
 		font-size: 12px;
 	}
+	.rule-main .rule-content .common-style .row.active{
+		padding-bottom: 10px;
+	}
 	.rule-main .rule-content .common-style .row span{
 		font-size: 12px;
 	}
@@ -743,9 +768,21 @@
 		position: relative;
 		z-index: 10;
 	}
+	.rule-main .rule-content .common-style .price-input span{
+		border-radius: 0;
+		height: 26px;
+		line-height: 26px;
+		border: #d4d4d4 1px solid;
+		background: #dad8d8;
+		display: inline-block;
+		width: 80px;
+		text-align: center;
+		overflow: hidden;
+		margin-right: 0;
+	}
 	.rule-main .rule-content .common-style .price-input em{
 		float: left;
-		margin: 0 5px;
+		margin: 0 7px 0 0;
 	}
 	.rule-main .rule-content .common-style .price-input em i{
 		margin-right: 20px;
@@ -757,9 +794,10 @@
 	.rule-main .rule-content .common-style.style-price .row .no-edit p i.input-text{
 		display: inline-block;
 		max-width: 60px;
+		height: 15px;
 		overflow: hidden;
 		position: relative;
-		top: 8px;
+		top: 1px;
 		margin-right: 5px;
 	}
 	.rule-main .rule-content .common-style .price-input i.currency{
@@ -770,13 +808,14 @@
 		background: #b0b0b0;
 		color: #fff;
 		float: left;
-		border-bottom-left-radius: 3px;
-		border-top-left-radius: 3px;
+		margin-right: -1px;
+		/*border-bottom-left-radius: 3px;*/
+		/*border-top-left-radius: 3px;*/
 	}
 	.rule-main .rule-content .common-style .price-input input{
 		max-width: 80px;
 		padding: 0;
-		margin-right: 3px !important;
+		margin-right: 0 !important;
 		position: relative;
 		/*left: -1px;*/
 		font-size: 12px;
@@ -904,7 +943,8 @@
 		padding: 8px 10px;
 	}
 	.rule-main .rule-content .common-style.style-price .row .no-edit p{
-		line-height: 25px;
+		line-height: 20px;
+		height: 20px;
 	}
 	.rule-main .rule-content .common-style .row{
 		position: relative;