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('采购、委托商品不支持跨店购买');