|
@@ -12,6 +12,7 @@ namespace App\Http\Logic\Bside\GoogleKeywordInsight; |
|
@@ -12,6 +12,7 @@ namespace App\Http\Logic\Bside\GoogleKeywordInsight; |
|
12
|
use App\Helper\Translate;
|
12
|
use App\Helper\Translate;
|
|
13
|
use App\Http\Logic\Bside\BaseLogic;
|
13
|
use App\Http\Logic\Bside\BaseLogic;
|
|
14
|
use App\Models\GoogleKeywordInsight\GoogleKeywordInsight;
|
14
|
use App\Models\GoogleKeywordInsight\GoogleKeywordInsight;
|
|
|
|
15
|
+use App\Models\GoogleKeywordInsight\GoogleKeywordInsightDetail;
|
|
15
|
use App\Services\GoogleKeywordInsightService;
|
16
|
use App\Services\GoogleKeywordInsightService;
|
|
16
|
|
17
|
|
|
17
|
class GoogleKeywordInsightLogic extends BaseLogic
|
18
|
class GoogleKeywordInsightLogic extends BaseLogic
|
|
@@ -39,56 +40,11 @@ class GoogleKeywordInsightLogic extends BaseLogic |
|
@@ -39,56 +40,11 @@ class GoogleKeywordInsightLogic extends BaseLogic |
|
39
|
$data = $this->service->requestUrl($this->param['keyword']);
|
40
|
$data = $this->service->requestUrl($this->param['keyword']);
|
|
40
|
if(!empty($data)){
|
41
|
if(!empty($data)){
|
|
41
|
//保存数据库
|
42
|
//保存数据库
|
|
42
|
- $this->saveInsight($this->param['keyword'],$data);
|
|
|
|
43
|
- $this->saveInsightDetail($this->param['keyword'],$data);
|
43
|
+ $detailModel = new GoogleKeywordInsightDetail();
|
|
|
|
44
|
+ $this->model->saveInsight($this->param['keyword'],$data);
|
|
|
|
45
|
+ $detailModel->saveInsightDetail($this->param['keyword'],$data);
|
|
44
|
}
|
46
|
}
|
|
45
|
}
|
47
|
}
|
|
46
|
return $this->success($data);
|
48
|
return $this->success($data);
|
|
47
|
}
|
49
|
}
|
|
48
|
-
|
|
|
|
49
|
- /**
|
|
|
|
50
|
- * @remark :保存洞察总数据
|
|
|
|
51
|
- * @name :saveInsight
|
|
|
|
52
|
- * @author :lyh
|
|
|
|
53
|
- * @method :post
|
|
|
|
54
|
- * @time :2025/3/25 14:45
|
|
|
|
55
|
- */
|
|
|
|
56
|
- public function saveInsight($keyword,$data){
|
|
|
|
57
|
- $saveData = [
|
|
|
|
58
|
- 'search'=>$keyword,
|
|
|
|
59
|
- 'project_id'=>$this->user['project_id'],
|
|
|
|
60
|
- 'data'=>json_encode($data,true),
|
|
|
|
61
|
- ];
|
|
|
|
62
|
- return $this->model->addReturnId($saveData);
|
|
|
|
63
|
- }
|
|
|
|
64
|
-
|
|
|
|
65
|
- /**
|
|
|
|
66
|
- * @remark :保存洞察数据详情
|
|
|
|
67
|
- * @name :saveInsightDetail
|
|
|
|
68
|
- * @author :lyh
|
|
|
|
69
|
- * @method :post
|
|
|
|
70
|
- * @time :2025/3/25 14:45
|
|
|
|
71
|
- */
|
|
|
|
72
|
- public function saveInsightDetail($keyword,$data){
|
|
|
|
73
|
- $saveData = [];
|
|
|
|
74
|
- foreach ($data as $val){
|
|
|
|
75
|
- $zh_text = Translate::tran($val['text'], 'zh');
|
|
|
|
76
|
- if(empty($zh_text)){
|
|
|
|
77
|
- $zh_text = $val['text'];
|
|
|
|
78
|
- }
|
|
|
|
79
|
- $saveData[] = [
|
|
|
|
80
|
- 'search'=>$keyword,
|
|
|
|
81
|
- 'text'=>$val['text'],
|
|
|
|
82
|
- 'zh_text'=>$zh_text,
|
|
|
|
83
|
- 'project_id'=>$this->user['project_id'],
|
|
|
|
84
|
- 'volume'=>$val['volume'],
|
|
|
|
85
|
- 'competition_level'=>$val['competition_level'],
|
|
|
|
86
|
- 'competition_index'=>$val['competition_index'],
|
|
|
|
87
|
- 'low_bid'=>$val['low_bid'],
|
|
|
|
88
|
- 'high_bid'=>$val['high_bid'],
|
|
|
|
89
|
- 'trend'=>$val['trend'],
|
|
|
|
90
|
- ];
|
|
|
|
91
|
- }
|
|
|
|
92
|
- return $this->model->insertAll($saveData);
|
|
|
|
93
|
- }
|
|
|
|
94
|
} |
50
|
} |