Ver Fonte

余额抵扣逻辑调整

zhengjinyi há 3 anos atrás
pai
commit
2f29cb3016

+ 49 - 53
src/main/resources/static/js/user-center/order/detail.js

@@ -165,68 +165,65 @@ var orderPage = new Vue({
         },
         hanldPayOrderFn:function(){//支付订单
             var _self = this;
-            OrderApi.OrderPaymentValidation({orderId:_self.orderId},function(r){
-                if(r.code*1 === 0){
-                    var dataCode = r.data.code;
-                    _self.payModelData = r.data;
-                    switch(dataCode){
-                        case 1:
-                            _self.modelType = 1;
-                            CAIMEI.Popup({
-                                content: '<div class="payAlert">您有采美余额<em>¥'+toFloat(r.data.ableUserMoney)+'</em>暂未使用,是否需要抵扣订单? 抵扣后您只需再支付<em>¥'+toFloat(r.data.pendingPayments)+'</em></div>',
-                                confitmBtnText: '抵扣,继续付款',
-                                cancelBtnText: '不抵扣,继续付款'
-                            },function(){
-                                // 抵扣,继续付款
-                                _self.hanldPaymentConfirm(1)
-                            },function(){
-                                // 不抵扣,继续付款
-                                _self.hanldCancelConfirm()
-                            });
-                            break;
-                        case 2:
-                            _self.modelType = 2;
-                            CAIMEI.Popup({
-                                content: '<div class="payAlert">您有采美余额<em>¥'+toFloat(r.data.ableUserMoney)+'</em>暂未使用,是否需要抵扣订单? 抵扣后订单支付完成</div>',
-                                confitmBtnText: '抵扣',
-                                cancelBtnText: '不抵扣,继续付款'
-                            },function(){
-                                // 抵扣全款
-                                _self.hanldPaymentConfirm(2);
-                            },function(){
-                                // 不抵扣,继续付款
-                                _self.hanldCancelConfirm();
-                            });
-                            break;
-                        case -1:
-                            CAIMEI.Alert('订单已申请全部退款,无需再付款!', '确定', false);
-                            break;
-                        default:
-                            if(r.data.onlinePayFlag == 1){
-                                _self.modelType = 3;
-                                window.location.href = '/pay/caimei-payunder.html?orderId='+_self.orderId;
-                            }else{
-                                window.location.href = '/pay/caimei-paylist.html?&orderId='+_self.orderId;
-                            }
+            OrderApi.OrderPaymentValidation({orderId:_self.orderId},function(response){
+                if(response.code == 0){
+                    var data = _self.payModelData = response.data
+                    if(data.balanceFlag == 1){// 0可以走余额抵扣,1不能走余额抵扣
+                        window.location.href = '/pay/caimei-paylist.html?&orderId='+_self.orderId;
+                    }else{
+                        switch(data.code){
+                            case 1:
+                                _self.modelType = 1;
+                                CAIMEI.Popup({
+                                    content: '<div class="payAlert">您有采美余额<em>¥'+toFloat(data.ableUserMoney)+'</em>暂未使用,是否需要抵扣订单? 抵扣后您只需再支付<em>¥'+toFloat(data.pendingPayments)+'</em></div>',
+                                    confitmBtnText: '抵扣,继续付款',
+                                    cancelBtnText: '不抵扣,继续付款'
+                                },function(){
+                                    // 抵扣,继续付款
+                                    _self.hanldPaymentConfirm(1)
+                                },function(){
+                                    // 不抵扣,继续付款
+                                    _self.hanldCancelConfirm()
+                                });
+                                break;
+                            case 2:
+                                _self.modelType = 2;
+                                CAIMEI.Popup({
+                                    content: '<div class="payAlert">您有采美余额<em>¥'+toFloat(data.ableUserMoney)+'</em>暂未使用,是否需要抵扣订单? 抵扣后订单支付完成</div>',
+                                    confitmBtnText: '抵扣',
+                                    cancelBtnText: '不抵扣,继续付款'
+                                },function(){
+                                    // 抵扣全款
+                                    _self.hanldPaymentConfirm(2);
+                                },function(){
+                                    // 不抵扣,继续付款
+                                    _self.hanldCancelConfirm();
+                                });
+                                break;
+                            case -1:
+                                CAIMEI.Alert('订单已申请全部退款,无需再付款!', '确定', false);
+                                break;
+                            default:
+                                if(_self.orderInfo.onlinePayFlag == 1){
+                                    window.location.href = '/pay/caimei-payunder.html?orderId='+_self.orderId;
+                                }else{
+                                    window.location.href = '/pay/caimei-paylist.html?orderId='+_self.orderId;
+                                }
+                        }
                     }
                 }else{
-                    CAIMEI.Alert(r.msg, '确定', false);
+                    CAIMEI.Alert(response.msg, '确定', false);
                 }
             })
         },
-        hanldPaymentConfirm:function() {//余额抵扣跳转
+        hanldPaymentConfirm:function(modelType) {//余额抵扣跳转
             var _self = this;
             OrderApi.OrderBalanceDeduction({orderId: _self.orderId}, function (response) {
                 if (response.code == 0) {
-                    if (_self.modelType === 2) {
+                    if (modelType === 2) {
                         window.location.href = '/pay/success.html?pageType=www&type=success&payAmount='+_self.payModelData.pendingPayments;
                     } else {
-                        if (_self.orderInfo.onlinePayFlag === 1) {
-                            _self.modelType = 3;
-                            window.location.href = '/pay/caimei-payunder.html?orderId='+_self.orderId;
-                        } else {
-                            window.location.href = '/pay/caimei-paylist.html?orderId='+_self.orderId;
-                        }
+                        window.location.href = '/pay/caimei-payunder.html?orderId='+_self.orderId;
                     }
                 } else {
                     CAIMEI.Alert(response.msg, '确定', false);
@@ -236,7 +233,6 @@ var orderPage = new Vue({
         hanldCancelConfirm:function(){//不使用余额抵扣直接跳转收银台
             var _self = this;
             if(_self.orderInfo.onlinePayFlag == 1){
-                _self.modelType = 3;
                 window.location.href = '/pay/caimei-payunder.html?orderId='+_self.orderId;
             }else{
                 window.location.href = '/pay/caimei-paylist.html?orderId='+_self.orderId;

+ 49 - 53
src/main/resources/static/js/user-center/order/list.js

@@ -242,68 +242,65 @@ var orderPage = new Vue({
             var _self = this;
             _self.hanldOrderData = order;
             _self.orderIdentificationId = '#'+orderId+'#';
-            OrderApi.OrderPaymentValidation({orderId:orderId},function(r){
-                if(r.code*1 === 0){
-                    var dataCode = r.data.code;
-                    _self.payModelData = r.data;
-                    switch(dataCode){
-                        case 1:
-                            _self.modelType = 1;
-                            CAIMEI.Popup({
-                                content: '<div class="payAlert">您有采美余额<em>¥'+toFloat(r.data.ableUserMoney)+'</em>暂未使用,是否需要抵扣订单? 抵扣后您只需再支付<em>¥'+toFloat(r.data.pendingPayments)+'</em></div>',
-                                confitmBtnText: '抵扣,继续付款',
-                                cancelBtnText: '不抵扣,继续付款'
-                            },function(){
-                                // 抵扣,继续付款
-                                _self.hanldPaymentConfirm(1)
-                            },function(){
-                                // 不抵扣,继续付款
-                                _self.hanldCancelConfirm()
-                            });
-                            break;
-                        case 2:
-                            _self.modelType = 2;
-                            CAIMEI.Popup({
-                                content: '<div class="payAlert">您有采美余额<em>¥'+toFloat(r.data.ableUserMoney)+'</em>暂未使用,是否需要抵扣订单? 抵扣后订单支付完成</div>',
-                                confitmBtnText: '抵扣',
-                                cancelBtnText: '不抵扣,继续付款'
-                            },function(){
-                                // 抵扣全款
-                                _self.hanldPaymentConfirm(2);
-                            },function(){
-                                // 不抵扣,继续付款
-                                _self.hanldCancelConfirm()
-                            });
-                            break;
-                        case -1:
-                            CAIMEI.Alert('订单已申请全部退款,无需再付款!', '确定', false);
-                            break;
-                        default:
-                            if(r.data.onlinePayFlag == 1){
-                                _self.modelType = 3;
-                                window.location.href = '/pay/caimei-payunder.html?orderId='+orderId;
-                            }else{
-                                window.location.href = '/pay/caimei-paylist.html?orderId='+orderId;
-                            }
+            OrderApi.OrderPaymentValidation({orderId:orderId},function(response){
+                if(response.code == 0){
+                    var data = _self.payModelData = response.data
+                    if(data.balanceFlag == 1){// 0可以走余额抵扣,1不能走余额抵扣
+                        window.location.href = '/pay/caimei-paylist.html?&orderId='+orderId;
+                    }else{
+                        switch(data.code){
+                            case 1:
+                                _self.modelType = 1;
+                                CAIMEI.Popup({
+                                    content: '<div class="payAlert">您有采美余额<em>¥'+toFloat(data.ableUserMoney)+'</em>暂未使用,是否需要抵扣订单? 抵扣后您只需再支付<em>¥'+toFloat(data.pendingPayments)+'</em></div>',
+                                    confitmBtnText: '抵扣,继续付款',
+                                    cancelBtnText: '不抵扣,继续付款'
+                                },function(){
+                                    // 抵扣,继续付款
+                                    _self.hanldPaymentConfirm(1)
+                                },function(){
+                                    // 不抵扣,继续付款
+                                    _self.hanldCancelConfirm()
+                                });
+                                break;
+                            case 2:
+                                _self.modelType = 2;
+                                CAIMEI.Popup({
+                                    content: '<div class="payAlert">您有采美余额<em>¥'+toFloat(data.ableUserMoney)+'</em>暂未使用,是否需要抵扣订单? 抵扣后订单支付完成</div>',
+                                    confitmBtnText: '抵扣',
+                                    cancelBtnText: '不抵扣,继续付款'
+                                },function(){
+                                    // 抵扣全款
+                                    _self.hanldPaymentConfirm(2);
+                                },function(){
+                                    // 不抵扣,继续付款
+                                    _self.hanldCancelConfirm();
+                                });
+                                break;
+                            case -1:
+                                CAIMEI.Alert('订单已申请全部退款,无需再付款!', '确定', false);
+                                break;
+                            default:
+                                if(_self.hanldOrderData.onlinePayFlag == 1){
+                                    window.location.href = '/pay/caimei-payunder.html?orderId='+orderId;
+                                }else{
+                                    window.location.href = '/pay/caimei-paylist.html?orderId='+orderId;
+                                }
+                        }
                     }
                 }else{
-                    CAIMEI.Alert(r.msg, '确定', false);
+                    CAIMEI.Alert(response.msg, '确定', false);
                 }
             })
         },
-        hanldPaymentConfirm:function(type) {//余额抵扣跳转
+        hanldPaymentConfirm:function(modelType) {//余额抵扣跳转
             var _self = this;
             OrderApi.OrderBalanceDeduction({orderId: _self.payModelData.orderId}, function (response) {
                 if (response.code == 0) {
-                    if (type === 2) {
+                    if (modelType === 2) {
                         window.location.href = '/pay/success.html?pageType=www&type=success&payAmount='+_self.payModelData.pendingPayments;
                     } else {
-                        if (response.data.order.onlinePayFlag === 1) {
-                            _self.modelType = 3;
-                            window.location.href = '/pay/caimei-payunder.html?orderId='+_self.hanldOrderData.orderId;
-                        } else {
-                            window.location.href = '/pay/caimei-paylist.html?orderId='+_self.hanldOrderData.orderId;
-                        }
+                        window.location.href = '/pay/caimei-payunder.html?orderId='+_self.hanldOrderData.orderId;
                     }
                 } else {
                     CAIMEI.Alert(response.msg, '确定', false);
@@ -313,7 +310,6 @@ var orderPage = new Vue({
         hanldCancelConfirm:function(){//不使用余额抵扣直接跳转收银台
             var _self = this;
             if(_self.hanldOrderData.onlinePayFlag == 1){
-                _self.modelType = 3;
                 window.location.href = '/pay/caimei-payunder.html?orderId='+_self.hanldOrderData.orderId;
             }else{
                 window.location.href = '/pay/caimei-paylist.html?orderId='+_self.hanldOrderData.orderId;