InquiryCount.php
2.4 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
<?php
namespace App\Console\Commands\DayCount;
use App\Models\Inquiry\InquiryCount as InquiryCountModel;
use App\Models\Inquiry\InquiryInfo;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
/**
* @remark :
* @class :InquiryCount.php
* @author :lyh
* @time :2023/7/14 16:20
*/
class InquiryCount extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'inquiry_count';
/**
* The console command description.
*
* @var string
*/
protected $description = '每天统计询盘数量';
/**
* @var :根据状态统计
*/
public $status = [
1=>'站群询盘',
2=>'ai站群询盘',
3=>'amp自建平台',
4=>'fb询盘',
5=>'fb广告',
6=>'广告采集建站',
7=>'黄金平台询盘',
8=>'内部统计',
9=>'GlobalImporter',
10=>'whatsapp',
11=>'Skype',
12=>'建站客户',
13=>'ChinaCn',
14=>'EC21',
15=>'邮件群发'
];
/**
* @remark :统计
* @name :handle
* @author :lyh
* @method :post
* @time :2023/7/14 16:21
*/
public function handle(){
$data = [];
//获取昨天的时间
$yesterday = Carbon::yesterday()->toDateString();
$inquiryInfoModel = new InquiryInfo();
try {
foreach ($this->status as $k=>$v){
$total = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']]])->count();
$untreated = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>1])->count();
$invalid = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>0])->count();
$data[] = [
'type'=>$k,
'day'=>$yesterday,
'total'=>$total ?? 0,
'untreated'=>$untreated ?? 0,
'invalid'=>$invalid ?? 0
];
}
$inquiryCount = new InquiryCountModel();
$inquiryCount->insert($data);
}catch (\Exception $e){
Log::error('inquiry_count : error');
}
return true;
}
}