|
...
|
...
|
@@ -7,6 +7,7 @@ use App\Helper\Common; |
|
|
|
use App\Http\Logic\Bside\BaseLogic;
|
|
|
|
use App\Models\Product\Category;
|
|
|
|
use App\Models\Product\CategoryRelated;
|
|
|
|
use App\Models\Product\ExtendInfo;
|
|
|
|
use App\Models\Product\Keyword;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
...
|
...
|
@@ -37,6 +38,12 @@ class ProductLogic extends BaseLogic |
|
|
|
* @time :2023/8/21 18:35
|
|
|
|
*/
|
|
|
|
public function productSave(){
|
|
|
|
//扩展字段
|
|
|
|
$extend = [];
|
|
|
|
if(!empty($this->param['extend'])){
|
|
|
|
$extend = $this->param['extend'];
|
|
|
|
unset($this->param['extend']);
|
|
|
|
}
|
|
|
|
$this->param = $this->handleSaveParam($this->param);
|
|
|
|
//单独处理分类
|
|
|
|
$category_ids = [];
|
|
...
|
...
|
@@ -52,16 +59,15 @@ class ProductLogic extends BaseLogic |
|
|
|
$this->param['route'] = $this->editProductRoute($this->param['route']);
|
|
|
|
$this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
}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'];
|
|
|
|
$this->param['route'] = $this->param['route'].'-'.RouteMap::SOURCE_PRODUCT;
|
|
|
|
$this->param = $this->addHandleParam($this->param);
|
|
|
|
$id = $this->model->addReturnId($this->param);
|
|
|
|
}
|
|
|
|
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
|
|
|
|
$this->model->edit(['route'=>$route],['id'=>$id]);
|
|
|
|
//产品分类关联
|
|
|
|
CategoryRelated::saveRelated($id, $category_ids);
|
|
|
|
//保存扩展字段
|
|
|
|
$this->saveExtendInfo($id,$extend);
|
|
|
|
DB::connection('custom_mysql')->commit();
|
|
|
|
}catch (\Exception $e){
|
|
|
|
DB::connection('custom_mysql')->rollBack();
|
|
...
|
...
|
@@ -73,6 +79,43 @@ class ProductLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :新增时处理字段
|
|
|
|
* @name :addHandleParam
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/9 14:48
|
|
|
|
*/
|
|
|
|
public function addHandleParam($param){
|
|
|
|
$param['project_id'] = $this->user['project_id'];
|
|
|
|
$param['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
$param['updated_at'] = $param['created_at'];
|
|
|
|
$this->param['route'] = $this->param['route'].'-'.RouteMap::SOURCE_PRODUCT;
|
|
|
|
return $param;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存扩展字段
|
|
|
|
* @name :saveExtend
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/9 15:02
|
|
|
|
*/
|
|
|
|
public function saveExtendInfo($id,$extend){
|
|
|
|
//先删除以前的数据
|
|
|
|
$extendInfoModel = new ExtendInfo();
|
|
|
|
$extendInfoModel->del(['project_id'=>$id]);
|
|
|
|
if(!empty($extend)){
|
|
|
|
foreach ($extend as $v){
|
|
|
|
$v['project_id'] = $this->user['project_id'];
|
|
|
|
$v['product_id'] = $id;
|
|
|
|
$extendInfoModel->add($v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :编辑列表数据
|
|
|
|
* @name :editList
|
|
|
|
* @author :lyh
|
...
|
...
|
|