UpgradeProjectCount.php
3.3 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
<?php
/**
* @remark :
* @name :UpgradeProjectCount.php
* @author :lyh
* @method :post
* @time :2024/1/8 9:03
*/
namespace App\Console\Commands\DayCount;
use App\Models\Visit\Visit;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use App\Models\HomeCount\Count;
class UpgradeProjectCount extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'upgrade_count';
/**
* The console command description.
*
* @var string
*/
protected $description = '升级项目统计';
public function handle(){
ProjectServer::useProject(439);
$this->count();
DB::disconnect('custom_mysql');
}
/**
* @remark :日统计记录
* @name :count
* @author :lyh
* @method :post
* @time :2024/1/8 9:05
*/
public function count(){
$list = DB::connection('custom_mysql')->table('gl_customer_visit')->select('updated_date')
->groupBy('updated_date')->get()->toArray();
if(!empty($list)){
$arr = [];
foreach ($list as $k=>$v){
echo date('Y-m-d H:i:s') . '时间:'.$v['updated_date'] . PHP_EOL;
$this->country20Top($v['updated_date']);
// $count = new Count();
// $arr['project_id'] = 439;
// $arr['date'] = $v['updated_date'];
// $arr['pv_num'] = $this->pv_num($v['updated_date']);
// $arr['ip_num'] = $this->ip_num($v['updated_date']);
// $arr['inquiry_num'] = $this->inquiry_num($v['updated_date']);
}
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :询盘国家前20
* @name :country20Top
* @author :lyh
* @method :post
* @time :2024/1/8 9:29
*/
public function country20Top($day){
$country = DB::connection('custom_mysql')->table('gl_customer_visit')
->whereDate('updated_date', $day)->where('inquiry_num',1)
->select('country', DB::raw('COUNT(*) as count'))
->groupBy('country')
->orderByDesc('count')->limit(20)->get()->toArray();
echo date('Y-m-d H:i:s') . 'shuju:'.json_encode($country) . PHP_EOL;
}
/**
* @remark :询盘数量
* @name :inquiry_num
* @author :lyh
* @method :post
* @time :2024/1/8 9:24
*/
public function inquiry_num($day){
$count = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $day)->where('inquiry_num',1)->count();
return $count;
}
/**
* @name :(统计pv)pv_num
* @author :lyh
* @method :post
* @time :2023/6/14 15:40
*/
public function pv_num($day){
$pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $day)->count();
return $pv;
}
/**
* @name :(统计ip)ip_num
* @author :lyh
* @method :post
* @time :2023/6/14 15:40
*/
public function ip_num($day){
$ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $day)->count();
return $ip;
}
}