作者 lyh

gx

@@ -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 }
@@ -14,4 +14,21 @@ use App\Models\Base; @@ -14,4 +14,21 @@ use App\Models\Base;
14 class GoogleKeywordInsight extends Base 14 class GoogleKeywordInsight extends Base
15 { 15 {
16 protected $table = 'gl_google_keyword_insight'; 16 protected $table = 'gl_google_keyword_insight';
  17 +
  18 + /**
  19 + * @remark :保存洞察总数据
  20 + * @name :saveInsight
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2025/3/25 14:45
  24 + */
  25 + public function saveInsight($keyword,$data){
  26 + $saveData = [
  27 + 'search'=>$keyword,
  28 + 'project_id'=>$this->user['project_id'],
  29 + 'data'=>json_encode($data,true),
  30 + ];
  31 + return $this->addReturnId($saveData);
  32 + }
  33 +
17 } 34 }
@@ -9,9 +9,40 @@ @@ -9,9 +9,40 @@
9 9
10 namespace App\Models\GoogleKeywordInsight; 10 namespace App\Models\GoogleKeywordInsight;
11 11
  12 +use App\Helper\Translate;
12 use App\Models\Base; 13 use App\Models\Base;
13 14
14 class GoogleKeywordInsightDetail extends Base 15 class GoogleKeywordInsightDetail extends Base
15 { 16 {
16 protected $table = 'gl_google_keyword_insight_detail'; 17 protected $table = 'gl_google_keyword_insight_detail';
  18 +
  19 + /**
  20 + * @remark :保存洞察数据详情
  21 + * @name :saveInsightDetail
  22 + * @author :lyh
  23 + * @method :post
  24 + * @time :2025/3/25 14:45
  25 + */
  26 + public function saveInsightDetail($keyword,$data){
  27 + $saveData = [];
  28 + foreach ($data as $val){
  29 + $zh_text = Translate::tran($val['text'], 'zh');
  30 + if(empty($zh_text)){
  31 + $zh_text = $val['text'];
  32 + }
  33 + $saveData[] = [
  34 + 'search'=>$keyword,
  35 + 'text'=>$val['text'],
  36 + 'zh_text'=>$zh_text,
  37 + 'project_id'=>$this->user['project_id'],
  38 + 'volume'=>$val['volume'],
  39 + 'competition_level'=>$val['competition_level'],
  40 + 'competition_index'=>$val['competition_index'],
  41 + 'low_bid'=>$val['low_bid'],
  42 + 'high_bid'=>$val['high_bid'],
  43 + 'trend'=>$val['trend'],
  44 + ];
  45 + }
  46 + return $this->insertAll($saveData);
  47 + }
17 } 48 }