|
|
@@ -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', 'TakeSelf', 'StoreInfo', function($scope, $rootScope, $stateParams, $modal, $state, Bill, toaster, Order, $filter, ShippingAddress, Ysepay, $q, NumberService, Cart, $timeout, DistributionRule, TakeSelf, StoreInfo) {
|
|
|
+ app.register.controller('orderPayCtrl', ['$scope', '$rootScope', '$stateParams', '$modal', '$state', 'Bill', 'toaster', 'Order', '$filter', 'ShippingAddress', 'Ysepay', '$q', 'NumberService', 'Cart', '$timeout', 'DistributionRule', 'TakeSelf', 'StoreInfo', 'AuthenticationService', function($scope, $rootScope, $stateParams, $modal, $state, Bill, toaster, Order, $filter, ShippingAddress, Ysepay, $q, NumberService, Cart, $timeout, DistributionRule, TakeSelf, StoreInfo, AuthenticationService) {
|
|
|
$scope.userInfo = $rootScope.userInfo;
|
|
|
document.title = '结算页-优软商城';
|
|
|
$rootScope.active = 'buyer_cart';
|
|
|
@@ -599,103 +599,111 @@ define(['app/app'], function(app) {
|
|
|
|
|
|
//确认付款
|
|
|
$scope.imperfect = false;//暂不完善
|
|
|
- $scope.confirmPay = function() {
|
|
|
- if ($scope.userInfo) {
|
|
|
- // 安全级别
|
|
|
- if (!$scope.userInfo.pwdEnable || !$scope.userInfo.haveUserQuestion||!$scope.userInfo.emailValidCode || $scope.userInfo.emailValidCode != 2) {
|
|
|
- $scope.openHomeCenterModel();
|
|
|
- } else {
|
|
|
- if($scope.order.status == 502 || $scope.order.status == 503) {
|
|
|
- var arr = [];
|
|
|
- if($scope.order.orderids) {
|
|
|
- arr = $scope.order.orderids.split(",");
|
|
|
- }else {
|
|
|
- arr.push($scope.order.orderid);
|
|
|
- }
|
|
|
- if ($scope.order.currency == 'RMB' && $scope.order.paytype == '1102') {
|
|
|
- paymentEnsure(arr);
|
|
|
- } else if($scope.order.paytype == '1103') {
|
|
|
- $state.go('order_transfer', {orderid : enIdFilter(arr.join("-"))});
|
|
|
- }else {
|
|
|
- toaster.pop('info', '美元请线下付款');
|
|
|
- }
|
|
|
- return ;
|
|
|
- }
|
|
|
- var validRule = checkRule();
|
|
|
- if (!validRule){
|
|
|
- toaster.pop("info", "当前地址部分卖家无法配送,请重新选择地址或与卖家协商处理");
|
|
|
- return ;
|
|
|
+ var doComfirmPay = function () {
|
|
|
+ // 安全级别
|
|
|
+ if (!$scope.userInfo.pwdEnable || !$scope.userInfo.haveUserQuestion||!$scope.userInfo.emailValidCode || $scope.userInfo.emailValidCode != 2) {
|
|
|
+ $scope.openHomeCenterModel();
|
|
|
+ } else {
|
|
|
+ if($scope.order.status == 502 || $scope.order.status == 503) {
|
|
|
+ var arr = [];
|
|
|
+ if($scope.order.orderids) {
|
|
|
+ arr = $scope.order.orderids.split(",");
|
|
|
+ }else {
|
|
|
+ arr.push($scope.order.orderid);
|
|
|
}
|
|
|
- var validTakeSelf = checkTakeSelf();
|
|
|
- if (!validTakeSelf){
|
|
|
- toaster.pop("info", "请选择一个自提点");
|
|
|
- return ;
|
|
|
+ if ($scope.order.currency == 'RMB' && $scope.order.paytype == '1102') {
|
|
|
+ paymentEnsure(arr);
|
|
|
+ } else if($scope.order.paytype == '1103') {
|
|
|
+ $state.go('order_transfer', {orderid : enIdFilter(arr.join("-"))});
|
|
|
+ }else {
|
|
|
+ toaster.pop('info', '美元请线下付款');
|
|
|
}
|
|
|
- var orderInfos = [], orderInfo;
|
|
|
- orderInfo = generateOrderInfo();
|
|
|
- if(orderInfo == null) {
|
|
|
+ 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) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ orderInfos.push(orderInfo);
|
|
|
+ if(!$scope.imperfect){
|
|
|
+ var validBill = checkBill();
|
|
|
+ if (!validBill){
|
|
|
+ // toaster.pop('info', '请完善专票信息');
|
|
|
+ $scope.showBillFrame = true;
|
|
|
return ;
|
|
|
}
|
|
|
- orderInfos.push(orderInfo);
|
|
|
- if(!$scope.imperfect){
|
|
|
- var validBill = checkBill();
|
|
|
- if (!validBill){
|
|
|
- // toaster.pop('info', '请完善专票信息');
|
|
|
- $scope.showBillFrame = true;
|
|
|
- return ;
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- Order.ensure({orderid: enIdFilter($scope.order.orderid)}, orderInfos, function(data){
|
|
|
- if(data.code == 1) {
|
|
|
- if (data.data && data.data[0]) {
|
|
|
- var arr = [];
|
|
|
- var batchCodes = [];
|
|
|
- for(var i = 0; i < data.data.length; i++) {
|
|
|
- arr.push(data.data[i].orderid);
|
|
|
- for(var j = 0; j < data.data[i].orderDetails.length; j++) {
|
|
|
- batchCodes.push(data.data[i].orderDetails[j].batchCode);
|
|
|
- }
|
|
|
- }
|
|
|
- if(!$scope.order.buyNow) {
|
|
|
- Cart.deleteByBatchCode({}, batchCodes, function(data) {
|
|
|
- }, function(response) {
|
|
|
- });
|
|
|
+ Order.ensure({orderid: enIdFilter($scope.order.orderid)}, orderInfos, function(data){
|
|
|
+ if(data.code == 1) {
|
|
|
+ if (data.data && data.data[0]) {
|
|
|
+ var arr = [];
|
|
|
+ var batchCodes = [];
|
|
|
+ for(var i = 0; i < data.data.length; i++) {
|
|
|
+ arr.push(data.data[i].orderid);
|
|
|
+ for(var j = 0; j < data.data[i].orderDetails.length; j++) {
|
|
|
+ batchCodes.push(data.data[i].orderDetails[j].batchCode);
|
|
|
}
|
|
|
- if ($scope.order.currency == 'RMB' && $scope.order.paytype == '1102') {
|
|
|
- paymentEnsure(arr);
|
|
|
- } else if($scope.order.paytype == '1103') {
|
|
|
- console.log(arr.length)
|
|
|
- if(arr.length != 1){
|
|
|
- $state.go('downPayment', {orderid : enIdFilter(arr.join('-'))});
|
|
|
- }else {
|
|
|
- $state.go('order_transfer', {orderid : enIdFilter(arr.join('-'))});
|
|
|
- }
|
|
|
+ }
|
|
|
+ if(!$scope.order.buyNow) {
|
|
|
+ Cart.deleteByBatchCode({}, batchCodes, function(data) {
|
|
|
+ }, function(response) {
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if ($scope.order.currency == 'RMB' && $scope.order.paytype == '1102') {
|
|
|
+ paymentEnsure(arr);
|
|
|
+ } else if($scope.order.paytype == '1103') {
|
|
|
+ console.log(arr.length)
|
|
|
+ if(arr.length != 1){
|
|
|
+ $state.go('downPayment', {orderid : enIdFilter(arr.join('-'))});
|
|
|
}else {
|
|
|
- toaster.pop('info', '美元请线下付款');
|
|
|
- $state.go('buyer_order');
|
|
|
+ $state.go('order_transfer', {orderid : enIdFilter(arr.join('-'))});
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
- }else {
|
|
|
- if(data.code == 6) { //产品信息有更新
|
|
|
- toaster.pop('warning', data.message + ",请刷新界面之后重新操作");
|
|
|
- }else if(data.code == 7){
|
|
|
- toaster.pop('warning', data.message + ",将为您跳转到购物车界面");
|
|
|
- $timeout(function () {
|
|
|
- $state.go('buyer_cart');
|
|
|
- }, 1000);
|
|
|
}else {
|
|
|
- toaster.pop('warning', data.message);
|
|
|
+ toaster.pop('info', '美元请线下付款');
|
|
|
+ $state.go('buyer_order');
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(data.code == 6) { //产品信息有更新
|
|
|
+ toaster.pop('warning', data.message + ",请刷新界面之后重新操作");
|
|
|
+ }else if(data.code == 7){
|
|
|
+ toaster.pop('warning', data.message + ",将为您跳转到购物车界面");
|
|
|
+ $timeout(function () {
|
|
|
+ $state.go('buyer_cart');
|
|
|
+ }, 1000);
|
|
|
+ }else {
|
|
|
+ toaster.pop('warning', data.message);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- }, function(response) {
|
|
|
- toaster.pop('error', '确认订单失败,' + response.data);
|
|
|
- });
|
|
|
- }
|
|
|
+ }, function(response) {
|
|
|
+ toaster.pop('error', '确认订单失败,' + response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.confirmPay = function() {
|
|
|
+ if ($scope.userInfo) {
|
|
|
+ doComfirmPay();
|
|
|
} else {
|
|
|
- toaster.pop('error', '未获取到登录信息,请刷新页面后重试');
|
|
|
+ AuthenticationService.getAuthentication().success(function (data) {
|
|
|
+ $scope.userInfo = data;
|
|
|
+ doComfirmPay();
|
|
|
+ }).error(function (err) {
|
|
|
+ toaster.pop('error', err || '获取登录信息失败,请刷新页面后重试');
|
|
|
+ })
|
|
|
}
|
|
|
};
|
|
|
|