|
...
|
...
|
@@ -47,13 +47,15 @@ class ProductLogic extends BaseLogic |
|
|
|
DB::connection('custom_mysql')->beginTransaction();
|
|
|
|
try {
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$id = $this->param['id'];
|
|
|
|
//查看路由是否更新
|
|
|
|
$id = $this->editProductRoute($this->param['id'],$this->param['route']);
|
|
|
|
$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;
|
|
|
|
$id = $this->model->addReturnId($this->param);
|
|
|
|
}
|
|
|
|
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
|
|
...
|
...
|
@@ -204,7 +206,7 @@ class ProductLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/7 10:02
|
|
|
|
*/
|
|
|
|
public function editProductRoute($id,$route){
|
|
|
|
public function editProductRoute($route){
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
if($info['route'] != $route){
|
|
|
|
//生成一条删除路由记录
|
|
...
|
...
|
@@ -213,8 +215,12 @@ class ProductLogic extends BaseLogic |
|
|
|
'route'=>$route,
|
|
|
|
];
|
|
|
|
$this->setRouteDeleteSave($data);
|
|
|
|
//"字符串以\"-product\"结尾"
|
|
|
|
if (!endsWith($route, "-product")) {
|
|
|
|
$route = $route."-product";
|
|
|
|
}
|
|
|
|
return $id;
|
|
|
|
}
|
|
|
|
return $route;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -431,17 +437,20 @@ class ProductLogic extends BaseLogic |
|
|
|
* @time :2023/8/15 17:53
|
|
|
|
*/
|
|
|
|
public function batchSetCategory(){
|
|
|
|
if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
|
|
|
|
DB::connection('custom_mysql')->beginTransaction();
|
|
|
|
$category_ids = $this->getLastCategoryArr($this->param['category_id']);
|
|
|
|
$this->param['category_id'] = ','.implode(',',$category_ids).',';
|
|
|
|
try {
|
|
|
|
//批量
|
|
|
|
$param = [
|
|
|
|
'category_id'=>','.Arr::arrToSet($this->param['category_id']).',',
|
|
|
|
'category_id'=>$this->param['category_id'],
|
|
|
|
'status'=>$this->param['status']
|
|
|
|
];
|
|
|
|
$this->model->edit($param,['id'=>['in',$this->param['id']]]);
|
|
|
|
//分类关联
|
|
|
|
foreach ($this->param['id'] as $id){
|
|
|
|
CategoryRelated::saveRelated($id, $this->param['category_id']);
|
|
|
|
CategoryRelated::saveRelated($id, $category_ids);
|
|
|
|
}
|
|
|
|
DB::connection('custom_mysql')->commit();
|
|
|
|
//对应添加关联表
|
|
...
|
...
|
@@ -449,6 +458,7 @@ class ProductLogic extends BaseLogic |
|
|
|
DB::connection('custom_mysql')->rollBack();
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|