Browse Source

映射配送规则到结算页,添加配送规则和自提点信息

hulh 8 years ago
parent
commit
5cdf0f20e7

+ 12 - 0
src/main/java/com/uas/platform/b2c/logistics/controller/AddressTakeSelfController.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2c.logistics.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
 import com.uas.platform.b2c.logistics.model.AddressTakeSelf;
 import com.uas.platform.b2c.logistics.service.AddressTakeSelfService;
@@ -9,6 +10,7 @@ import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * Created by hulh on 2017/8/11.
@@ -76,4 +78,14 @@ public class AddressTakeSelfController {
 	public List<String> findAllTakeSelfName(){
 		return addressTakeSelfService.findAllTakeSelfName();
 	}
+
+	/**
+	 * 根据店铺list获取自提点信息
+	 * @param info
+	 * @return
+	 */
+	@RequestMapping(value = "/store/takeSelf", method = RequestMethod.POST)
+	public Map<String, List<AddressTakeSelf>> findStoreTakeSelf(@RequestBody List<JSONObject> info){
+		return addressTakeSelfService.findTakeSelfByStore(info);
+	}
 }

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

@@ -126,8 +126,12 @@ public class DistributionRuleController {
 		return distributionRuleService.findRuleMatchArea(info, area);
 	}
 
-	@RequestMapping
-	public DistributionRule findMinRule(){
-		return null;
+	/**
+	 * 获取指定运费价格
+	 * @return
+	 */
+	@RequestMapping(value = "/fare", method = RequestMethod.POST)
+	public List<UsableRuleInfo> findFareRule(Double price, @RequestBody List<UsableRuleInfo> ruleList){
+		return distributionRuleService.findFareOfRule(ruleList, price);
 	}
 }

+ 4 - 0
src/main/java/com/uas/platform/b2c/logistics/model/UsableRuleInfo.java

@@ -34,6 +34,10 @@ public class UsableRuleInfo {
 	 */
 	private String currencyName;
 
+	public UsableRuleInfo(){
+
+	}
+
 	public UsableRuleInfo(DistributionRule rule){
 		this.id = rule.getId();
 		this.ruleName = rule.getRuleName();

+ 8 - 0
src/main/java/com/uas/platform/b2c/logistics/service/AddressTakeSelfService.java

@@ -1,10 +1,12 @@
 package com.uas.platform.b2c.logistics.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.logistics.model.AddressTakeSelf;
 import com.uas.platform.core.model.PageParams;
 import org.springframework.data.domain.Page;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * Created by hulh on 2017/8/11.
@@ -48,4 +50,10 @@ public interface AddressTakeSelfService {
 	 * @return
 	 */
 	List<String> findAllTakeSelfName();
+
+	/**
+	 * 根据企业列表获取自提点信息
+	 * @return
+	 */
+	Map<String, List<AddressTakeSelf>> findTakeSelfByStore(List<JSONObject> info);
 }

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

@@ -88,4 +88,12 @@ public interface DistributionRuleService {
 	 * @return
 	 */
 	Map<String, List<UsableRuleInfo>> findRuleMatchArea(List<JSONObject> uuidArray, String area);
+
+	/**
+	 * 更新指定运费
+	 * @param ruleList
+	 * @param price
+	 * @return
+	 */
+	List<UsableRuleInfo> findFareOfRule(List<UsableRuleInfo> ruleList, Double price);
 }

+ 25 - 0
src/main/java/com/uas/platform/b2c/logistics/service/impl/AddressTakeSelfServiceImpl.java

@@ -1,9 +1,13 @@
 package com.uas.platform.b2c.logistics.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.logistics.dao.AddressTakeSelfDao;
 import com.uas.platform.b2c.logistics.model.AddressTakeSelf;
 import com.uas.platform.b2c.logistics.service.AddressTakeSelfService;
+import com.uas.platform.b2c.prod.store.dao.StoreInDao;
+import com.uas.platform.b2c.prod.store.model.StoreIn;
+import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,7 +21,9 @@ import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Created by hulh on 2017/8/11.
@@ -25,9 +31,13 @@ import java.util.List;
 @Service
 @Transactional
 public class AddressTakeSelfServiceImpl implements AddressTakeSelfService {
+
 	@Autowired
 	private AddressTakeSelfDao addressTakeSelfDao;
 
+	@Autowired
+	private StoreInDao storeInDao;
+
 	@Override
 	public AddressTakeSelf saveTakeSelf(AddressTakeSelf addressTakeSelf, Boolean isActive) {
 		if (addressTakeSelf.getId() == null){
@@ -81,4 +91,19 @@ public class AddressTakeSelfServiceImpl implements AddressTakeSelfService {
 		Long enuu = SystemSession.getUser().getEnterprise().getUu();
 		return addressTakeSelfDao.findTakenameByEnuu(enuu);
 	}
+
+	@Override
+	public Map<String, List<AddressTakeSelf>> findTakeSelfByStore(List<JSONObject> info) {
+		Map<String, List<AddressTakeSelf>> map = new HashMap<>();
+		for (JSONObject object : info){
+			StoreIn store = storeInDao.findByUuid(object.getString("uuid"));
+			if (store == null){
+				throw new IllegalOperatorException("店铺信息丢失,请刷新后重试");
+			}
+			Long enuu = store.getEnUU();
+			List<AddressTakeSelf> list = addressTakeSelfDao.findByEnuuOrderByCreatetimeDesc(enuu);
+			map.put(object.getString("uuid"), list);
+		}
+		return map;
+	}
 }

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

@@ -265,6 +265,22 @@ public class DistributionRuleServiceImpl implements DistributionRuleService{
 		return distributionRuleDao.findShippingMethodByEnuuAndActive(enuu, ShortConstant.YES_SHORT);
 	}
 
+	@Override
+	public List<UsableRuleInfo> findFareOfRule(List<UsableRuleInfo> ruleList, Double price) {
+		if (CollectionUtils.isEmpty(ruleList)){
+			throw new IllegalOperatorException("配送规则信息丢失,请刷新后重试");
+		}
+		for (UsableRuleInfo info : ruleList){
+			DistributionRule rule = distributionRuleDao.findOne(info.getId());
+			if (rule == null){
+				throw new IllegalOperatorException("配送规则信息丢失,请刷新后重试");
+			}
+			Double fare = getFareOfRule(rule, price);
+			info.setFare(fare);
+		}
+		return null;
+	}
+
 	/**
 	 * 返回所有店铺适用的配送规则
 	 * @param uuidArray

+ 45 - 17
src/main/java/com/uas/platform/b2c/trade/order/model/Order.java

@@ -142,22 +142,34 @@ public class Order extends Document implements Serializable {
 	private Integer deliverytype;
 
 	/**
-	 * 拆单之前的配送方式,店铺id为key,配送方式为value
+	 * 运费
 	 */
-	@Column(name = "or_deliverytypes")
-	private String deliverytypes;
+	@Column(name = "or_fare")
+	private Double fare = 0d;
 
 	/**
-	 * 拆单之前的运费,店铺id为key,运费为value
+	 * 使用的配送规则
 	 */
-	@Column(name = "or_fares")
-	private String fares;
+	@Column(name = "or_rule", length = 2000)
+	private String jsonRule;
 
 	/**
-	 * 运费
+	 * 拆单之前的配送规则列表
 	 */
-	@Column(name = "or_fare")
-	private Double fare;
+	@Column(name = "or_rules", length = 4000)
+	private String jsonMoreRule;
+
+	/**
+	 * 自提点信息
+	 */
+	@Column(name = "or_take_self", length = 2000)
+	private String jsonTakeSelf;
+
+	/**
+	 * 拆单之前的自提点信息
+	 */
+	@Column(name = "or_take_selfs", length = 4000)
+	private String jsonMoreTake;
 
 	/**
 	 * 收货地址 这里使用json字符串的形式将收货地址整个存起来
@@ -1750,6 +1762,14 @@ public class Order extends Document implements Serializable {
 		this.vatBillStatus = vatBillStatus;
 	}
 
+	public String getJsonRule() {
+		return jsonRule;
+	}
+
+	public void setJsonRule(String jsonRule) {
+		this.jsonRule = jsonRule;
+	}
+
 	/**
 	 * Gets audit pay fail reason.
 	 *
@@ -2737,12 +2757,12 @@ public class Order extends Document implements Serializable {
 		this.dissociative = dissociative;
 	}
 
-	public String getDeliverytypes() {
-		return deliverytypes;
+	public String getJsonMoreRule() {
+		return jsonMoreRule;
 	}
 
-	public void setDeliverytypes(String deliverytypes) {
-		this.deliverytypes = deliverytypes;
+	public void setJsonMoreRule(String jsonMoreRule) {
+		this.jsonMoreRule = jsonMoreRule;
 	}
 
 	public Double getFare() {
@@ -2753,11 +2773,19 @@ public class Order extends Document implements Serializable {
 		this.fare = fare;
 	}
 
-	public String getFares() {
-		return fares;
+	public String getJsonTakeSelf() {
+		return jsonTakeSelf;
+	}
+
+	public void setJsonTakeSelf(String jsonTakeSelf) {
+		this.jsonTakeSelf = jsonTakeSelf;
+	}
+
+	public String getJsonMoreTake() {
+		return jsonMoreTake;
 	}
 
-	public void setFares(String fares) {
-		this.fares = fares;
+	public void setJsonMoreTake(String jsonMoreTake) {
+		this.jsonMoreTake = jsonMoreTake;
 	}
 }

+ 28 - 0
src/main/java/com/uas/platform/b2c/trade/order/model/Purchase.java

@@ -468,6 +468,18 @@ public class Purchase extends Document implements Serializable {
 	@Column(name = "pu_deliverytype")
 	private String deliveryType;
 
+	/**
+	 * 使用的配送规则
+	 */
+	@Column(name = "pu_rule", length = 2000)
+	private String jsonRule;
+
+	/**
+	 * 自提点信息
+	 */
+	@Column(name = "pu_take_self", length = 2000)
+	private String jsonTakeSelf;
+
 	/**
 	 * 运费
 	 */
@@ -1743,6 +1755,14 @@ public class Purchase extends Document implements Serializable {
 		return this;
 	}
 
+	public String getJsonRule() {
+		return jsonRule;
+	}
+
+	public void setJsonRule(String jsonRule) {
+		this.jsonRule = jsonRule;
+	}
+
 	/**
 	 * @Tip 对象初始化时必须给历史记录赋值,为showTip属性设置默认值
 	 */
@@ -2078,6 +2098,14 @@ public class Purchase extends Document implements Serializable {
 		this.exchangeStatus = exchangeStatus;
 	}
 
+	public String getJsonTakeSelf() {
+		return jsonTakeSelf;
+	}
+
+	public void setJsonTakeSelf(String jsonTakeSelf) {
+		this.jsonTakeSelf = jsonTakeSelf;
+	}
+
 	/**
 	 * Gets storeid.
 	 *

+ 24 - 10
src/main/java/com/uas/platform/b2c/trade/order/service/impl/OrderServiceImpl.java

@@ -687,11 +687,12 @@ public class OrderServiceImpl implements OrderService {
         }
         str1 = StringUtils.isEmpty(str1) ? str1 : str1.substring(0, str1.length() - 1);
         order.setOrderids(str1);
-        //获取配送方式Map
-        JSONObject methodMap = splitObject.getJSONObject("methodList");
-        order.setDeliverytypes(FastjsonUtils.toJson(methodMap));
-        JSONObject fareMap = splitObject.getJSONObject("fareList");
-        order.setFares(FastjsonUtils.toJson(fareMap));
+        //保存配送规则Map
+        String ruleJson = splitObject.getString("ruleList");
+        order.setJsonMoreRule(ruleJson);
+        String takeJson = splitObject.getString("takeList");
+        order.setJsonMoreTake(takeJson);
+        order.setEnsurePrice(orderInfo.getDouble("totalprice"));
         orderDao.save(order);
 
         // 记录确认订单操作日志
@@ -718,9 +719,12 @@ public class OrderServiceImpl implements OrderService {
         //获得订单备注Map
         JSONObject remarkMap = FastjsonUtils.fromJson(order.getOrderRemark(), JSONObject.class);
 
-        //获取配送方式Map
-        JSONObject methodMap = object.getJSONObject("methodList");
-        JSONObject fareMap = object.getJSONObject("fareList");
+        //获取适用配送规则列表
+        String jsonRule = object.getString("ruleList");
+        JSONObject ruleObject = FastjsonUtils.fromJson(jsonRule, JSONObject.class);
+        //获取自提点信息
+        String jsonTake = object.getString("takeList");
+        JSONObject takeObject = FastjsonUtils.fromJson(jsonTake, JSONObject.class);
 
         for (OrderDetail detail : order.getOrderDetails()) {
             List<OrderDetail> orderDetails = listMap.get(detail.getStoreid());
@@ -765,8 +769,18 @@ public class OrderServiceImpl implements OrderService {
             /**
              *  加入运费
              */
-            or.setFare(Double.parseDouble(fareMap.getString(storeid)));
+            JSONObject rule = ruleObject.getJSONObject(storeid);
+            JSONObject take = takeObject.getJSONObject(storeid);
+            System.out.println(rule);
+            or.setJsonRule(FastjsonUtils.toJson(rule));
+            if(take != null){
+                or.setJsonTakeSelf(FastjsonUtils.toJson(take));
+            }
+
+            or.setDeliverytype(Integer.parseInt(rule.getString("method")));
+            or.setFare(Double.parseDouble(rule.getString("fare")));
             ensurePrices += or.getFare();
+            transationPrice += or.getFare();
 
             or.setBatchQty(newOrderDetails.size());
             or.setEnsurePrice(NumberUtil.fractionNumCeil(ensurePrices, 2));
@@ -779,7 +793,7 @@ public class OrderServiceImpl implements OrderService {
             map.put(storeid, remarkMap.getString(storeid));
             String orRemark = FastjsonUtils.toJson(map);
             or.setOrderRemark(orRemark);
-            or.setDeliverytype(Integer.parseInt(methodMap.getString(storeid)));
+//            or.setDeliverytype(Integer.parseInt(methodMap.getString(storeid)));
 
             StoreIn storeIn = storeInDao.findByUuid(storeid);
             if (storeIn == null) {

+ 6 - 0
src/main/java/com/uas/platform/b2c/trade/order/service/impl/PurchaseServiceImpl.java

@@ -352,6 +352,8 @@ public class PurchaseServiceImpl implements PurchaseService {
 		price = NumberUtil.pricesScaleTwo(price);
 		purchase.setPrice(price);
 		// TODO 这里需要考虑确认总价的问题 (默认和总价相等,打折或优惠券逻辑待考虑)
+		// 加入运费
+		ensurePrices += purchase.getFare();
 		ensurePrices = NumberUtil.pricesScaleTwo(ensurePrices);
 		purchase.setEnsurePrice(ensurePrices);
 	}
@@ -388,6 +390,10 @@ public class PurchaseServiceImpl implements PurchaseService {
 		purchase.setPurchaseRemark(object.getString(orderFromCust.getStoreid()));//绑定评论
 		purchase.setSendType(orderFromCust.getDeliverytype());
 		purchase.setFare(orderFromCust.getFare());
+		purchase.setJsonRule(orderFromCust.getJsonRule());
+		if (orderFromCust.getJsonTakeSelf() != null){
+			purchase.setJsonTakeSelf(orderFromCust.getJsonTakeSelf());
+		}
 		purchase.setSellerenuu(enuu);
 		purchase.setStoreid(orderFromCust.getStoreid());
 		//如果是优软代售的。

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

@@ -116,6 +116,11 @@ define([ 'ngResource' ], function() {
 				method: 'GET',
 				isArray : true
 			},
+			findFareOfRule : {
+				url: 'trade/distributionRule/fare',
+				method: 'POST',
+				isArray : true
+			},
 			findUsableRule : {
 				url: 'trade/distributionRule/usable/rule',
 				method: 'POST'

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

@@ -52,6 +52,10 @@ define(['ngResource'], function() {
 				url : 'trade/takeSelf/takeName',
 				method : 'GET',
 				isArray : true
+			},
+			findTakeSelfByStore : {
+				url : 'trade/takeSelf/store/takeSelf',
+				method : 'POST'
 			}
 		});
 	}]);

+ 2 - 2
src/main/webapp/resources/js/usercenter/app.js

@@ -1,7 +1,7 @@
 
-define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'common/services', 'common/directives','common/query/kind', 'common/query/brand', 'common/query/component', 'common/query/order', 'common/query/cart', 'common/query/goods', 'common/query/return' ,'angular-toaster', 'common/query/urlencryption', 'ui-jquery', 'common/query/bankTransfer', 'common/query/bankInfo', 'common/query/change', 'common/query/logistics', 'common/query/address' ,'angular-toaster','common/query/collection', 'common/query/proofing', 'common/query/bill', 'common/query/user','file-upload', 'file-upload-shim', 'common/query/bankInfo' , 'common/query/responseLogistics', 'common/query/payment', 'common/query/afterSale', 'common/query/messageBoard', 'common/query/importDeclaration', 'common/query/enterprise', 'common/query/invoice', 'common/query/refund', 'common/query/recommendation', 'common/query/logisticsPort', 'common/query/storeInfo', 'common/query/tradeMessageNotice', 'common/query/tradeBasicProperties', 'common/query/browsingHistory', 'common/query/internalMessage', 'common/module/chat_web_module', 'angular-filter'], function(angularAMD) {
+define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'common/services', 'common/directives','common/query/kind', 'common/query/brand', 'common/query/component', 'common/query/order', 'common/query/cart', 'common/query/goods', 'common/query/return' ,'angular-toaster', 'common/query/urlencryption', 'ui-jquery', 'common/query/bankTransfer', 'common/query/bankInfo', 'common/query/change', 'common/query/logistics', 'common/query/address' ,'angular-toaster','common/query/collection', 'common/query/proofing', 'common/query/bill', 'common/query/user','file-upload', 'file-upload-shim', 'common/query/bankInfo' , 'common/query/responseLogistics', 'common/query/payment', 'common/query/afterSale', 'common/query/messageBoard', 'common/query/importDeclaration', 'common/query/enterprise', 'common/query/invoice', 'common/query/refund', 'common/query/recommendation', 'common/query/logisticsPort', 'common/query/storeInfo', 'common/query/tradeMessageNotice', 'common/query/tradeBasicProperties', 'common/query/browsingHistory', 'common/query/internalMessage', 'common/module/chat_web_module', 'angular-filter', 'common/query/vendor'], function(angularAMD) {
 	'use strict';
-	var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ngTable', 'common.services', 'common.directives', 'tool.directives', 'common.query.kind', 'brandServices', 'componentServices', 'orderServices', 'cartServices', 'goodsServices', 'returnServices' , 'toaster', 'urlencryptionServices', 'ui.jquery', 'bankTransfer', 'bankInfo', 'changeServices', 'logisticsServices', 'addressServices', 'toaster','collection','proofingServices', 'billServices', 'common.query.user', 'angularFileUpload', 'bankInfo', 'responseLogisticsService', 'PaymentService', 'afterSaleService', 'messageBoardServices', 'table.directives', 'importDeclaration', 'common.query.enterprise', 'invoiceServices', 'refundModule', 'recommendation','logisticsPortService', 'storeInfoServices', 'tradeMessageNoticeModule', 'tradeBasicPropertiesServices', 'BrowsingHistory', 'internalMessageServices', 'WebChatModule', 'angular.filter']);
+	var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ngTable', 'common.services', 'common.directives', 'tool.directives', 'common.query.kind', 'brandServices', 'componentServices', 'orderServices', 'cartServices', 'goodsServices', 'returnServices' , 'toaster', 'urlencryptionServices', 'ui.jquery', 'bankTransfer', 'bankInfo', 'changeServices', 'logisticsServices', 'addressServices', 'toaster','collection','proofingServices', 'billServices', 'common.query.user', 'angularFileUpload', 'bankInfo', 'responseLogisticsService', 'PaymentService', 'afterSaleService', 'messageBoardServices', 'table.directives', 'importDeclaration', 'common.query.enterprise', 'invoiceServices', 'refundModule', 'recommendation','logisticsPortService', 'storeInfoServices', 'tradeMessageNoticeModule', 'tradeBasicPropertiesServices', 'BrowsingHistory', 'internalMessageServices', 'WebChatModule', 'angular.filter', 'vendorServices']);
 	app.init = function() {
 		angularAMD.bootstrap(app);
 	};

+ 109 - 18
src/main/webapp/resources/js/usercenter/controllers/forstore/order_pay_ctrl.js

@@ -3,7 +3,7 @@
  *  订单付款的界面
  */
 define(['app/app'], function(app) {
-	app.register.controller('orderPayCtrl', ['$scope', '$rootScope', '$stateParams', '$modal', '$state', 'Bill', 'toaster', 'Order', '$filter', 'ShippingAddress', 'Ysepay', '$q', 'NumberService', 'Cart', '$timeout', 'DistributionRule', function($scope, $rootScope, $stateParams, $modal, $state, Bill, toaster, Order, $filter, ShippingAddress, Ysepay, $q, NumberService, Cart, $timeout, DistributionRule) {
+	app.register.controller('orderPayCtrl', ['$scope', '$rootScope', '$stateParams', '$modal', '$state', 'Bill', 'toaster', 'Order', '$filter', 'ShippingAddress', 'Ysepay', '$q', 'NumberService', 'Cart', '$timeout', 'DistributionRule', 'TakeSelf', function($scope, $rootScope, $stateParams, $modal, $state, Bill, toaster, Order, $filter, ShippingAddress, Ysepay, $q, NumberService, Cart, $timeout, DistributionRule, TakeSelf) {
 
 		$rootScope.active = 'buyer_cart';
 
@@ -87,6 +87,7 @@ define(['app/app'], function(app) {
 						$scope.$$orderDetailsMap = {};
 						$scope.remarkList = {};//订单备注列表
 						$scope.deliveryList = {};//配送方式列表
+						$scope.takeSelfList = {};
 						$scope.fareList = {};//运费列表
 						if($scope.order.orderDetails.length == 0) {
 							toaster.pop('warning', '您购买的商品已全部失效,请您前往购物车重新勾选');
@@ -104,6 +105,7 @@ define(['app/app'], function(app) {
 								$scope.$$orderDetailsMap[detail.storeName] = [];
 								$scope.remarkList[detail.storeid] = "";
 								$scope.deliveryList[detail.storeid] = '';
+								$scope.takeSelfList[detail.storeid] = null;
 								$scope.fareList[detail.storeid] = 0;
 								$scope.$$orderDetailsMap[detail.storeName].push(detail);
 							}
@@ -112,6 +114,7 @@ define(['app/app'], function(app) {
 						if($scope.order.status == 501) { //如果不是待确认状态,则不需要计算
 							//计算总价格
 							$scope.calculateTotal();
+							getTakeSelf();
 						}
 						angular.forEach($scope.$$orderDetailsMap, function (value, key) {
 							var object = {
@@ -130,6 +133,12 @@ define(['app/app'], function(app) {
 					if ($scope.order.orderRemark){
 						$scope.remarkList = angular.fromJson($scope.order.orderRemark);
 					}
+					if ($scope.order.jsonRule){
+						$scope.rule = angular.fromJson($scope.order.jsonRule);
+					}
+					if ($scope.order.jsonTakeSelf){
+						$scope.takeSelf = angular.fromJson($scope.order.jsonTakeSelf);
+					}
 					if($scope.order.orderDetails.length == 0) {
 						$state.go('buyer_order');
 					}
@@ -142,9 +151,14 @@ define(['app/app'], function(app) {
 							$scope.$$orderDetailsMap[detail.storeName].push(detail);
 						}
 					});
+					if ($scope.order.jsonMoreRule){
+						$scope.deliveryList = angular.fromJson($scope.order.jsonMoreRule);
+					}
+					if ($scope.order.jsonMoreTake){
+						$scope.takeList = angular.fromJson($scope.order.jsonMoreTake);
+					}
 					if ($scope.storeArray.length != 1){
-						$scope.deliveryList = angular.fromJson($scope.order.deliverytypes);
-						$scope.fareList = angular.fromJson($scope.order.fares);
+						$scope.calculateTotal();
 					}
 					initOrder();
 				}
@@ -153,10 +167,32 @@ define(['app/app'], function(app) {
 
 		getOrderData();
 
+		var getTakeSelf = function () {
+			if ($scope.order.status == 501){
+				TakeSelf.findTakeSelfByStore({}, $scope.storeArray, function (data) {
+					if(data){
+						$scope.takeSelfMap = data;
+					}
+				})
+			}
+		};
+
 		$scope.changeFare = function (details) {
 			var storeid = details[0].storeid;
 			var rule = $scope.deliveryList[storeid];
 			$scope.fareList[storeid] = rule.fare;
+			$scope.calculateFare();
+		};
+
+		/**
+		 * 计算运费和店铺费用合计
+		 */
+		$scope.calculateFare = function () {
+			var fare = 0;
+			angular.forEach($scope.fareList, function (v) {
+				fare = NumberService.add(v, fare);
+			});
+			$scope.order.ensurePrice = NumberService.add($scope.order.totalprice, fare);
 		};
 
 
@@ -207,6 +243,7 @@ define(['app/app'], function(app) {
 								$scope.fareList[item.uuid] = arr[0].fare;
 							}
 						});
+						$scope.calculateFare();
 					}
 				},function (error) {
 					toaster.pop('info', '提示', error.data);
@@ -214,6 +251,10 @@ define(['app/app'], function(app) {
 			}
 		};
 
+		$scope.updateTakeSelf = function (uuid, item) {
+			$scope.takeSelfList[uuid] = item;
+		};
+
 		// 添加按钮,每次加1
 		$scope.add = function(detail){
 			var num = NumberService.add(detail.number, detail.goodsHistory.minPackQty);
@@ -227,6 +268,15 @@ define(['app/app'], function(app) {
 			$scope.calculatePrice(detail.number, detail, detail.currencyName);
 			//计算总价格
 			$scope.calculateTotal();
+			updateStoreArray(detail);
+			$q.all([updateFare($scope.ruleMap[detail.storeid], $scope.storePrice[detail.storeName]).$promise]).then(function (data) {
+				if (data){
+					var arr = data[0];
+					$scope.ruleMap[detail.storeid] = arr;
+					$scope.deliveryList[detail.storeid] = arr[0];
+					$scope.calculateFare();
+				}
+			});
 		};
 
 		// 减少按钮,每次减minPackQty
@@ -242,6 +292,44 @@ define(['app/app'], function(app) {
 			$scope.calculatePrice(detail.number, detail, detail.currencyName);
 			//计算总价格
 			$scope.calculateTotal();
+			updateStoreArray(detail);
+			$q.all([updateFare($scope.ruleMap[detail.storeid], $scope.storePrice[detail.storeName]).$promise]).then(function (data) {
+				if (data){
+					var arr = data[0];
+					$scope.ruleMap[detail.storeid] = arr;
+					$scope.deliveryList[detail.storeid] = arr[0];
+					$scope.calculateFare();
+				}
+			});
+
+		};
+
+		/**
+		 * 更新配送规则请求参数
+		 */
+		var updateStoreArray = function (detail) {
+			angular.forEach($scope.storeArray, function (item) {
+				if (item.uuid == detail.storeid){
+					item.fare = $scope.storePrice[detail.storeName];
+				}
+			})
+		};
+
+		/**
+		 * 更新运费列表
+		 * @param ruleList
+		 * @param price
+		 * @returns {*|{url, method, isArray}}
+		 */
+		var updateFare = function (ruleList, price) {
+			return DistributionRule.findFareOfRule({price:price}, ruleList, function (data) {
+				if (data){
+					var rule = ruleList[0];
+					$scope.fareList[rule.uuid] = rule.fare;
+				}
+			}, function (error) {
+
+			})
 		};
 
 		// 输入购买量限制
@@ -258,6 +346,15 @@ define(['app/app'], function(app) {
 			$scope.calculatePrice(detail.number, detail, detail.currencyName);
 			//计算总价格
 			$scope.calculateTotal();
+			updateStoreArray(detail);
+			$q.all([updateFare($scope.ruleMap[detail.storeid], $scope.storePrice[detail.storeName]).$promise]).then(function (data) {
+				if (data){
+					var arr = data[0];
+					$scope.ruleMap[detail.storeid] = arr;
+					$scope.deliveryList[detail.storeid] = arr[0];
+					$scope.calculateFare();
+				}
+			});
 		};
 
 		$scope.deliveryMethod = {
@@ -375,14 +472,6 @@ define(['app/app'], function(app) {
 			});
 		};
 
-		$scope.getRule = function (uuid) {
-			DistributionRule.findMatchRule({method:1301, area:$scope.payment.address.area, uuid:uuid},{},function (data) {
-				if (data){
-					console.log(data);
-				}
-			})
-		};
-
 		// 产生要提交的单个订单数据
 		var generateOrderInfo = function() {
 			/*订单信息:orderInfo含有信息:id、orderid、deliverytype、add_id、invoicetype、invoiceid、paytype、totalprice(price)、
@@ -403,7 +492,8 @@ define(['app/app'], function(app) {
 			}
 
 			// 收货地址,上门自提暂不提供
-			if($scope.order.deliverytype == '1301'){
+			if($scope.deliveryList){
+				console.log("进来了");
 				/*var address = angular.fromJson($scope.selectAddress);
 				 delete address.isSelect;
 				 orderInfo.jsonAddress = angular.toJson(address);*/
@@ -423,9 +513,10 @@ define(['app/app'], function(app) {
 					}
 				}
 				orderInfo.add_id = $scope.payment.address.id;
-			}else if($scope.order.deliverytype == '1302'){
-				orderInfo.add_id = $scope.pickAddress.id;
 			}
+			// else if($scope.order.deliverytype == '1302'){
+			// 	orderInfo.add_id = $scope.pickAddress.id;
+			// }
 			orderInfo.invoicetype = $scope.order.invoicetype; // 发票类型
 			if($scope.order.invoicetype != '1207') {
 				if(!$scope.bill.id) {
@@ -439,8 +530,8 @@ define(['app/app'], function(app) {
 			orderInfo.currency = $scope.order.currency; // 币别
 			orderInfo.orderRemark = angular.toJson($scope.remarkList);//订单备注
 			orderInfo.splitInfo = {
-				ruleList : angular.toJson($scope.deliveryList)
-				// fareList : angular.toJson($scope.fareList)
+				ruleList : angular.toJson($scope.deliveryList),
+				takeList : angular.toJson($scope.takeSelfList)
 			};
 
 			orderInfo.paytype =  $scope.order.paytype;
@@ -586,7 +677,7 @@ define(['app/app'], function(app) {
 		 * 计算总金额
 		 */
 		$scope.calculateTotal = function () {
-			$scope.order.ensurePrice = 0;
+			$scope.order.totalprice = 0;
 			$scope.storePrice = {};
 			angular.forEach($scope.order.orderDetails, function(detail) {
 				detail.ensurePrice = Number(NumberService.mul(detail.taxUnitprice, detail.number));
@@ -597,7 +688,7 @@ define(['app/app'], function(app) {
 			});
 			angular.forEach($scope.$$orderDetailsMap, function (value, key) {
 				$scope.storePrice[key] = Number(NumberService.toCeil($scope.storePrice[key], 2));
-				$scope.order.ensurePrice = NumberService.add($scope.storePrice[key], $scope.order.ensurePrice)
+				$scope.order.totalprice = NumberService.add($scope.storePrice[key], $scope.order.totalprice)
 			});
 		};
 

+ 41 - 40
src/main/webapp/resources/view/usercenter/forstore/order_pay.html

@@ -625,7 +625,7 @@
 							<span style="width: 100%;">
 								<em style="margin-left: 40px;">订单备注:</em>
 								<input ng-if="order.status==501" type="text"  class="form-control" placeholder="请填写订单备注" ng-model="remarkList[details[0].storeid]" maxlength="200"/>
-								<em ng-if="order.status!=501" style="margin-left: 0px">{{order.orderRemark}}</em>
+								<em ng-if="order.status!=501" style="margin-left: 0px" ng-bind="remarkList[details[0].storeid] || '无'"></em>
 							</span>
 						</dd>
 						<dd class="line60">
@@ -636,59 +636,60 @@
 									<!--ng-options="rule.method as deliveryMethod[rule.method] for rule in ruleMap[details[0].storeid]"-->
 									<!--<option ng-repeat="rule in ruleMap[details[0].storeid]" value="rule.method">{{deliveryMethod[rule.method]}}</option>-->
 								</select>
-								<em ng-if="order.status != 501" class="color333" ng-bind="deliveryMethod[order.deliverytype]"></em>
-								<!--<i>满1000元包邮,未满足的订单收取运费20元</i>-->
+								<em ng-if="order.status != 501">
+									<em class="color333" ng-if="storeArray.length == 1" ng-bind="deliveryMethod[order.deliverytype]"></em>
+									<em class="color333" ng-if="storeArray.length != 1" ng-bind="deliveryMethod[deliveryList[details[0].storeid].method]"></em>
+								</em>
+								<i ng-if="order.status == 501" ng-bind="deliveryList[details[0].storeid].ruleName">满1000元包邮,未满足的订单收取运费20元</i>
+								<i ng-if="order.status != 501">
+									<i style="margin-left: 0px;" ng-if="storeArray.length != 1" ng-bind="deliveryList[details[0].storeid].ruleName"></i>
+									<i style="margin-left: 0px;" ng-if="storeArray.length == 1" ng-bind="rule.ruleName"></i>
+								</i>
 								<!--<button ng-click="getRule(order.storeid)">获取配送规则</button>-->
 							</span>
 							<span class="total-price">
-								<p><strong>运费:</strong><em ng-bind="fareList[details[0].storeid] | formateNumber : 2 | currencySysmbol : order.currency.substring(0,3)" style="font-weight: bold"></em></p>
+								<p><strong>运费:</strong>
+									<em ng-if="order.status==501" ng-bind="fareList[details[0].storeid] | formateNumber : 2 | currencySysmbol : order.currency.substring(0,3)" style="font-weight: bold"></em>
+									<em ng-if="order.status!=501" style="font-weight: bold">
+										<em ng-if="storeArray.length == 1" ng-bind="order.fare | formateNumber : 2 | currencySysmbol : order.currency.substring(0,3)"></em>
+										<em ng-if="storeArray.length != 1" ng-bind="deliveryList[details[0].storeid].fare | formateNumber : 2 | currencySysmbol : order.currency.substring(0,3)"></em>
+									</em>
+								</p>
 								<p><strong>店铺合计:</strong>
 									<em ng-if="order.status==501" ng-bind="storePrice[key] + fareList[details[0].storeid] | formateNumber :2 | currencySysmbol : order.currency.substring(0,3)" style="font-weight: bold"></em>
-									<em ng-if="order.status!=501" ng-bind="order.ensurePrice | formateNumber :2 | currencySysmbol : order.currency.substring(0,3)" style="font-weight: bold"></em>
+									<em ng-if="order.status!=501" style="font-weight: bold">
+										<em ng-if="storeArray.length == 1" ng-bind="order.ensurePrice | formateNumber :2 | currencySysmbol : order.currency.substring(0,3)"></em>
+										<em ng-if="storeArray.length != 1" ng-bind="storePrice[key] + deliveryList[details[0].storeid].fare | formateNumber :2 | currencySysmbol : order.currency.substring(0,3)"></em>
+									</em>
 								</p>
 							</span>
 						</dd>
-						<div class="self-list" ng-if="order.deliverytype == 1303">
+						<div class="self-list" ng-if="order.status==501 && deliveryList[details[0].storeid].method == 1303">
 							<!--自提点列表-->
-								<ul class="self-advice">
-									<li>
-										<label class="check-act">
-											<input type="radio" id="1" name="1"/>
-											<label for="1"></label>
-										</label>
-										<strong style="margin-left: 0">自提点A</strong>
-										<strong>地址:<i>广东省  深圳市  南山区  科技园英唐大厦6楼 优软商城科技园英唐大厦6楼 优软商城</i></strong>
-										<strong>营业时间:<i>周一至周五 8:30-18:00</i></strong>
-									</li>
-									<li>
-										<label class="check-act">
-											<input type="radio" id="2" name="2"/>
-											<label for="2"></label>
-										</label>
-										<strong style="margin-left: 0">自提点A</strong>
-										<strong>地址:<i>广东省  深圳市  南山区  科技园英唐大厦6楼 优软商城科技园英唐大厦6楼 优软商城</i></strong>
-										<strong>营业时间:<i>周一至周五 8:30-18:00</i></strong>
-									</li>
-									<li>
+								<ul class="self-advice" ng-if="order.status == 501">
+									<li ng-repeat="item in takeSelfMap[details[0].storeid]">
 										<label class="check-act">
-											<input type="radio" id="3" name="3"/>
-											<label for="3"></label>
+											<input type="radio" id="{{item.id}}" name="1" ng-click="updateTakeSelf(details[0].storeid, item)"/>
+											<label for="{{item.id}}"></label>
 										</label>
-										<strong style="margin-left: 0">自提点A</strong>
-										<strong>地址:<i>广东省  深圳市  南山区  科技园英唐大厦6楼 优软商城科技园英唐大厦6楼 优软商城</i></strong>
-										<strong>营业时间:<i>周一至周五 8:30-18:00</i></strong>
-									</li>
-									<li>
-										<label class="check-act">
-											<input type="radio" id="4" name="4"/>
-											<label for="4"></label>
-										</label>
-										<strong style="margin-left: 0">自提点A</strong>
-										<strong>地址:<i>广东省  深圳市  南山区  科技园英唐大厦6楼 优软商城科技园英唐大厦6楼 优软商城</i></strong>
-										<strong>营业时间:<i>周一至周五 8:30-18:00</i></strong>
+										<strong style="margin-left: 0" ng-bind="item.takename"></strong>
+										<strong>地址:<i ng-bind="item.area"></i>&nbsp;&nbsp;<i ng-bind="item.detailAddress"></i></strong>
+										<strong>营业时间:<i ng-bind="item.businesstime">周一至周五 8:30-18:00</i></strong>
 									</li>
 								</ul>
 						</div>
+						<div class="self-list" ng-if="order.status!=501">
+							<span ng-if="takeList">
+								<strong style="margin-left: 0" ng-bind="takeList[details[0].storeid].takename"></strong>
+								<strong>地址:<i ng-bind="takeList[details[0].storeid].area"></i>&nbsp;&nbsp;<i ng-bind="takeList[details[0].storeid].detailAddress"></i></strong>
+								<strong>营业时间:<i ng-bind="takeList[details[0].storeid].businesstime">周一至周五 8:30-18:00</i></strong>
+							</span>
+							<span ng-if="!takeList && takeSelf">
+								<strong style="margin-left: 0" ng-bind="takeSelf.takename"></strong>
+								<strong>地址:<i ng-bind="takeSelf.area"></i>&nbsp;&nbsp;<i ng-bind="takeSelf.detailAddress"></i></strong>
+								<strong>营业时间:<i ng-bind="takeSelf.businesstime">周一至周五 8:30-18:00</i></strong>
+							</span>
+						</div>
 					</div>
 					<dd class="pay_price">
 						<div>

+ 2 - 2
src/main/webapp/resources/view/vendor/forstore/purchase_detail.html

@@ -463,9 +463,9 @@
 							<!--<i style="color: #666;">(满1000元包邮,未满足的订单收取运费20元)</i>-->
 						</span>
 						<span class="total-price">
-								<p><strong>运费:</strong><em ng-bind="0 | formateNumber : 2 | currencySysmbol : purchase.currency.substring(0,3)" style="font-weight: bold"></em></p>
+								<p><strong>运费:</strong><em ng-bind="purchase.fare | formateNumber : 2 | currencySysmbol : purchase.currency.substring(0,3)" style="font-weight: bold"></em></p>
 								<p><strong>店铺合计:</strong>
-									<em ng-if="!isChange" ng-bind="purchase.price | formateNumber : 2 | currencySysmbol : purchase.currency" style="font-weight: bold"></em>
+									<em ng-if="!isChange" ng-bind="purchase.ensurePrice | formateNumber : 2 | currencySysmbol : purchase.currency" style="font-weight: bold"></em>
 									<em ng-if="isChange" ng-bind="purchase.currentTotal | formateNumber : 2 | currencySysmbol : purchase.currency" style="font-weight: bold"></em>
 								</p>
 						</span>