|
...
|
...
|
@@ -33,20 +33,19 @@ class ProductLogic extends BaseLogic |
|
|
|
* @time :2023/8/21 18:35
|
|
|
|
*/
|
|
|
|
public function productSave(){
|
|
|
|
//参数处理
|
|
|
|
$this->param = $this->handleSaveParam($this->param);
|
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$id = $this->param['id'];
|
|
|
|
$this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
$id = $this->editProduct();
|
|
|
|
}else{
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$this->param['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
$this->param['updated_at'] = $this->param['created_at'];
|
|
|
|
$id = $this->model->insertGetId($this->param);
|
|
|
|
$id = $this->addProduct();
|
|
|
|
}
|
|
|
|
//路由映射
|
|
|
|
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
|
|
|
|
//更新路由
|
|
|
|
$this->model->edit(['route'=>$route],['id'=>$id]);
|
|
|
|
DB::commit();
|
|
|
|
}catch (\Exception $e){
|
|
|
|
DB::rollBack();
|
|
...
|
...
|
@@ -58,6 +57,43 @@ class ProductLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :新增产品
|
|
|
|
* @name :addProduct
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/7 10:01
|
|
|
|
*/
|
|
|
|
public function addProduct(){
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$this->param['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
$this->param['updated_at'] = $this->param['created_at'];
|
|
|
|
$id = $this->model->addReturnId($this->param);
|
|
|
|
return $id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :编辑产品
|
|
|
|
* @name :editProduct
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/7 10:02
|
|
|
|
*/
|
|
|
|
public function editProduct(){
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
if($info['route'] != $this->param['route']){
|
|
|
|
//生成一条删除路由记录
|
|
|
|
$data = [
|
|
|
|
'source'=>RouteMap::SOURCE_PRODUCT,
|
|
|
|
'route'=>$info['route'],
|
|
|
|
];
|
|
|
|
$this->setRouteDeleteSave($data);
|
|
|
|
}
|
|
|
|
$id = $this->param['id'];
|
|
|
|
$this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
return $id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :不使用save处理参数
|
|
|
|
* @name :handleSaveParam
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -91,6 +127,7 @@ class ProductLogic extends BaseLogic |
|
|
|
return $param;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :删除数据
|
|
|
|
* @name :delete
|
|
...
|
...
|
@@ -106,6 +143,12 @@ class ProductLogic extends BaseLogic |
|
|
|
if($info['status'] == Product::STATUS_RECYCLE){
|
|
|
|
//删除路由映射
|
|
|
|
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
|
|
|
|
//生成一条删除路由记录
|
|
|
|
$data = [
|
|
|
|
'source'=>RouteMap::SOURCE_PRODUCT,
|
|
|
|
'route'=>$info['route'],
|
|
|
|
];
|
|
|
|
$this->setRouteDeleteSave($data);
|
|
|
|
//删除当前产品模版
|
|
|
|
$this->delProductModule($id);
|
|
|
|
$this->model->del(['id'=>$id]);
|
...
|
...
|
|