|
@@ -69,17 +69,19 @@ class CmsSubjectRepository {
|
|
throw new HttpException(500, '请检查商品与排序数目是否对应');
|
|
throw new HttpException(500, '请检查商品与排序数目是否对应');
|
|
}
|
|
}
|
|
|
|
|
|
- $subject_product = new CmsSubjectProduct();
|
|
|
|
|
|
+ $resert_data = [];
|
|
for ($i = 0;$i < $product_num;$i++){
|
|
for ($i = 0;$i < $product_num;$i++){
|
|
- $resert_data =[
|
|
|
|
|
|
+ $resert_data[] =[
|
|
'product_id' => $products[$i],
|
|
'product_id' => $products[$i],
|
|
'sort' => $sort[$i],
|
|
'sort' => $sort[$i],
|
|
'subject_id' => $res['id'],
|
|
'subject_id' => $res['id'],
|
|
'created_at' => $date,
|
|
'created_at' => $date,
|
|
'updated_at' => $date,
|
|
'updated_at' => $date,
|
|
];
|
|
];
|
|
- $subject_product->insert($resert_data);
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+ $result = $this->cmsSubjectProduct->insert($resert_data);
|
|
|
|
+ if (!$result){
|
|
|
|
+ throw new HttpException(500, '专题商品添加失败');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
DB::commit();
|
|
DB::commit();
|
|
@@ -124,16 +126,19 @@ class CmsSubjectRepository {
|
|
throw new HttpException(500, '请检查商品与排序数目是否对应');
|
|
throw new HttpException(500, '请检查商品与排序数目是否对应');
|
|
}
|
|
}
|
|
|
|
|
|
- $subject_product = new CmsSubjectProduct();
|
|
|
|
- for ($i = 0; $i < $product_num; $i++) {
|
|
|
|
- $resert_data = [
|
|
|
|
|
|
+ $update_data = [];
|
|
|
|
+ for ($i = 0;$i < $product_num;$i++){
|
|
|
|
+ $update_data[] =[
|
|
'product_id' => $products[$i],
|
|
'product_id' => $products[$i],
|
|
'sort' => $sort[$i],
|
|
'sort' => $sort[$i],
|
|
'subject_id' => $subject->id,
|
|
'subject_id' => $subject->id,
|
|
'created_at' => $date,
|
|
'created_at' => $date,
|
|
'updated_at' => $date,
|
|
'updated_at' => $date,
|
|
];
|
|
];
|
|
- $subject_product->insert($resert_data);
|
|
|
|
|
|
+ }
|
|
|
|
+ $result = $this->cmsSubjectProduct->insert($update_data);
|
|
|
|
+ if (!$result){
|
|
|
|
+ throw new HttpException(500, '专题商品添加失败');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
DB::commit();
|
|
DB::commit();
|