GoogleKeywordInsightDetail.php
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* @remark :
* @name :GoogleKeywordInsightDetail.php
* @author :lyh
* @method :post
* @time :2025/3/25 14:33
*/
namespace App\Models\GoogleKeywordInsight;
use App\Helper\Translate;
use App\Models\Base;
class GoogleKeywordInsightDetail extends Base
{
protected $table = 'gl_google_insight_detail';
/**
* @remark :保存洞察数据详情
* @name :saveInsightDetail
* @author :lyh
* @method :post
* @time :2025/3/25 14:45
*/
public function saveInsightDetail($project_id,$keyword,$data){
$saveData = [];
$textArr = array_column($data, 'text');
$transData = Translate::tran($textArr, 'zh');
foreach ($data as $key => $val){
$saveData[] = [
'search'=>$keyword,
'text'=>$val['text'],
'zh_text'=>$transData[$key] ?? $val['text'],
'project_id'=>$project_id,
'volume'=>$val['volume'],
'competition_level'=>$val['competition_level'],
'competition_index'=>$val['competition_index'],
'low_bid'=>$val['low_bid'],
'high_bid'=>$val['high_bid'],
'trend'=>$val['trend'],
];
}
return $this->insertAll($saveData);
}
/**
* @remark :保存一条数据
* @name :saveInsightDetailOne
* @author :lyh
* @method :post
* @time :2025/4/1 11:32
*/
public function saveInsightDetailOne($project_id,$keyword,$data){
$transData = Translate::tran($data['text'], 'zh');
$saveData = [
'search'=>$keyword,
'text'=>$data['text'],
'zh_text'=>$transData ?? $data['text'],
'project_id'=>$project_id,
'volume'=>$data['volume'],
'competition_level'=>$data['competition_level'],
'competition_index'=>$data['competition_index'],
'low_bid'=>$data['low_bid'],
'high_bid'=>$data['high_bid'],
'trend'=>$data['trend'],
];
return $this->addReturnId($saveData);
}
}