|
...
|
...
|
@@ -38,21 +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);
|
|
|
|
//处理扩展字段
|
|
|
|
$extend = $this->handleExtent();
|
|
|
|
//单独处理分类
|
|
|
|
$category_ids = [];
|
|
|
|
if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
|
|
|
|
$category_ids = $this->getLastCategoryArr($this->param['category_id']);
|
|
|
|
$this->param['category_id'] = ','.implode(',',$category_ids).',';
|
|
|
|
}else{
|
|
|
|
$this->param['category_id'] = '';
|
|
|
|
}
|
|
|
|
$category_ids = $this->handleCategory();
|
|
|
|
//处理其他字段
|
|
|
|
$this->param = $this->handleSaveParam($this->param);
|
|
|
|
DB::connection('custom_mysql')->beginTransaction();
|
|
|
|
try {
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
...
|
...
|
@@ -81,6 +72,40 @@ class ProductLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :处理扩展字段
|
|
|
|
* @name :handleExtent
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/6 15:06
|
|
|
|
*/
|
|
|
|
public function handleExtent(){
|
|
|
|
//扩展字段
|
|
|
|
$extend = [];
|
|
|
|
if(!empty($this->param['extend'])){
|
|
|
|
$extend = $this->param['extend'];
|
|
|
|
unset($this->param['extend']);
|
|
|
|
}
|
|
|
|
return $extend;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :处理分类数据
|
|
|
|
* @name :handleCategory
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/6 15:01
|
|
|
|
*/
|
|
|
|
public function handleCategory(){
|
|
|
|
$category_ids = [];
|
|
|
|
if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
|
|
|
|
$category_ids = $this->getLastCategoryArr($this->param['category_id']);
|
|
|
|
$this->param['category_id'] = ','.implode(',',$category_ids).',';
|
|
|
|
}else{
|
|
|
|
$this->param['category_id'] = '';
|
|
|
|
}
|
|
|
|
return $category_ids;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @remark :新增时处理字段
|
|
|
|
* @name :addHandleParam
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -112,27 +137,38 @@ class ProductLogic extends BaseLogic |
|
|
|
if(empty($v['values'])){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
unset($v['title']);
|
|
|
|
if($v['type'] == 3){
|
|
|
|
foreach ($v['values'] as $k1=>$v1){
|
|
|
|
$v1['url'] = str_replace_url($v1['url']);
|
|
|
|
$v['values'][$k1] = $v1;
|
|
|
|
}
|
|
|
|
$v['values'] = json_encode($v['values']);
|
|
|
|
}elseif ($v['type'] == 4){
|
|
|
|
foreach ($v['values'] as $k1=>$v1){
|
|
|
|
$v1 = str_replace_url($v1);
|
|
|
|
$v['values'][$k1] = $v1;
|
|
|
|
}
|
|
|
|
$v['values'] = json_encode($v['values']);
|
|
|
|
}
|
|
|
|
$v['project_id'] = $this->user['project_id'];
|
|
|
|
$v['product_id'] = $product_id;
|
|
|
|
$v = $this->saveHandleExtend($v,$product_id);
|
|
|
|
$extendInfoModel->add($v);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存扩展字段时处理数据
|
|
|
|
* @name :saveHandleExtend
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/6 15:11
|
|
|
|
*/
|
|
|
|
public function saveHandleExtend(&$v,$product_id){
|
|
|
|
unset($v['title']);
|
|
|
|
if($v['type'] == 3){
|
|
|
|
foreach ($v['values'] as $k1=>$v1){
|
|
|
|
$v1['url'] = str_replace_url($v1['url']);
|
|
|
|
$v['values'][$k1] = $v1;
|
|
|
|
}
|
|
|
|
$v['values'] = json_encode($v['values']);
|
|
|
|
}elseif ($v['type'] == 4){
|
|
|
|
foreach ($v['values'] as $k1=>$v1){
|
|
|
|
$v1 = str_replace_url($v1);
|
|
|
|
$v['values'][$k1] = $v1;
|
|
|
|
}
|
|
|
|
$v['values'] = json_encode($v['values']);
|
|
|
|
}
|
|
|
|
$v['project_id'] = $this->user['project_id'];
|
|
|
|
$v['product_id'] = $product_id;
|
|
|
|
return $this->success($v);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :编辑列表数据
|
...
|
...
|
|