CountLogic.php
6.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
namespace App\Http\Logic\Bside\HomeCount;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\EnterpriseService\EnterpriseService as EnterpriseServiceModel;
use App\Models\HomeCount\Count;
use App\Models\RankData\RankData as RankDataModel;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
class CountLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new Count();
}
/**
* @name :(昨日统计数据)yesterday_count
* @author :lyh
* @method :post
* @time :2023/5/23 17:30
*/
public function yesterday_count(){
$yesterday = Carbon::yesterday()->toDateString();
$param = [
'date' => $yesterday,
'project_id' => $this->user['project_id']
];
$info = $this->model->read($param,['pv_num','ip_num','inquiry_num','date','compliance_day','service_day']);
if($info === false){
$info = [];
}
return $this->success($info);
}
/**
* @name :(方案信息)scheme_info
* @author :lyh
* @method :post
* @time :2023/5/24 11:48
*/
public function scheme_info(){
$data = [
'company'=>$this->project['company'],
'scheme'=>$this->project['deploy_build']['plan'],
'service_duration'=>$this->project['deploy_build']['service_duration'],
];
return $this->success($data);
}
/**
* @name :(总访问量)total_count
* @author :lyh
* @method :post
* @time :2023/5/24 13:33
*/
public function total_count($inquiry_num = ''){
$pv = DB::table('gl_customer_visit_item')->where(['domain'=>$this->project['deploy_build']['test_domain']])->count();
$ip = DB::table('gl_customer_visit')->where(['domain'=>$this->project['deploy_build']['test_domain']])->count();
$data = [
'total_pv'=>$pv,
'total_ip'=>$ip,
'conversion_rate' => (isset($inquiry_num) && !empty($inquiry_num)) ? ($inquiry_num / $ip) * 100 : 0,
];
return $this->success($data);
}
/**
* @name :(前一天关键字排名统计)keyword_data
* @author :lyh
* @method :post
* @time :2023/5/24 14:03
*/
public function keyword_data_count(){
$yesterday = Carbon::yesterday()->toDateString();
$rankDataModel = new RankDataModel();
$param = [
'updated_date' => $yesterday,
'project_id' => $this->user['project_id']
];
$data = $rankDataModel->read($param,['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num']);
if($data === false){
$data = [];
}
return $this->success($data);
}
/**
* @name :(相关数据统计)with_data_count
* @author :lyh
* @method :post
* @time :2023/5/24 14:12
*/
public function with_data_count(){
$product_count = DB::table('gl_product')->where(['project_id' => $this->user['project_id']])->count();
$news_count = DB::table('gl_news')->where(['project_id' => $this->user['project_id']])->count();
$page_count = DB::table('gl_web_template')->where(['project_id' => $this->user['project_id']])->count();
$data = [
'product_count' => $product_count,
'news_count' => $news_count,
'page_count' => $page_count,
];
return $this->success($data);
}
/**
* @name :(30天数据统计)visit_data_count
* @author :lyh
* @method :post
* @time :2023/5/24 14:18
*/
public function visit_data_count(){
$param = [
'date' => ['between',[now()->subDays(30)->startOfDay()->toDateString(),now()->startOfDay()->toDateString()]],
'project_id' => $this->user['project_id']
];
$data = $this->model->list($param,'id',['id','pv_num','ip_num','date']);
return $this->success($data);
}
/**
* @name :(询盘国家统计)inquiry_country_count
* @author :lyh
* @method :post
* @time :2023/5/24 14:58
*/
public function inquiry_country_count(){
$data = DB::table('gl_inquiry_record')
->select('ip_area', DB::raw('COUNT(ip_area) as count'))
->groupBy('ip_area')->orderBy('count','desc')->limit(20)->get()->toArray();
$data = object_to_array($data);
$total = DB::table('gl_inquiry_record')->count();
foreach ($data as $k=>$v){
$data[$k]['proportion'] = ($v['count']/$total) * 100;
}
return $this->success($data);
}
/**
* @name :(访问来源统计)referrer_count
* @author :lyh
* @method :post
* @time :2023/5/24 15:32
*/
public function referrer_count(){
$data = DB::table('gl_customer_visit')
->select('referrer_url', DB::raw('COUNT(*) as count'))->groupBy('referrer_url')
->orderByDesc('count')->limit(8)->get()->toArray();
$total = DB::table('gl_customer_visit')->count();
$data = object_to_array($data);
foreach ($data as $k=>$v){
$data[$k]['proportion'] = ($v['count']/$total) * 100;
}
return $this->success($data);
}
/**
* @name :(访问国家统计)access_country_count
* @author :lyh
* @method :post
* @time :2023/5/24 15:56
*/
public function access_country_count(){
$data = DB::table('gl_customer_visit')
->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
->groupBy('country')->orderBy('ip','desc')->limit(20)->get()->toArray();
$data = object_to_array($data);
foreach ($data as $k => $v){
$v['pv'] = (int)$v['pv'];
$data[$k] = $v;
}
return $this->success($data);
}
/**
* @name :(售后服务中心)enterprise_service
* @author :lyh
* @method :post
* @time :2023/5/25 10:22
*/
public function enterprise_service(){
$enterpriseServiceModel = new EnterpriseServiceModel();
$info = $enterpriseServiceModel->read(['status'=>0]);
return $this->success($info);
}
}