From ef2e854fbea372d7aba3cb7cdc7bb9ae6000dd11 Mon Sep 17 00:00:00 2001 From: weigang Date: Tue, 10 Nov 2020 17:32:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E8=B4=AD=E7=A7=8D=E6=95=B0=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/v3/Implementations/GoodsActivityService.php | 3 ++- app/Service/v3/Implementations/OrderOnlineService.php | 6 +++--- app/Service/v3/Implementations/ShopCartUpdateService.php | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/Service/v3/Implementations/GoodsActivityService.php b/app/Service/v3/Implementations/GoodsActivityService.php index a0a46e2..c06c6b7 100644 --- a/app/Service/v3/Implementations/GoodsActivityService.php +++ b/app/Service/v3/Implementations/GoodsActivityService.php @@ -158,6 +158,7 @@ class GoodsActivityService implements GoodsActivityServiceInterface $sourceGoods = GoodsActivity::query() ->whereIn('id', $goodsIds) + ->orderByRaw('FIELD(`id`,'.implode(',', $goodsIds).')') ->get()->toArray(); // $redis = ApplicationContext::getContainer()->get(Redis::class); @@ -200,7 +201,7 @@ class GoodsActivityService implements GoodsActivityServiceInterface } if ($goods['type_limit'] != 0 && $buyNum[$goods['type_limit']] > $goods['type_limit']) { - return false; + return $sourceGoods[$key-1]['name']; } } diff --git a/app/Service/v3/Implementations/OrderOnlineService.php b/app/Service/v3/Implementations/OrderOnlineService.php index eb214c5..3a630e3 100644 --- a/app/Service/v3/Implementations/OrderOnlineService.php +++ b/app/Service/v3/Implementations/OrderOnlineService.php @@ -230,7 +230,7 @@ class OrderOnlineService implements OrderOnlineServiceInterface // 用户购物车数据 $cartIds = explode(',', $storeItem->cart_ids); $shopcartIds = array_merge($shopcartIds, $cartIds); - $carts = ShoppingCart::query()->whereIn('id', $cartIds)->where(['market_id' => $marketId, 'user_id' => $userId])->get(); + $carts = ShoppingCart::query()->whereIn('id', $cartIds)->where(['market_id' => $marketId, 'user_id' => $userId])->orderBy('updated_at ASC')->get(); foreach ($carts as $k => &$cart) { // 查个商品,做商品有效的判断检查 $goods = []; @@ -443,9 +443,9 @@ class OrderOnlineService implements OrderOnlineServiceInterface // 判断是否有购买多个特价商品 $check = $this->goodsActivityService->checkOrderActivityCount($activityGoodsIds); - if(!$check){ + if($check !== true){ $this->log->event(LogLabel::ORDER_ONLINE_LOG, ['msg' => '同一订单中有活动商品不可同时购买多款', 'data' => json_encode($dataOrderGoods)]); - throw new ErrorCodeException(ErrorCode::GOODS_ACTIVITY_RESTRICT_LIMIT); + throw new ErrorCodeException(ErrorCode::GOODS_ACTIVITY_RESTRICT_LIMIT, '[商品:' . $check . ']'); } // 订单成功,做一些处理 diff --git a/app/Service/v3/Implementations/ShopCartUpdateService.php b/app/Service/v3/Implementations/ShopCartUpdateService.php index 8b22179..8dd5872 100644 --- a/app/Service/v3/Implementations/ShopCartUpdateService.php +++ b/app/Service/v3/Implementations/ShopCartUpdateService.php @@ -50,8 +50,8 @@ class ShopCartUpdateService implements ShopCartUpdateServiceInterface ->pluck('goods_id')->toArray(); array_push($goodsArr,$goodsId); $checkGoodsActivity = $this->goodsActivityService->checkOrderActivityCount($goodsArr); - if(!$checkGoodsActivity){ - throw new ErrorCodeException(ErrorCode::GOODS_ACTIVITY_RESTRICT_LIMIT); + if($checkGoodsActivity !== true){ + throw new ErrorCodeException(ErrorCode::GOODS_ACTIVITY_RESTRICT_LIMIT, '[商品:' . $checkGoodsActivity . ']'); } $goodsCheck = $this->goodsActivityService->check($goods,$num,$userId); }else{