From 01cfd79803ef7b34de2d8538fb97d8c3bdd86fa5 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Thu, 7 Sep 2023 15:40:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=A7=94=E6=89=98=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/store/order/StoreCart.php | 2 +- .../order/StoreOrderCreateRepository.php | 34 ++++++++++++++----- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/app/common/model/store/order/StoreCart.php b/app/common/model/store/order/StoreCart.php index 58d9263b..1a2ae6bc 100644 --- a/app/common/model/store/order/StoreCart.php +++ b/app/common/model/store/order/StoreCart.php @@ -155,7 +155,7 @@ class StoreCart extends BaseModel 'activity_id' => $this->source_id, 'product_type' => $this->product_type, ]; - if ($this->product_type == 98) { + if ($this->product_type == 98 || $this->product_type == 99) { $where['product_id'] = $this->product_id; } } else { diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 3a242a8e..2dcbee92 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -97,11 +97,10 @@ class StoreOrderCreateRepository extends StoreOrderRepository } } } - if ($order_type == 98 && count($merchantCartList) > 1) { - throw new ValidateException('采购商品不支持跨店购买'); + if (($order_type == 98 || $order_type == 99) && count($merchantCartList) > 1) { + throw new ValidateException('采购、委托商品不支持跨店购买'); } $community = []; - // 99 委托商品是否设置收货方式 ? if ($order_type == 98) { $sourceIdArray = []; foreach($merchantCart['list'] as $prod){ @@ -120,6 +119,24 @@ class StoreOrderCreateRepository extends StoreOrderRepository } } } + if ($order_type == 99) { + $sourceIdArray = []; + foreach($merchantCart['list'] as $prod){ + if ($prod['source_id'] > 0) { + $sourceIdArray[] = $prod['source_id']; + } + } + if (count($sourceIdArray)) { + if (count(array_unique($sourceIdArray)) > 1) { + throw new ValidateException('委托商品数据异常'); + } + $community = Db::name('Community')->where('community_id', $sourceIdArray[0] ?? 0)->field('community_id, title, image')->fetchSql(false)->find(); + if ($community) { + $deliverMethod = Db::name('entrust')->where('community_id', $sourceIdArray[0] ?? 0)->value('deliver_method'); + $deliverMethodArray = explode(',', $deliverMethod); + } + } + } unset($merchantCart, $cart); $order_price = 0; $total_true_price = 0; @@ -141,7 +158,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository $order_svip_discount = 0; // 循环计算每个店铺的订单数据 委托商品是否设置收货方式 ? foreach ($merchantCartList as &$merchantCart) { - if ($order_type == 98 && !empty($deliverMethodArray)) { + if (($order_type == 98 || $order_type == 99) && !empty($deliverMethodArray)) { $merchantCart['delivery_way'] = $deliverMethodArray; } $postageRule = []; @@ -173,8 +190,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository $product_cart = []; foreach ($merchantCart['list'] as $k => $cart) { - //处理转售送货方式 委托商品是否设置收货方式 ? - if ($order_type == 98) { + if ($order_type == 98 || $order_type == 99) { $merchantCart['list'][$k]['product']['delivery_way'] = $cart['product']['delivery_way'] = $deliverMethod ?? ''; } //获取订单类型, 活动商品单次只能购买一个 @@ -962,7 +978,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository if ($orderType == 0 && $pay_type == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) { throw new ValidateException('该商品不支持先货后款'); } - if (!in_array($orderType, [0, 98]) && (count($orderInfo['order']) > 1 || ($orderType != 10 && count($orderInfo['order'][0]['list']) > 1))) { + if (!in_array($orderType, [0, 98, 99]) && (count($orderInfo['order']) > 1 || ($orderType != 10 && count($orderInfo['order'][0]['list']) > 1))) { throw new ValidateException('活动商品请单独购买'); } @@ -987,8 +1003,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository } } } - if ($orderType == 98 && count($merchantCartList) > 1) { - throw new ValidateException('采购商品不支持跨店购买'); + if (($orderType == 98 || $orderType == 99) && count($merchantCartList) > 1) { + throw new ValidateException('采购、委托商品不支持跨店购买'); } if ($hasTake) { app()->make(UserAddressValidate::class)->scene('take')->check($post);