|
|
@@ -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', function($scope, $rootScope, $stateParams, $modal, $state, Bill, toaster, Order, $filter, ShippingAddress, Ysepay, $q, NumberService, Cart, $timeout) {
|
|
|
+ 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';
|
|
|
|
|
|
@@ -21,38 +21,38 @@ define(['app/app'], function(app) {
|
|
|
$scope.bills = [];
|
|
|
|
|
|
//获取个人的发票信息
|
|
|
- var getBillInfo = function() {
|
|
|
- Bill.getListPersonal(null, function(data) {
|
|
|
- $scope.bill = {};
|
|
|
- $scope.bills = data;
|
|
|
+ var getBillInfo = function() {
|
|
|
+ Bill.getListPersonal(null, function(data) {
|
|
|
+ $scope.bill = {};
|
|
|
+ $scope.bills = data;
|
|
|
$scope.bill.kind = '1207';
|
|
|
$scope.order.invoicetype = '1207';
|
|
|
- // angular.forEach($scope.bills, function(item) {
|
|
|
- // if(item.kind == '1205') {
|
|
|
- // $scope.bill = item;
|
|
|
- // }
|
|
|
- // });
|
|
|
- }, function(response) {
|
|
|
+ // angular.forEach($scope.bills, function(item) {
|
|
|
+ // if(item.kind == '1205') {
|
|
|
+ // $scope.bill = item;
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ }, function(response) {
|
|
|
if(angular.equals('系统错误', response.data)) {
|
|
|
toaster.pop('error', '获取信息失败');
|
|
|
}else {
|
|
|
toaster.pop('error', '获取订单的信息失败,' + response.data);
|
|
|
}
|
|
|
- });
|
|
|
- };
|
|
|
+ });
|
|
|
+ };
|
|
|
|
|
|
- $scope.deliveryMethod = {
|
|
|
+ $scope.deliveryMethod = {
|
|
|
1301 : '第三方配送',
|
|
|
1302 : '卖家配送',
|
|
|
1303 : '上门自提'
|
|
|
};
|
|
|
|
|
|
- //选择相应的发票信息
|
|
|
+ //选择相应的发票信息
|
|
|
$scope.selectBill = function(kind) {
|
|
|
if(!kind || (kind != '1205' && kind != '1206' && kind != '1207')) {
|
|
|
return ;
|
|
|
}
|
|
|
- getTheKindBill(kind);
|
|
|
+ getTheKindBill(kind);
|
|
|
$scope.order.invoicetype = kind;
|
|
|
$scope.bill.kind = kind;
|
|
|
};
|
|
|
@@ -70,19 +70,25 @@ define(['app/app'], function(app) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- //查看价格分段。
|
|
|
- $scope.togglePrice = function (detail) {
|
|
|
- detail.display = detail.display == 'block' ? 'none' : 'block';
|
|
|
- };
|
|
|
+ //查看价格分段。
|
|
|
+ $scope.togglePrice = function (detail) {
|
|
|
+ detail.display = detail.display == 'block' ? 'none' : 'block';
|
|
|
+ };
|
|
|
+
|
|
|
//获取订单的信息
|
|
|
var getOrderData = function() {
|
|
|
return Order.findStatusByOrderid({enOrderid : $stateParams.orderid}, function (response) {
|
|
|
|
|
|
+ $scope.storeArray = [];
|
|
|
+ $scope.ruleMap = {};
|
|
|
if (response.status == 501){
|
|
|
Order.orderContainGoods({enOrderid : $stateParams.orderid}, function(data) {
|
|
|
$scope.order = data;
|
|
|
$scope.$$orderDetailsMap = {};
|
|
|
- $scope.remarkList = {};
|
|
|
+ $scope.remarkList = {};//订单备注列表
|
|
|
+ $scope.deliveryList = {};//配送方式列表
|
|
|
+ $scope.takeSelfList = {};
|
|
|
+ $scope.fareList = {};//运费列表
|
|
|
if($scope.order.orderDetails.length == 0) {
|
|
|
toaster.pop('warning', '您购买的商品已全部失效,请您前往购物车重新勾选');
|
|
|
$timeout(function () {
|
|
|
@@ -98,6 +104,9 @@ define(['app/app'], function(app) {
|
|
|
}else {
|
|
|
$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);
|
|
|
}
|
|
|
$scope.disabledAddAndSub(detail);
|
|
|
@@ -105,7 +114,15 @@ define(['app/app'], function(app) {
|
|
|
if($scope.order.status == 501) { //如果不是待确认状态,则不需要计算
|
|
|
//计算总价格
|
|
|
$scope.calculateTotal();
|
|
|
+ getTakeSelf();
|
|
|
}
|
|
|
+ angular.forEach($scope.$$orderDetailsMap, function (value, key) {
|
|
|
+ var object = {
|
|
|
+ uuid : value[0].storeid,
|
|
|
+ fare : $scope.storePrice[key]
|
|
|
+ };
|
|
|
+ $scope.storeArray.push(object);
|
|
|
+ });
|
|
|
initOrder();
|
|
|
}, function(response) {
|
|
|
toaster.pop('error', "获取订单的类型失败。" + response.data);
|
|
|
@@ -116,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');
|
|
|
}
|
|
|
@@ -123,10 +146,20 @@ define(['app/app'], function(app) {
|
|
|
if($scope.$$orderDetailsMap[detail.storeName]) {
|
|
|
$scope.$$orderDetailsMap[detail.storeName].push(detail);
|
|
|
}else {
|
|
|
+ $scope.storeArray.push(detail.storeid);
|
|
|
$scope.$$orderDetailsMap[detail.storeName] = [];
|
|
|
$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.calculateTotal();
|
|
|
+ }
|
|
|
initOrder();
|
|
|
}
|
|
|
});
|
|
|
@@ -147,6 +180,35 @@ define(['app/app'], function(app) {
|
|
|
$scope.contactBNox = false;
|
|
|
};
|
|
|
|
|
|
+ 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);
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取买家收货地址信息
|
|
|
*/
|
|
|
@@ -177,18 +239,47 @@ define(['app/app'], function(app) {
|
|
|
$scope.calculatePrice(detail.number, detail, detail.currencyName);
|
|
|
//计算总价格
|
|
|
$scope.calculateTotal();
|
|
|
- };
|
|
|
- //选择收货的地址。
|
|
|
+ };
|
|
|
+ //选择收货的地址。
|
|
|
$scope.selectAdd = function(address) {
|
|
|
$scope.payment.address = address;
|
|
|
- $scope.formatArea = $scope.payment.address.area.replace(/,/g,' ');
|
|
|
+ $scope.formatArea = $scope.payment.address.area.replace(/,/g,' ');
|
|
|
+ if ($scope.order.status == 501){
|
|
|
+ DistributionRule.findUsableRule({area:$scope.payment.address.area}, $scope.storeArray, function (data) {
|
|
|
+ if (data){
|
|
|
+ //更换地址后先清空数据
|
|
|
+ $scope.deliveryList = {};
|
|
|
+ $scope.fareList = {};
|
|
|
+ angular.forEach($scope.storeArray, function (item) {
|
|
|
+ $scope.ruleMap[item.uuid] = [];
|
|
|
+ var arr = data[item.uuid];
|
|
|
+ $scope.ruleMap[item.uuid] = arr;
|
|
|
+ if (arr.length != 0){
|
|
|
+ $scope.deliveryList[item.uuid] = arr[0];
|
|
|
+ $scope.fareList[item.uuid] = arr[0].fare;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.calculateFare();
|
|
|
+ }
|
|
|
+ },function (error) {
|
|
|
+ toaster.pop('info', '提示', error.data);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.updateTakeSelf = function (uuid, item) {
|
|
|
+ $scope.takeSelfList[uuid] = item;
|
|
|
};
|
|
|
|
|
|
// 添加按钮,每次加1
|
|
|
$scope.add = function(detail){
|
|
|
- var num = NumberService.add(detail.number, detail.goodsHistory.minPackQty);
|
|
|
+ var num = NumberService.add(detail.number, detail.goodsHistory.perQty);
|
|
|
if(Number(num) > detail.goodsHistory.reserve) {
|
|
|
- detail.number = Number(NumberService.sub(detail.goodsHistory.reserve, detail.goodsHistory.reserve %detail.goodsHistory.minPackQty));
|
|
|
+ if(detail.goodsHistory.breakUp) {
|
|
|
+ detail.number = detail.goodsHistory.reserve;
|
|
|
+ }else {
|
|
|
+ detail.number = Number(NumberService.sub(detail.goodsHistory.reserve, detail.goodsHistory.reserve %detail.goodsHistory.minPackQty));
|
|
|
+ }
|
|
|
toaster.pop('info','提示','库存不足');
|
|
|
}else {
|
|
|
detail.number = num;
|
|
|
@@ -197,11 +288,26 @@ 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 id = $scope.deliveryList[detail.storeid].id;
|
|
|
+ var arr = data[0];
|
|
|
+ $scope.ruleMap[detail.storeid] = arr;
|
|
|
+ angular.forEach(arr, function (item) {
|
|
|
+ if (item.id == id){
|
|
|
+ $scope.deliveryList[detail.storeid] = item;
|
|
|
+ $scope.fareList[detail.storeid] = item.fare;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.calculateFare();
|
|
|
+ }
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
// 减少按钮,每次减minPackQty
|
|
|
$scope.reduce = function(detail){
|
|
|
- var num = NumberService.sub(detail.number, detail.goodsHistory.minPackQty);
|
|
|
+ var num = NumberService.sub(detail.number, detail.goodsHistory.perQty);
|
|
|
if(Number(num) < detail.goodsHistory.minBuyQty) {
|
|
|
toaster.pop('info', '提示','该商品最少购买' + detail.goodsHistory.minBuyQty + "件");
|
|
|
detail.number = detail.goodsHistory.minBuyQty;
|
|
|
@@ -212,6 +318,49 @@ 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 id = $scope.deliveryList[detail.storeid].id;
|
|
|
+ var arr = data[0];
|
|
|
+ $scope.ruleMap[detail.storeid] = arr;
|
|
|
+ angular.forEach(arr, function (item) {
|
|
|
+ if (item.id == id){
|
|
|
+ $scope.deliveryList[detail.storeid] = item;
|
|
|
+ $scope.fareList[detail.storeid] = item.fare;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $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){
|
|
|
+
|
|
|
+ }
|
|
|
+ }, function (error) {
|
|
|
+ // toaster.pop("error", error.data);
|
|
|
+ })
|
|
|
};
|
|
|
|
|
|
// 输入购买量限制
|
|
|
@@ -221,31 +370,83 @@ define(['app/app'], function(app) {
|
|
|
toaster.pop("info", "提示", "该商品最少购买" + detail.goodsHistory.minBuyQty + "件");
|
|
|
detail.number = detail.goodsHistory.minBuyQty;
|
|
|
}else if(detail.number > detail.goodsHistory.reserve){
|
|
|
- detail.number = Number(NumberService.sub(detail.goodsHistory.reserve, detail.goodsHistory.reserve %detail.goodsHistory.minPackQty));
|
|
|
+ if(detail.goodsHistory.breakUp) {
|
|
|
+ detail.number = detail.goodsHistory.reserve;
|
|
|
+ }else{
|
|
|
+ detail.number = Number(NumberService.sub(detail.goodsHistory.reserve, detail.goodsHistory.reserve %detail.goodsHistory.minPackQty));
|
|
|
+ }
|
|
|
toaster.pop('info', '提示','库存不足');
|
|
|
+ }else {
|
|
|
+ if(!detail.goodsHistory.breakUp) {
|
|
|
+ var remandar = detail.number % detail.goodsHistory.minPackQty;
|
|
|
+ if(remandar != 0) {
|
|
|
+ detail.number = Number(NumberService.add(NumberService.sub(detail.number, detail.number % detail.goodsHistory.minPackQty), detail.goodsHistory.minPackQty));
|
|
|
+ if(detail.number > detail.goodsHistory.reserve) {
|
|
|
+ detail.number = NumberService.sub(detail.goodsHistory.reserve, detail.goodsHistory.reserve % detail.goodsHistory.minPackQty);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
$scope.disabledAddAndSub(detail);
|
|
|
$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 id = $scope.deliveryList[detail.storeid].id;
|
|
|
+ var arr = data[0];
|
|
|
+ $scope.ruleMap[detail.storeid] = arr;
|
|
|
+ angular.forEach(arr, function (item) {
|
|
|
+ if (item.id == id){
|
|
|
+ $scope.deliveryList[detail.storeid] = item;
|
|
|
+ $scope.fareList[detail.storeid] = item.fare;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $scope.calculateFare();
|
|
|
+ }
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 是否失效- +
|
|
|
*/
|
|
|
$scope.disabledAddAndSub = function(detail) {
|
|
|
- if((Number(detail.number) - Number(detail.goodsHistory.minPackQty)) < Number(detail.goodsHistory.minBuyQty)) {
|
|
|
+ if((Number(detail.number) - Number(detail.goodsHistory.perQty)) < Number(detail.goodsHistory.minBuyQty)) {
|
|
|
detail.minusDisabled = true;
|
|
|
}else {
|
|
|
detail.minusDisabled = false;
|
|
|
}
|
|
|
- if(Number(detail.number) + Number(detail.goodsHistory.minPackQty) > Number(detail.goodsHistory.reserve)) {
|
|
|
+ if(Number(detail.number) + Number(detail.goodsHistory.perQty) > Number(detail.goodsHistory.reserve)) {
|
|
|
detail.addDisabled = true;
|
|
|
}else {
|
|
|
detail.addDisabled = false;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ //验证配送规则
|
|
|
+ var checkRule = function () {
|
|
|
+ var value = true;
|
|
|
+ angular.forEach($scope.ruleMap, function (v) {
|
|
|
+ if (v.length == 0){
|
|
|
+ value = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return value;
|
|
|
+ };
|
|
|
+ //验证是否选择上门自提,却没有选择自提点
|
|
|
+ var checkTakeSelf = function () {
|
|
|
+ var value = true;
|
|
|
+ angular.forEach($scope.deliveryList, function (v, k) {
|
|
|
+ if (v.method == 1303){
|
|
|
+ if ($scope.takeSelfList[k] == null){
|
|
|
+ value = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return value;
|
|
|
+ };
|
|
|
+
|
|
|
//确认付款
|
|
|
$scope.confirmPay = function() {
|
|
|
if($scope.order.status == 502 || $scope.order.status == 503) {
|
|
|
@@ -264,6 +465,16 @@ define(['app/app'], function(app) {
|
|
|
}
|
|
|
return ;
|
|
|
}
|
|
|
+ var validRule = checkRule();
|
|
|
+ if (!validRule){
|
|
|
+ toaster.pop("info", "当前地址部分卖家无法配送,请重新选择地址或与卖家协商处理");
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ var validTakeSelf = checkTakeSelf();
|
|
|
+ if (!validTakeSelf){
|
|
|
+ toaster.pop("info", "请选择一个自提点");
|
|
|
+ return ;
|
|
|
+ }
|
|
|
var orderInfos = [], orderInfo;
|
|
|
orderInfo = generateOrderInfo();
|
|
|
if(orderInfo == null) {
|
|
|
@@ -347,7 +558,7 @@ define(['app/app'], function(app) {
|
|
|
|
|
|
orderInfo.id = $scope.order.id;
|
|
|
orderInfo.orderid = $scope.order.orderid;
|
|
|
- orderInfo.deliverytype = $scope.order.deliverytype; // 配送方式
|
|
|
+ // orderInfo.deliverytype = $scope.order.deliverytype; // 配送方式
|
|
|
|
|
|
if($scope.order.currency == 'USD' && $scope.order.paytype == '1102') {
|
|
|
toaster.pop('info', '美元请线下付款');
|
|
|
@@ -359,7 +570,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);*/
|
|
|
@@ -379,9 +591,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) {
|
|
|
@@ -391,11 +604,14 @@ define(['app/app'], function(app) {
|
|
|
orderInfo.invoiceid = $scope.bill.id; // 发票主键
|
|
|
}
|
|
|
|
|
|
- orderInfo.totalprice = $scope.order.ensurePrice; // 应付总额
|
|
|
+ orderInfo.totalprice = $scope.order.totalprice; // 应付总额,不含运费
|
|
|
orderInfo.currency = $scope.order.currency; // 币别
|
|
|
- orderInfo.orderRemark = angular.toJson($scope.remarkList);
|
|
|
- // console.log(orderInfo.orderRemark);
|
|
|
- // orderInfo.orderRemark = $scope.order.orderRemark; // 交易备注
|
|
|
+ orderInfo.orderRemark = angular.toJson($scope.remarkList);//订单备注
|
|
|
+ orderInfo.splitInfo = {
|
|
|
+ ruleList : angular.toJson($scope.deliveryList),
|
|
|
+ takeList : angular.toJson($scope.takeSelfList)
|
|
|
+ };
|
|
|
+
|
|
|
orderInfo.paytype = $scope.order.paytype;
|
|
|
orderInfo.orderDetails = convertOrderDetails(); // 订单明细信息:id、number
|
|
|
|
|
|
@@ -411,6 +627,7 @@ define(['app/app'], function(app) {
|
|
|
number: v.number,
|
|
|
taxUnitprice: v.taxUnitprice,
|
|
|
remark : v.remark,
|
|
|
+ goodsnumber : v.goodsnumber,
|
|
|
storeid : v.storeid
|
|
|
});
|
|
|
});
|
|
|
@@ -433,13 +650,13 @@ define(['app/app'], function(app) {
|
|
|
}
|
|
|
// 人民币为专用增值税发票,美元不开发票 --1205专用增值税发票 --1206普通发票 --1207不开发票
|
|
|
if($scope.order.currency == 'USD') {
|
|
|
- $scope.order.invoicetype = 1207;
|
|
|
+ $scope.order.invoicetype = 1207;
|
|
|
$scope.order.paytype = '1103';
|
|
|
}else {
|
|
|
- $scope.order.invoicetype = 1205;
|
|
|
+ $scope.order.invoicetype = 1205;
|
|
|
$scope.order.paytype = '1102';
|
|
|
}
|
|
|
- // 默认选择UU配送 --1301UU配送 --1302上门自提
|
|
|
+ // 默认选择第三方配送 --1301第三方配送 --卖家配送 --1303上门自提
|
|
|
$scope.order.deliverytype = 1301;
|
|
|
|
|
|
//获取地址的信息
|
|
|
@@ -484,8 +701,7 @@ define(['app/app'], function(app) {
|
|
|
$scope.sendAddress.push(address);
|
|
|
}
|
|
|
}
|
|
|
- $scope.payment.address = address;
|
|
|
- $scope.formatArea = $scope.payment.address.area.replace(/,/g,' ');
|
|
|
+ $scope.selectAdd(address);
|
|
|
}, function(){
|
|
|
toaster.pop('info', '提示 ' + '您已取消收货地址的编辑');
|
|
|
});
|
|
|
@@ -520,13 +736,13 @@ define(['app/app'], function(app) {
|
|
|
|
|
|
|
|
|
// 获取当前数量的对应价格区间的单据信息
|
|
|
- if(properPrice.length > 0) {
|
|
|
- detail.usdUnitPrice = properPrice[0].uSDPrice;
|
|
|
- detail.rmbUnitPrice = properPrice[0].rMBPrice;
|
|
|
- }else {
|
|
|
- detail.usdUnitPrice = detail.goodsHistory.prices[detail.goodsHistory.prices.length - 1].uSDPrice;
|
|
|
- detail.rmbUnitPrice = detail.goodsHistory.prices[detail.goodsHistory.prices.length - 1].rMBPrice;
|
|
|
- }
|
|
|
+ if(properPrice.length > 0) {
|
|
|
+ detail.usdUnitPrice = properPrice[0].uSDPrice;
|
|
|
+ detail.rmbUnitPrice = properPrice[0].rMBPrice;
|
|
|
+ }else {
|
|
|
+ detail.usdUnitPrice = detail.goodsHistory.prices[detail.goodsHistory.prices.length - 1].uSDPrice;
|
|
|
+ detail.rmbUnitPrice = detail.goodsHistory.prices[detail.goodsHistory.prices.length - 1].rMBPrice;
|
|
|
+ }
|
|
|
|
|
|
if (currency == 'RMB') {
|
|
|
detail.taxUnitprice = detail.rmbUnitPrice;
|
|
|
@@ -539,7 +755,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));
|
|
|
@@ -550,7 +766,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)
|
|
|
});
|
|
|
};
|
|
|
|
|
|
@@ -595,7 +811,7 @@ define(['app/app'], function(app) {
|
|
|
$scope.isModify = isModify;
|
|
|
$scope.validEmail = function (email) {
|
|
|
return /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(email)
|
|
|
- };
|
|
|
+ };
|
|
|
|
|
|
$http.get('static/js/prod/data/city.json').success(function(data) {
|
|
|
$scope.division = data;
|
|
|
@@ -613,12 +829,12 @@ define(['app/app'], function(app) {
|
|
|
toaster.pop('error', '系统错误 ' + '加载城市信息失败');
|
|
|
});
|
|
|
|
|
|
- //验证数据
|
|
|
+ //验证数据
|
|
|
$scope.checkForm = function(num) {
|
|
|
var size;
|
|
|
if(num == 1) {
|
|
|
if ($scope.address.name){
|
|
|
- size = $scope.address.name.replace(/[^x00-xFF]/g,'**').length;
|
|
|
+ size = $scope.address.name.replace(/[^\x00-\xff]/g,'**').length;
|
|
|
if (size > 20) {
|
|
|
$scope.userError = true;
|
|
|
return;
|
|
|
@@ -627,7 +843,7 @@ define(['app/app'], function(app) {
|
|
|
}
|
|
|
} else if(num == 2) {
|
|
|
if ($scope.address.tel){
|
|
|
- size = $scope.address.tel.replace(/[^x00-xFF]/g,'**').length;
|
|
|
+ size = $scope.address.tel.replace(/[^\x00-\xff]/g,'**').length;
|
|
|
if (size < 8 || size > 11) {
|
|
|
$scope.telError = true;
|
|
|
return;
|
|
|
@@ -642,7 +858,7 @@ define(['app/app'], function(app) {
|
|
|
}
|
|
|
} else if(num == 3) {
|
|
|
if ($scope.address.detailAddress){
|
|
|
- size = $scope.address.detailAddress.replace(/[^x00-xFF]/g,'**').length;
|
|
|
+ size = $scope.address.detailAddress.replace(/[^\x00-\xff]/g,'**').length;
|
|
|
if (size > 60) {
|
|
|
$scope.addrError = true;
|
|
|
return;
|