From 76e9db8b4e9f5af0e59ec734ac127f2e98ad0d44 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Wed, 24 Jan 2024 11:19:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=9C=B0=E5=8C=BA=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=92=8C=E5=95=86=E5=93=81=E9=99=90=E8=B4=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/store/CityAreaDao.php | 6 ++--- .../order/StoreOrderCreateRepository.php | 26 ++++++------------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/app/common/dao/store/CityAreaDao.php b/app/common/dao/store/CityAreaDao.php index 0e439da0..a08bb0cd 100644 --- a/app/common/dao/store/CityAreaDao.php +++ b/app/common/dao/store/CityAreaDao.php @@ -107,13 +107,13 @@ class CityAreaDao extends BaseDao */ public function getLngAndLat($location, $streetCode) { - if (!empty($location) && $location != ',') { - [$lat, $lng] = explode(',', $location); - } elseif (!empty($streetCode)) { + if (!empty($streetCode)) { $location = GeoStreet::where('street_code', $streetCode)->field('lng,lat')->find(); if (!empty($location)) { [$lat, $lng] = [$location['lat'], $location['lng']]; } + } elseif (!empty($location) && $location != ',') { + [$lat, $lng] = explode(',', $location); } if (empty($lat) || empty($lng)) { [$lat, $lng] = ['28.889137', '105.443352']; diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 1d0bf2a6..9918bb85 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -102,23 +102,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository $order_type = $cart['product_type']; } $source = $cart['source']; - $canBuy = (new StoreActivityDao())->canBuy($cart['uid'], $cart['product_id']); - if ($canBuy['is_true']==false) { - throw new ValidateException('活动商品限购1个'); - } - if ($canBuy['activityId']== 2) { - $activityProductCount += $cart['cart_num']; - if ($activityProductCount > 1){ - throw new ValidateException('活动商品限购1个'); - } - } - $oldProductId = $cart->product->old_product_id ?? 0; - if (in_array($oldProductId, [1, 2, 3])) { - $oldProductStock = Db::name('store_product')->where('product_id', $oldProductId)->value('stock'); - if ($oldProductStock < $cart['cart_num']) { - throw new ValidateException('商品库存不足'); - } - if ($source == 103) { + if ($source == 105) { $canBuy = (new StoreActivityDao())->canBuy($cart['uid'], $cart['product_id']); if ($canBuy['is_true'] == false) { throw new ValidateException('活动商品限购1个'); @@ -130,6 +114,13 @@ class StoreOrderCreateRepository extends StoreOrderRepository } } } + $oldProductId = $cart->product->old_product_id ?? 0; + if (in_array($oldProductId, [1, 2, 3])) { + $oldProductStock = Db::name('store_product')->where('product_id', $oldProductId)->value('stock'); + if ($oldProductStock < $cart['cart_num']) { + throw new ValidateException('商品库存不足'); + } + } if ($cart['product_type'] <= 97 && $cart['product_type'] > 0 && (($cart['product_type'] != 10 && count($merchantCart['list']) != 1) || count($merchantCartList) != 1)) { throw new ValidateException('活动商品必须单独购买'); } @@ -153,7 +144,6 @@ class StoreOrderCreateRepository extends StoreOrderRepository } } } - } } // if (($order_type == 98 || $order_type == 99) && count($merchantCartList) > 1) { // throw new ValidateException('采购、委托商品不支持跨店购买');