wesmiler 2 سال پیش
والد
کامیت
1e00742116
1فایلهای تغییر یافته به همراه10 افزوده شده و 3 حذف شده
  1. 10 3
      app/Services/Api/GoodsService.php

+ 10 - 3
app/Services/Api/GoodsService.php

@@ -332,11 +332,18 @@ class GoodsService extends BaseService
         if ($goods) {
             RedisService::set($cacheKey . '_page', $page, rand(300, 600));
             RedisService::set($cacheKey, $goods, rand(5, 10));
-            $this->model->insertAll($goods);
+            DB::beginTransaction();
+            try {
+                $this->model->insertAll($goods);
+                if($skus){
+                    GoodsSkuModel::insert($skus);
+                }
 
-            if($skus){
-                GoodsSkuModel::insert($skus);
+                DB::commit();
+            }catch (\Exception $exception){
+                DB::rollBack();
             }
+
         }