|
@@ -3,7 +3,7 @@
|
|
|
* 订单付款的界面
|
|
* 订单付款的界面
|
|
|
*/
|
|
*/
|
|
|
define(['app/app'], function(app) {
|
|
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';
|
|
$rootScope.active = 'buyer_cart';
|
|
|
|
|
|
|
@@ -87,6 +87,7 @@ define(['app/app'], function(app) {
|
|
|
$scope.$$orderDetailsMap = {};
|
|
$scope.$$orderDetailsMap = {};
|
|
|
$scope.remarkList = {};//订单备注列表
|
|
$scope.remarkList = {};//订单备注列表
|
|
|
$scope.deliveryList = {};//配送方式列表
|
|
$scope.deliveryList = {};//配送方式列表
|
|
|
|
|
+ $scope.takeSelfList = {};
|
|
|
$scope.fareList = {};//运费列表
|
|
$scope.fareList = {};//运费列表
|
|
|
if($scope.order.orderDetails.length == 0) {
|
|
if($scope.order.orderDetails.length == 0) {
|
|
|
toaster.pop('warning', '您购买的商品已全部失效,请您前往购物车重新勾选');
|
|
toaster.pop('warning', '您购买的商品已全部失效,请您前往购物车重新勾选');
|
|
@@ -104,6 +105,7 @@ define(['app/app'], function(app) {
|
|
|
$scope.$$orderDetailsMap[detail.storeName] = [];
|
|
$scope.$$orderDetailsMap[detail.storeName] = [];
|
|
|
$scope.remarkList[detail.storeid] = "";
|
|
$scope.remarkList[detail.storeid] = "";
|
|
|
$scope.deliveryList[detail.storeid] = '';
|
|
$scope.deliveryList[detail.storeid] = '';
|
|
|
|
|
+ $scope.takeSelfList[detail.storeid] = null;
|
|
|
$scope.fareList[detail.storeid] = 0;
|
|
$scope.fareList[detail.storeid] = 0;
|
|
|
$scope.$$orderDetailsMap[detail.storeName].push(detail);
|
|
$scope.$$orderDetailsMap[detail.storeName].push(detail);
|
|
|
}
|
|
}
|
|
@@ -112,6 +114,7 @@ define(['app/app'], function(app) {
|
|
|
if($scope.order.status == 501) { //如果不是待确认状态,则不需要计算
|
|
if($scope.order.status == 501) { //如果不是待确认状态,则不需要计算
|
|
|
//计算总价格
|
|
//计算总价格
|
|
|
$scope.calculateTotal();
|
|
$scope.calculateTotal();
|
|
|
|
|
+ getTakeSelf();
|
|
|
}
|
|
}
|
|
|
angular.forEach($scope.$$orderDetailsMap, function (value, key) {
|
|
angular.forEach($scope.$$orderDetailsMap, function (value, key) {
|
|
|
var object = {
|
|
var object = {
|
|
@@ -130,6 +133,12 @@ define(['app/app'], function(app) {
|
|
|
if ($scope.order.orderRemark){
|
|
if ($scope.order.orderRemark){
|
|
|
$scope.remarkList = angular.fromJson($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) {
|
|
if($scope.order.orderDetails.length == 0) {
|
|
|
$state.go('buyer_order');
|
|
$state.go('buyer_order');
|
|
|
}
|
|
}
|
|
@@ -142,9 +151,14 @@ define(['app/app'], function(app) {
|
|
|
$scope.$$orderDetailsMap[detail.storeName].push(detail);
|
|
$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){
|
|
if ($scope.storeArray.length != 1){
|
|
|
- $scope.deliveryList = angular.fromJson($scope.order.deliverytypes);
|
|
|
|
|
- $scope.fareList = angular.fromJson($scope.order.fares);
|
|
|
|
|
|
|
+ $scope.calculateTotal();
|
|
|
}
|
|
}
|
|
|
initOrder();
|
|
initOrder();
|
|
|
}
|
|
}
|
|
@@ -153,10 +167,32 @@ define(['app/app'], function(app) {
|
|
|
|
|
|
|
|
getOrderData();
|
|
getOrderData();
|
|
|
|
|
|
|
|
|
|
+ var getTakeSelf = function () {
|
|
|
|
|
+ if ($scope.order.status == 501){
|
|
|
|
|
+ TakeSelf.findTakeSelfByStore({}, $scope.storeArray, function (data) {
|
|
|
|
|
+ if(data){
|
|
|
|
|
+ $scope.takeSelfMap = data;
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
$scope.changeFare = function (details) {
|
|
$scope.changeFare = function (details) {
|
|
|
var storeid = details[0].storeid;
|
|
var storeid = details[0].storeid;
|
|
|
var rule = $scope.deliveryList[storeid];
|
|
var rule = $scope.deliveryList[storeid];
|
|
|
$scope.fareList[storeid] = rule.fare;
|
|
$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.fareList[item.uuid] = arr[0].fare;
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+ $scope.calculateFare();
|
|
|
}
|
|
}
|
|
|
},function (error) {
|
|
},function (error) {
|
|
|
toaster.pop('info', '提示', error.data);
|
|
toaster.pop('info', '提示', error.data);
|
|
@@ -214,6 +251,10 @@ define(['app/app'], function(app) {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ $scope.updateTakeSelf = function (uuid, item) {
|
|
|
|
|
+ $scope.takeSelfList[uuid] = item;
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
// 添加按钮,每次加1
|
|
// 添加按钮,每次加1
|
|
|
$scope.add = function(detail){
|
|
$scope.add = function(detail){
|
|
|
var num = NumberService.add(detail.number, detail.goodsHistory.minPackQty);
|
|
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.calculatePrice(detail.number, detail, detail.currencyName);
|
|
|
//计算总价格
|
|
//计算总价格
|
|
|
$scope.calculateTotal();
|
|
$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
|
|
// 减少按钮,每次减minPackQty
|
|
@@ -242,6 +292,44 @@ define(['app/app'], function(app) {
|
|
|
$scope.calculatePrice(detail.number, detail, detail.currencyName);
|
|
$scope.calculatePrice(detail.number, detail, detail.currencyName);
|
|
|
//计算总价格
|
|
//计算总价格
|
|
|
$scope.calculateTotal();
|
|
$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.calculatePrice(detail.number, detail, detail.currencyName);
|
|
|
//计算总价格
|
|
//计算总价格
|
|
|
$scope.calculateTotal();
|
|
$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 = {
|
|
$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() {
|
|
var generateOrderInfo = function() {
|
|
|
/*订单信息:orderInfo含有信息:id、orderid、deliverytype、add_id、invoicetype、invoiceid、paytype、totalprice(price)、
|
|
/*订单信息: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);
|
|
/*var address = angular.fromJson($scope.selectAddress);
|
|
|
delete address.isSelect;
|
|
delete address.isSelect;
|
|
|
orderInfo.jsonAddress = angular.toJson(address);*/
|
|
orderInfo.jsonAddress = angular.toJson(address);*/
|
|
@@ -423,9 +513,10 @@ define(['app/app'], function(app) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
orderInfo.add_id = $scope.payment.address.id;
|
|
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; // 发票类型
|
|
orderInfo.invoicetype = $scope.order.invoicetype; // 发票类型
|
|
|
if($scope.order.invoicetype != '1207') {
|
|
if($scope.order.invoicetype != '1207') {
|
|
|
if(!$scope.bill.id) {
|
|
if(!$scope.bill.id) {
|
|
@@ -439,8 +530,8 @@ define(['app/app'], function(app) {
|
|
|
orderInfo.currency = $scope.order.currency; // 币别
|
|
orderInfo.currency = $scope.order.currency; // 币别
|
|
|
orderInfo.orderRemark = angular.toJson($scope.remarkList);//订单备注
|
|
orderInfo.orderRemark = angular.toJson($scope.remarkList);//订单备注
|
|
|
orderInfo.splitInfo = {
|
|
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;
|
|
orderInfo.paytype = $scope.order.paytype;
|
|
@@ -586,7 +677,7 @@ define(['app/app'], function(app) {
|
|
|
* 计算总金额
|
|
* 计算总金额
|
|
|
*/
|
|
*/
|
|
|
$scope.calculateTotal = function () {
|
|
$scope.calculateTotal = function () {
|
|
|
- $scope.order.ensurePrice = 0;
|
|
|
|
|
|
|
+ $scope.order.totalprice = 0;
|
|
|
$scope.storePrice = {};
|
|
$scope.storePrice = {};
|
|
|
angular.forEach($scope.order.orderDetails, function(detail) {
|
|
angular.forEach($scope.order.orderDetails, function(detail) {
|
|
|
detail.ensurePrice = Number(NumberService.mul(detail.taxUnitprice, detail.number));
|
|
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) {
|
|
angular.forEach($scope.$$orderDetailsMap, function (value, key) {
|
|
|
$scope.storePrice[key] = Number(NumberService.toCeil($scope.storePrice[key], 2));
|
|
$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)
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|