|
...
|
...
|
@@ -26,6 +26,9 @@ class ProductLogic extends BaseLogic |
|
|
|
$this->model = new Product();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存产品
|
|
|
|
* @name :productSave
|
|
...
|
...
|
@@ -34,9 +37,10 @@ class ProductLogic extends BaseLogic |
|
|
|
* @time :2023/8/21 18:35
|
|
|
|
*/
|
|
|
|
public function productSave(){
|
|
|
|
$category_ids = $this->param['category_id'] ?? [];
|
|
|
|
//参数处理
|
|
|
|
$this->param = $this->handleSaveParam($this->param);
|
|
|
|
DB::beginTransaction();
|
|
|
|
DB::connection('custom_mysql')->beginTransaction();
|
|
|
|
try {
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
//查看路由是否更新
|
|
...
|
...
|
@@ -51,9 +55,12 @@ class ProductLogic extends BaseLogic |
|
|
|
//路由映射
|
|
|
|
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
|
|
|
|
$this->model->edit(['route'=>$route],['id'=>$id]);
|
|
|
|
DB::commit();
|
|
|
|
//产品分类关联
|
|
|
|
CategoryRelated::saveRelated($id, $category_ids);
|
|
|
|
|
|
|
|
DB::connection('custom_mysql')->commit();
|
|
|
|
}catch (\Exception $e){
|
|
|
|
DB::rollBack();
|
|
|
|
DB::connection('custom_mysql')->rollBack();
|
|
|
|
$this->fail('系统错误请联系管理员');
|
|
|
|
}
|
|
|
|
//通知更新
|
|
...
|
...
|
@@ -128,7 +135,7 @@ class ProductLogic extends BaseLogic |
|
|
|
* @time :2023/8/21 17:11
|
|
|
|
*/
|
|
|
|
public function productDelete(){
|
|
|
|
DB::beginTransaction();
|
|
|
|
DB::connection('custom_mysql')->beginTransaction();
|
|
|
|
try {
|
|
|
|
foreach ($this->param['ids'] as $id) {
|
|
|
|
$info = $this->model->read(['id'=>$id],['id','status']);
|
|
...
|
...
|
@@ -142,9 +149,9 @@ class ProductLogic extends BaseLogic |
|
|
|
$this->model->edit(['status'=>Product::STATUS_RECYCLE],['id'=>$id]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DB::commit();
|
|
|
|
DB::connection('custom_mysql')->commit();
|
|
|
|
}catch (\Exception $e){
|
|
|
|
DB::rollBack();
|
|
|
|
DB::connection('custom_mysql')->rollBack();
|
|
|
|
$this->fail('删除失败');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
...
|
...
|
@@ -334,7 +341,7 @@ class ProductLogic extends BaseLogic |
|
|
|
* @time :2023/8/15 17:53
|
|
|
|
*/
|
|
|
|
public function batchSetCategory(){
|
|
|
|
DB::beginTransaction();
|
|
|
|
DB::connection('custom_mysql')->beginTransaction();
|
|
|
|
try {
|
|
|
|
//批量
|
|
|
|
$param = [
|
|
...
|
...
|
@@ -342,10 +349,16 @@ class ProductLogic extends BaseLogic |
|
|
|
'status'=>$this->param['status']
|
|
|
|
];
|
|
|
|
$this->model->edit($param,['id'=>['in',$this->param['id']]]);
|
|
|
|
DB::commit();
|
|
|
|
|
|
|
|
//分类关联
|
|
|
|
foreach ($this->param['id'] as $id){
|
|
|
|
CategoryRelated::saveRelated($id, $this->param['category_id']);
|
|
|
|
}
|
|
|
|
|
|
|
|
DB::connection('custom_mysql')->commit();
|
|
|
|
//对应添加关联表
|
|
|
|
}catch (\Exception $e){
|
|
|
|
DB::rollBack();
|
|
|
|
DB::connection('custom_mysql')->rollBack();
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
}
|
|
|
|
return $this->success();
|
...
|
...
|
|