From b8cc587c63ceaff4ffb857eac3d42d560fe9ae1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=BB=BA=E7=82=8A?= <924182103@qq.com> Date: Wed, 13 Nov 2024 10:38:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Goods/GoodsCombinationController.php | 5 +---- app/Http/Controllers/Goods/GoodsSkusController.php | 12 ++++-------- app/Imports/SaleStockImport.php | 7 ++++--- app/Listeners/BatchStockUpdateListener.php | 2 +- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/Goods/GoodsCombinationController.php b/app/Http/Controllers/Goods/GoodsCombinationController.php index 0af6eaa..553a14b 100644 --- a/app/Http/Controllers/Goods/GoodsCombinationController.php +++ b/app/Http/Controllers/Goods/GoodsCombinationController.php @@ -34,11 +34,8 @@ class GoodsCombinationController extends Controller $orderRestTime = DeveloperConfig::query() ->where('key', DeveloperConfig::$ORDER_RESET_TIME) ->value('value'); - $time = date('Y-m-d 07:00:00'); if (is_null($orderRestTime)) { - $orderRestTime = $time; - } else { - $orderRestTime = Carbon::parse($orderRestTime)->lt(Carbon::parse($time)) ? $time : $orderRestTime; + $orderRestTime = date('Y-m-d 07:00:00'); } $businessOrderItems = BusinessOrderItem::query() diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index 5e8bd47..3c7bf4e 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -59,11 +59,8 @@ class GoodsSkusController extends Controller $orderRestTime = DeveloperConfig::query() ->where('key', DeveloperConfig::$ORDER_RESET_TIME) ->value('value'); - $time = date('Y-m-d 07:00:00'); if (is_null($orderRestTime)) { - $orderRestTime = $time; - } else { - $orderRestTime = Carbon::parse($orderRestTime)->lt(Carbon::parse($time)) ? $time : $orderRestTime; + $orderRestTime = date('Y-m-d 07:00:00'); } $businessOrderItems = BusinessOrderItem::query() ->select(DB::raw($fields)) @@ -304,9 +301,6 @@ class GoodsSkusController extends Controller $log = new LogModel(); $log->batchInsert($logs); DB::commit(); - if (!empty($updateIds)) { - event(new BatchStockUpdateEvent($updateIds)); - } } catch (\Exception $exception) { DB::rollBack(); $this->res = [ @@ -315,7 +309,9 @@ class GoodsSkusController extends Controller 'errorMessage' => $exception->getMessage(), ]; } - + if (!empty($updateIds)) { + event(new BatchStockUpdateEvent($updateIds)); + } return response($this->res, $this->res['httpCode']); } diff --git a/app/Imports/SaleStockImport.php b/app/Imports/SaleStockImport.php index 30391ed..c59e33a 100644 --- a/app/Imports/SaleStockImport.php +++ b/app/Imports/SaleStockImport.php @@ -71,13 +71,14 @@ class SaleStockImport implements ToArray, SkipsEmptyRows $log = new LogModel(); $log->batchInsert($logs); DB::commit(); - if (!empty($updateIds)) { - event(new BatchStockUpdateEvent($updateIds)); - } + } catch (\Exception $exception) { DB::rollBack(); throw new Exception($exception->getMessage()); } + if (!empty($updateIds)) { + event(new BatchStockUpdateEvent($updateIds)); + } } } } diff --git a/app/Listeners/BatchStockUpdateListener.php b/app/Listeners/BatchStockUpdateListener.php index d18fb62..a101025 100644 --- a/app/Listeners/BatchStockUpdateListener.php +++ b/app/Listeners/BatchStockUpdateListener.php @@ -49,7 +49,7 @@ class BatchStockUpdateListener implements ShouldQueue ->where('external_sku_id', $goodsSku->external_sku_id) ->get(); BusinessFactory::init()->make($shop['plat_id'])->setShopWithId($shop['id'])->batchIncrQuantity($businessGoodsSkus->toArray(), $num, false); - usleep(140); + usleep(50); } } } catch (\Exception $exception) { From bf1d627e9d90158475685bb597946d98a6a6f221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=BB=BA=E7=82=8A?= <924182103@qq.com> Date: Wed, 13 Nov 2024 17:04:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Listeners/BatchStockUpdateListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Listeners/BatchStockUpdateListener.php b/app/Listeners/BatchStockUpdateListener.php index a101025..ef85305 100644 --- a/app/Listeners/BatchStockUpdateListener.php +++ b/app/Listeners/BatchStockUpdateListener.php @@ -49,7 +49,7 @@ class BatchStockUpdateListener implements ShouldQueue ->where('external_sku_id', $goodsSku->external_sku_id) ->get(); BusinessFactory::init()->make($shop['plat_id'])->setShopWithId($shop['id'])->batchIncrQuantity($businessGoodsSkus->toArray(), $num, false); - usleep(50); + usleep(100); } } } catch (\Exception $exception) {