|
@@ -42,6 +42,9 @@ class KeywordLogic extends BaseLogic |
|
@@ -42,6 +42,9 @@ class KeywordLogic extends BaseLogic |
|
42
|
if($info !== false){
|
42
|
if($info !== false){
|
|
43
|
$info['url'] = $this->user['domain'] . $info['route'];
|
43
|
$info['url'] = $this->user['domain'] . $info['route'];
|
|
44
|
$info['related_news_info'] = News::whereIn('id', $info['related_news_ids'])->select(['id', 'name'])->get();
|
44
|
$info['related_news_info'] = News::whereIn('id', $info['related_news_ids'])->select(['id', 'name'])->get();
|
|
|
|
45
|
+ $product = $this->getProduct($info['id']);
|
|
|
|
46
|
+ $info['product_list'] = $product['product'] ?? [];
|
|
|
|
47
|
+ $info['product_video_list'] = $product['video_product'] ?? [];
|
|
45
|
}
|
48
|
}
|
|
46
|
return $this->success($info);
|
49
|
return $this->success($info);
|
|
47
|
}
|
50
|
}
|
|
@@ -82,6 +85,9 @@ class KeywordLogic extends BaseLogic |
|
@@ -82,6 +85,9 @@ class KeywordLogic extends BaseLogic |
|
82
|
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
|
85
|
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
|
|
83
|
$this->model->edit(['route'=>$route],['id'=>$id]);
|
86
|
$this->model->edit(['route'=>$route],['id'=>$id]);
|
|
84
|
$data = ['id'=>$id];
|
87
|
$data = ['id'=>$id];
|
|
|
|
88
|
+ if(isset($this->param['keyword_arr']) && isset($this->param['keyword_video_arr'])){
|
|
|
|
89
|
+ $this->delRelated($id,$this->param['keyword_arr'],$this->param['keyword_video_arr']);
|
|
|
|
90
|
+ }
|
|
85
|
}
|
91
|
}
|
|
86
|
Common::del_user_cache('product_keyword',$this->user['project_id']);
|
92
|
Common::del_user_cache('product_keyword',$this->user['project_id']);
|
|
87
|
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_KEYWORD,$route);
|
93
|
$this->addUpdateNotify(RouteMap::SOURCE_PRODUCT_KEYWORD,$route);
|
|
@@ -298,4 +304,51 @@ class KeywordLogic extends BaseLogic |
|
@@ -298,4 +304,51 @@ class KeywordLogic extends BaseLogic |
|
298
|
}
|
304
|
}
|
|
299
|
return $this->success();
|
305
|
return $this->success();
|
|
300
|
}
|
306
|
}
|
|
|
|
307
|
+
|
|
|
|
308
|
+ /**
|
|
|
|
309
|
+ * @remark :根据关键字获取产品
|
|
|
|
310
|
+ * @name :getProduct
|
|
|
|
311
|
+ * @author :lyh
|
|
|
|
312
|
+ * @method :post
|
|
|
|
313
|
+ * @time :2024/11/28 9:26
|
|
|
|
314
|
+ */
|
|
|
|
315
|
+ public function getProduct($keyword_id){
|
|
|
|
316
|
+ $data_video_type_arr = $data_type_arr = [];
|
|
|
|
317
|
+ $keywordRelatedModel = new KeywordRelated();
|
|
|
|
318
|
+ $keywordRelateList = $keywordRelatedModel->list(['keyword_id'=>$keyword_id],'id',['id','product_id','type']);
|
|
|
|
319
|
+ if(!empty($keywordRelateList)){
|
|
|
|
320
|
+ foreach ($keywordRelateList as $val){
|
|
|
|
321
|
+ if($val['type'] == 1){
|
|
|
|
322
|
+ $data_type_arr[] = $val['product_id'];
|
|
|
|
323
|
+ }else{
|
|
|
|
324
|
+ $data_video_type_arr[] = $val['product_id'];
|
|
|
|
325
|
+ }
|
|
|
|
326
|
+ }
|
|
|
|
327
|
+ }
|
|
|
|
328
|
+ $productVideoList = $productList = [];
|
|
|
|
329
|
+ $productModel = new Product();
|
|
|
|
330
|
+ if(!empty($data_type_arr)){
|
|
|
|
331
|
+ $productList = $productModel->list(['id'=>['in',$data_type_arr]],'id',['id','title']);
|
|
|
|
332
|
+ }
|
|
|
|
333
|
+ if(!empty($data_video_type_arr)){
|
|
|
|
334
|
+ $productVideoList = $productModel->list(['id'=>['in',$data_video_type_arr]],'id',['id','title']);
|
|
|
|
335
|
+ }
|
|
|
|
336
|
+ return $this->success(['product'=>$productList,'video_product'=>$productVideoList]);
|
|
|
|
337
|
+ }
|
|
|
|
338
|
+
|
|
|
|
339
|
+ /**
|
|
|
|
340
|
+ * @remark :对应删除关联关系
|
|
|
|
341
|
+ * @name :delRelated
|
|
|
|
342
|
+ * @author :lyh
|
|
|
|
343
|
+ * @method :post
|
|
|
|
344
|
+ * @time :2024/11/28 9:46
|
|
|
|
345
|
+ */
|
|
|
|
346
|
+ public function delRelated($product_id,$keyword_arr = [],$keyword_video_arr = []){
|
|
|
|
347
|
+ $productModel = new Product();
|
|
|
|
348
|
+ $keyword_str = !empty($keyword_arr) ? ','.implode(',',$keyword_arr).',' : '';
|
|
|
|
349
|
+ KeywordRelated::saveRelated($product_id,$keyword_arr);
|
|
|
|
350
|
+ KeywordRelated::saveRelated($product_id,$keyword_video_arr,2);
|
|
|
|
351
|
+ $keyword_video_str = !empty($keyword_video_arr) ? ','.implode(',',$keyword_arr).',' : '';
|
|
|
|
352
|
+ $productModel->edit(['keyword_id'=>$keyword_str,'keyword_video_id'=>$keyword_video_str],['id'=>$product_id]);
|
|
|
|
353
|
+ }
|
|
301
|
} |
354
|
} |