|
1
|
-<?php
|
|
|
|
2
|
-/**
|
|
|
|
3
|
- * @remark :
|
|
|
|
4
|
- * @name :ForwardInquiryCount.php
|
|
|
|
5
|
- * @author :lyh
|
|
|
|
6
|
- * @method :post
|
|
|
|
7
|
- * @time :2023/8/18 9:41
|
|
|
|
8
|
- */
|
|
|
|
9
|
-
|
|
|
|
10
|
-namespace App\Console\Commands\MonthlyCount;
|
|
|
|
11
|
-
|
|
|
|
12
|
-use App\Models\Inquiry\ForwardCount;
|
|
|
|
13
|
-use Carbon\Carbon;
|
|
|
|
14
|
-use Illuminate\Console\Command;
|
|
|
|
15
|
-use Illuminate\Support\Facades\DB;
|
|
|
|
16
|
-
|
|
|
|
17
|
-/**
|
|
|
|
18
|
- * @remark :转发询盘人员统计
|
|
|
|
19
|
- * @name :ForwardInquiryCount
|
|
|
|
20
|
- * @author :lyh
|
|
|
|
21
|
- * @method :post
|
|
|
|
22
|
- * @time :2023/8/18 9:42
|
|
|
|
23
|
- */
|
|
|
|
24
|
-class ForwardInquiryCount extends Command
|
|
|
|
25
|
-{
|
|
|
|
26
|
- /**
|
|
|
|
27
|
- * The name and signature of the console command.
|
|
|
|
28
|
- *
|
|
|
|
29
|
- * @var string
|
|
|
|
30
|
- */
|
|
|
|
31
|
- protected $signature = 'forward_count';
|
|
|
|
32
|
-
|
|
|
|
33
|
- /**
|
|
|
|
34
|
- * The console command description.
|
|
|
|
35
|
- *
|
|
|
|
36
|
- * @var string
|
|
|
|
37
|
- */
|
|
|
|
38
|
- protected $description = '月转发报告统计';
|
|
|
|
39
|
-
|
|
|
|
40
|
- /**
|
|
|
|
41
|
- * @remark :统计报告
|
|
|
|
42
|
- * @name :handle
|
|
|
|
43
|
- * @author :lyh
|
|
|
|
44
|
- * @method :post
|
|
|
|
45
|
- * @time :2023/8/18 9:52
|
|
|
|
46
|
- */
|
|
|
|
47
|
- public function handle(){
|
|
|
|
48
|
- // 获取上个月的开始时间
|
|
|
|
49
|
- $startTime = Carbon::now()->subMonth()->startOfMonth()->toDateString();
|
|
|
|
50
|
- // 获取上个月的结束时间
|
|
|
|
51
|
- $endTime = Carbon::now()->subMonth()->endOfMonth()->toDateString();
|
|
|
|
52
|
- $list = DB::table('gl_inquiry_info')->groupBy('user_name')
|
|
|
|
53
|
- ->select("user_name",DB::raw('COUNT(*) as count'))
|
|
|
|
54
|
- ->where('send_time','>=',$startTime.' 00:00:00')
|
|
|
|
55
|
- ->where('send_time','<=',$endTime.' 23:59:59')
|
|
|
|
56
|
- ->get();
|
|
|
|
57
|
- if(!empty($list)){
|
|
|
|
58
|
- $list = $list->toArray();
|
|
|
|
59
|
- $forwardModel = new ForwardCount();
|
|
|
|
60
|
- foreach ($list as $v){
|
|
|
|
61
|
- $data = [
|
|
|
|
62
|
- 'date'=>Carbon::now()->subMonth()->format('Y-m'),
|
|
|
|
63
|
- 'name'=>$v['user_name'],
|
|
|
|
64
|
- 'count'=>$v['count']
|
|
|
|
65
|
- ];
|
|
|
|
66
|
- $forwardModel->add($data);
|
|
|
|
67
|
- }
|
|
|
|
68
|
- }
|
|
|
|
69
|
- return 1;
|
|
|
|
70
|
- }
|
|
|
|
71
|
-} |
|
|