|
@@ -332,11 +332,18 @@ class GoodsService extends BaseService
|
|
|
if ($goods) {
|
|
if ($goods) {
|
|
|
RedisService::set($cacheKey . '_page', $page, rand(300, 600));
|
|
RedisService::set($cacheKey . '_page', $page, rand(300, 600));
|
|
|
RedisService::set($cacheKey, $goods, rand(5, 10));
|
|
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();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|