|
...
|
...
|
@@ -274,4 +274,38 @@ class ProductLogic extends BaseLogic |
|
|
|
}
|
|
|
|
return $rs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :批量设置产品分类及状态
|
|
|
|
* @name :batchSetCategory
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/15 17:53
|
|
|
|
*/
|
|
|
|
public function batchSetCategory(){
|
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
//删除分类关联表记录
|
|
|
|
$categoryRelatedModel = new CategoryRelated();
|
|
|
|
$categoryRelatedModel->del(['product_id'=>['in',$this->param['id']]]);
|
|
|
|
//批量
|
|
|
|
$param = [
|
|
|
|
'category_id'=>Arr::arrToSet($this->param['category_id']),
|
|
|
|
'status'=>$this->param['status']
|
|
|
|
];
|
|
|
|
$this->model->edit($param,['id'=>['in',$this->param['id']]]);
|
|
|
|
//新增关联分类
|
|
|
|
foreach ($this->param['id'] as $v1){
|
|
|
|
foreach ($this->param['category_id'] as $v2){
|
|
|
|
CategoryRelated::saveRelated($v1,$v2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DB::commit();
|
|
|
|
//对应添加关联表
|
|
|
|
}catch (\Exception $e){
|
|
|
|
DB::rollBack();
|
|
|
|
$this->fail('error');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|