|
...
|
...
|
@@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\Product; |
|
|
|
|
|
|
|
use App\Helper\Arr;
|
|
|
|
use App\Http\Logic\Bside\BaseLogic;
|
|
|
|
use App\Models\Product\Category;
|
|
|
|
use App\Models\Product\CategoryRelated;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
...
|
...
|
@@ -26,9 +27,6 @@ class ProductLogic extends BaseLogic |
|
|
|
$this->model = new Product();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存产品
|
|
|
|
* @name :productSave
|
|
...
|
...
|
@@ -37,7 +35,7 @@ class ProductLogic extends BaseLogic |
|
|
|
* @time :2023/8/21 18:35
|
|
|
|
*/
|
|
|
|
public function productSave(){
|
|
|
|
$category_ids = $this->param['category_id'] ?? [];
|
|
|
|
// $category_ids = $this->param['category_id'] ?? [];
|
|
|
|
//参数处理
|
|
|
|
$this->param = $this->handleSaveParam($this->param);
|
|
|
|
DB::connection('custom_mysql')->beginTransaction();
|
|
...
|
...
|
@@ -56,8 +54,7 @@ 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]);
|
|
|
|
//产品分类关联
|
|
|
|
CategoryRelated::saveRelated($id, $category_ids);
|
|
|
|
|
|
|
|
// CategoryRelated::saveRelated($id, $category_ids);
|
|
|
|
DB::connection('custom_mysql')->commit();
|
|
|
|
}catch (\Exception $e){
|
|
|
|
DB::connection('custom_mysql')->rollBack();
|
|
...
|
...
|
@@ -88,7 +85,7 @@ class ProductLogic extends BaseLogic |
|
|
|
$param['attrs'] = Arr::a2s($param['attrs'] ?? '');
|
|
|
|
$param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? '');
|
|
|
|
if(isset($param['category_id']) && !empty($param['category_id'])){
|
|
|
|
$param['category_id'] = ','.Arr::arrToSet($param['category_id']).',';
|
|
|
|
$param['category_id'] = $this->getLastCategory($param['category_id']);
|
|
|
|
}
|
|
|
|
if(isset($param['keyword_id']) && !empty($param['keyword_id'])){
|
|
|
|
$param['keyword_id'] = ','.Arr::arrToSet($param['keyword_id']).',';
|
|
...
|
...
|
@@ -108,6 +105,25 @@ class ProductLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取最后一级分类id
|
|
|
|
* @name :getLastCategory
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/20 9:02
|
|
|
|
*/
|
|
|
|
public function getLastCategory($category){
|
|
|
|
$str = '';
|
|
|
|
$cateModel = new Category();
|
|
|
|
foreach ($category as $v){
|
|
|
|
$info = $cateModel->read(['pid'=>$v]);
|
|
|
|
if($info === false){
|
|
|
|
$str .= $v.',';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ','.$str;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :编辑产品
|
|
|
|
* @name :editProduct
|
|
|
|
* @author :lyh
|
...
|
...
|
|