|
...
|
...
|
@@ -42,9 +42,7 @@ class KeywordLogic extends BaseLogic |
|
|
|
if($info !== false){
|
|
|
|
$info['url'] = $this->user['domain'] . $info['route'];
|
|
|
|
$info['related_news_info'] = News::whereIn('id', $info['related_news_ids'])->select(['id', 'name'])->get();
|
|
|
|
$product = $this->getProduct($info['id']);
|
|
|
|
$info['product_list'] = $product['product'] ?? [];
|
|
|
|
$info['product_video_list'] = $product['video_product'] ?? [];
|
|
|
|
$info['product_list'] = $this->getProduct($info['id']);
|
|
|
|
}
|
|
|
|
return $this->success($info);
|
|
|
|
}
|
|
...
|
...
|
@@ -85,9 +83,6 @@ class KeywordLogic extends BaseLogic |
|
|
|
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
|
|
|
|
$this->model->edit(['route'=>$route],['id'=>$id]);
|
|
|
|
$data = ['id'=>$id];
|
|
|
|
if(isset($this->param['keyword_arr']) && isset($this->param['keyword_video_arr'])){
|
|
|
|
$this->delRelated($id,$this->param['keyword_arr'],$this->param['keyword_video_arr']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Common::del_user_cache('product_keyword',$this->user['project_id']);
|
|
|
|
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_KEYWORD,$route);
|
|
...
|
...
|
@@ -313,27 +308,14 @@ class KeywordLogic extends BaseLogic |
|
|
|
* @time :2024/11/28 9:26
|
|
|
|
*/
|
|
|
|
public function getProduct($keyword_id){
|
|
|
|
$data_video_type_arr = $data_type_arr = [];
|
|
|
|
$productList = [];
|
|
|
|
$keywordRelatedModel = new KeywordRelated();
|
|
|
|
$keywordRelateList = $keywordRelatedModel->list(['keyword_id'=>$keyword_id],'id',['id','product_id','type']);
|
|
|
|
if(!empty($keywordRelateList)){
|
|
|
|
foreach ($keywordRelateList as $val){
|
|
|
|
if($val['type'] == 1){
|
|
|
|
$data_type_arr[] = $val['product_id'];
|
|
|
|
}else{
|
|
|
|
$data_video_type_arr[] = $val['product_id'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$productVideoList = $productList = [];
|
|
|
|
$productModel = new Product();
|
|
|
|
if(!empty($data_type_arr)){
|
|
|
|
$productList = $productModel->list(['id'=>['in',$data_type_arr]],'id',['id','title']);
|
|
|
|
}
|
|
|
|
if(!empty($data_video_type_arr)){
|
|
|
|
$productVideoList = $productModel->list(['id'=>['in',$data_video_type_arr]],'id',['id','title']);
|
|
|
|
$productIdArr = $keywordRelatedModel->selectField(['keyword_id'=>$keyword_id],'product_id');
|
|
|
|
if(!empty($productIdArr)){
|
|
|
|
$productModel = new Product();
|
|
|
|
$productList = $productModel->list(['id'=>['in',$productIdArr]],['id','title']);
|
|
|
|
}
|
|
|
|
return $this->success(['product'=>$productList,'video_product'=>$productVideoList]);
|
|
|
|
return $this->success($productList);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -343,12 +325,15 @@ class KeywordLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2024/11/28 9:46
|
|
|
|
*/
|
|
|
|
public function delRelated($product_id,$keyword_arr = [],$keyword_video_arr = []){
|
|
|
|
public function delRelated($keyword_id,$product_id){
|
|
|
|
$productModel = new Product();
|
|
|
|
$keyword_str = !empty($keyword_arr) ? ','.implode(',',$keyword_arr).',' : '';
|
|
|
|
KeywordRelated::saveRelated($product_id,$keyword_arr);
|
|
|
|
KeywordRelated::saveRelated($product_id,$keyword_video_arr,2);
|
|
|
|
$keyword_video_str = !empty($keyword_video_arr) ? ','.implode(',',$keyword_arr).',' : '';
|
|
|
|
$productModel->edit(['keyword_id'=>$keyword_str,'keyword_video_id'=>$keyword_video_str],['id'=>$product_id]);
|
|
|
|
$productModel->where('id', $product_id)
|
|
|
|
->update(['keyword_id' => DB::raw("REPLACE(keyword_id, ',$keyword_id,' , ',')"),'keyword_video_id' => DB::raw("REPLACE(keyword_video_id, ',$keyword_id,' , ',')")]);
|
|
|
|
$productModel->where('id', $product_id)->where('keyword_id',',')->orWhere('keyword_video_id',',')
|
|
|
|
->update(['keyword_id' => DB::raw("REPLACE(keyword_id, ',' , '')"),'keyword_video_id' => DB::raw("REPLACE(keyword_video_id, ',' , '')")]);
|
|
|
|
$keywordRelatedModel = new KeywordRelated();
|
|
|
|
$keywordRelatedModel->del(['product_id'=>$product_id,'keyword_id'=>$keyword_id]);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|