Explorar el Código

线下付款包邮问题优化

吴昊天 hace 2 años
padre
commit
3f1b2edca4

+ 1 - 1
crmeb/app/api/controller/v1/order/StoreOrderController.php

@@ -125,7 +125,7 @@ class StoreOrderController
         if ($this->services->be(['order_id|unique' => $key, 'uid' => $uid, 'is_del' => 0]))
             return app('json')->status('extend_order', 410173, ['orderId' => $key, 'key' => $key]);
         list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, $shipping_type) = $request->postMore([
-            'addressId', 'couponId', ['payType', 'yue'], ['useIntegral', 0], 'mark', ['combinationId', 0], ['pinkId', 0], ['seckill_id', 0], ['bargainId', ''],
+            'addressId', 'couponId', ['payType', ''], ['useIntegral', 0], 'mark', ['combinationId', 0], ['pinkId', 0], ['seckill_id', 0], ['bargainId', ''],
             ['shipping_type', 1],
         ], true);
         $payType = strtolower($payType);

+ 1 - 1
crmeb/app/services/order/StoreOrderComputedServices.php

@@ -448,7 +448,7 @@ class StoreOrderComputedServices extends BaseServices
         }
         //会员邮费享受折扣
         if ($storePostage) {
-            $express_rule_number = 0;
+            $express_rule_number = 100;
             if (!$userInfo) {
                 /** @var UserServices $userService */
                 $userService = app()->make(UserServices::class);

+ 21 - 1
crmeb/app/services/order/StoreOrderServices.php

@@ -1724,6 +1724,24 @@ HTML;
      */
     public function setOrderTypePayOffline(string $orderId)
     {
+        if (($count = strpos($orderId, '_')) !== false) {
+            $orderId = substr($orderId, $count + 1);
+        }
+        if (sys_config('offline_postage', 0) == 1) {
+            $orderInfo = $this->dao->get(['order_id' => $orderId]);
+            $cartInfoService = app()->make(StoreOrderCartInfoServices::class);
+            $cartInfo = $cartInfoService->getColumn(['oid' => $orderInfo['id']], 'cart_info', 'id');
+            foreach ($cartInfo as $key => &$item) {
+                $item_arr = json_decode($item, true);
+                $item_arr['postage_price'] = $item_arr['origin_postage_price'] = 0;
+                $cartInfoService->update(['id' => $key], ['cart_info' => json_encode($item_arr)]);
+            }
+            return $this->dao->update($orderId, [
+                'pay_type' => 'offline',
+                'pay_price' => bcsub((string)$orderInfo['pay_price'], (string)$orderInfo['pay_postage'], 2),
+                'pay_postage' => 0
+            ], 'order_id');
+        }
         return $this->dao->update($orderId, ['pay_type' => 'offline'], 'order_id');
     }
 
@@ -2508,7 +2526,7 @@ HTML;
 
         switch ($type) {
             case 'order':
-                $info = $this->dao->get(['order_id' => $orderId], ['pay_price', 'add_time', 'combination_id', 'seckill_id', 'bargain_id']);
+                $info = $this->dao->get(['order_id' => $orderId], ['pay_price', 'add_time', 'combination_id', 'seckill_id', 'bargain_id', 'pay_postage']);
                 if (!$info) {
                     throw new PayException('您支付的订单不存在');
                 }
@@ -2529,6 +2547,8 @@ HTML;
                 }
 
                 $data['pay_price'] = $info['pay_price'];
+                $data['pay_postage'] = $info['pay_postage'];
+                $data['offline_postage'] = sys_config('offline_postage', 0);
                 $data['invalid_time'] = $time;
 
                 break;

+ 24 - 11
template/uni-app/pages/goods/cashier/index.vue

@@ -1,9 +1,9 @@
 <template>
-	<view class="page" v-if="payPrice">
+	<view class="page" v-if="payPriceShow">
 		<view class="pay-price">
 			<view class="price">
 				<text class="unit">{{$t(`¥`)}}</text>
-				<numberScroll :num='payPrice' color="#E93323" width='30' height='50' fontSize='50'></numberScroll>
+				<numberScroll :num='payPriceShow' color="#E93323" width='30' height='50' fontSize='50'></numberScroll>
 			</view>
 			<view class="count-down">
 				{{$t(`支付剩余时间`)}}:
@@ -94,7 +94,10 @@
 				orderId: 0,
 				fromType: '',
 				active: 0,
-				payPrice: 0,
+				payPrice: 0,
+				payPriceShow: 0,
+				payPostage: 0,
+				offlinePostage: false,
 				invalidTime: 0,
 				initIn: false,
 				jumpData: {
@@ -140,7 +143,7 @@
 						title: this.$t(`取消支付`)
 					}, {
 						tab: 5,
-						url: `/pages/goods/order_pay_status/index?order_id=${this.orderId}&msg=${this.$t(`取消支付`)}&type=3&totalPrice=${this.payPrice}&status=2`
+						url: `/pages/goods/order_pay_status/index?order_id=${this.orderId}&msg=${this.$t(`取消支付`)}&type=3&totalPrice=${this.payPriceShow}&status=2`
 					});
 				} else {
 					if (extraData.code == 'success') {
@@ -149,7 +152,7 @@
 							icon: 'success'
 						}, {
 							tab: 5,
-							url: `/pages/goods/order_pay_status/index?order_id=${this.orderId}&msg=${this.jumpData.msg}&type=3&totalPrice=${this.payPrice}`
+							url: `/pages/goods/order_pay_status/index?order_id=${this.orderId}&msg=${this.jumpData.msg}&type=3&totalPrice=${this.payPriceShow}`
 						});
 					} else if (extraData.code == 'cancel') {
 						// "支付已取消";
@@ -157,12 +160,12 @@
 							title: this.$t(`取消支付`)
 						}, {
 							tab: 5,
-							url: `/pages/goods/order_pay_status/index?order_id=${this.orderId}&msg=${this.$t(`取消支付`)}&type=3&totalPrice=${this.payPrice}&status=2`
+							url: `/pages/goods/order_pay_status/index?order_id=${this.orderId}&msg=${this.$t(`取消支付`)}&type=3&totalPrice=${this.payPriceShow}&status=2`
 						});
 					} else {
 						// "支付失败:" + extraData.errmsg;
 						uni.reLaunch({
-							url: `/pages/goods/order_pay_status/index?order_id=${this.orderId}&msg=${this.$t(`支付失败`)}&totalPrice=${this.payPrice}`
+							url: `/pages/goods/order_pay_status/index?order_id=${this.orderId}&msg=${this.$t(`支付失败`)}&totalPrice=${this.payPriceShow}`
 						})
 					}
 				}
@@ -175,7 +178,9 @@
 				});
 				getCashierOrder(this.orderId, this.fromType).then(res => {
 					console.log(res)
-					this.payPrice = res.data.pay_price
+					this.payPrice = this.payPriceShow = res.data.pay_price
+					this.payPostage = res.data.pay_postage
+					this.offlinePostage = res.data.offline_postage
 					this.invalidTime = res.data.invalid_time
 					//微信支付是否开启
 					this.cartArr[0].payStatus = res.data.wechat_pay_status || 0
@@ -207,6 +212,14 @@
 				this.active = index;
 				this.paytype = paytype;
 				this.number = number;
+				if (this.offlinePostage) {
+					if (paytype == 'offline') {
+						this.payPriceShow = this.$util.$h.Sub(this.payPrice, this.payPostage);
+					} else {
+						this.payPriceShow = this.payPrice;
+					}
+
+				}
 			},
 			formpost(url, postData) {
 				let tempform = document.createElement("form");
@@ -228,7 +241,7 @@
 			waitPay() {
 				uni.reLaunch({
 					url: '/pages/goods/order_pay_status/index?order_id=' + this.orderId + '&msg=取消支付&type=3' +
-						'&status=2&totalPrice=' + this.payPrice
+						'&status=2&totalPrice=' + this.payPriceShow
 				})
 			},
 			goPay(number, paytype) {
@@ -236,7 +249,7 @@
 				if (!that.orderId) return that.$util.Tips({
 					title: that.$t(`请选择要支付的订单`)
 				});
-				if (paytype == 'yue' && parseFloat(number) < parseFloat(that.payPrice)) return that.$util.Tips({
+				if (paytype == 'yue' && parseFloat(number) < parseFloat(that.payPriceShow)) return that.$util.Tips({
 					title: that.$t(`余额不足`)
 				});
 				uni.showLoading({
@@ -272,7 +285,7 @@
 						goPages = '/pages/goods/order_pay_status/index?order_id=' + this.orderId + '&msg=' +
 						res
 						.msg +
-						'&type=3' + '&totalPrice=' + this.payPrice,
+						'&type=3' + '&totalPrice=' + this.payPriceShow,
 						friendPay = '/pages/users/payment_on_behalf/index?order_id=' + this.orderId +
 						'&spread=' +
 						this

+ 1 - 4
template/uni-app/pages/goods/order_confirm/index.vue

@@ -342,7 +342,7 @@
 				],
 				virtual_type: 0,
 				formContent: '',
-				payType: 'weixin', //支付方式
+				payType: '', //支付方式
 				openType: 1, //优惠券打开方式 1=使用
 				active: 0, //支付方式切换
 				coupon: {
@@ -1284,9 +1284,6 @@
 				let that = this,
 					data = {};
 
-				if (!that.payType) return that.$util.Tips({
-					title: that.$t(`请选择支付方式`)
-				});
 				if (!that.addressId && !that.shippingType && !that.virtual_type) return that.$util.Tips({
 					title: that.$t(`请选择收货地址`)
 				});