作者 lyh

gx

  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();
  50 + // 获取上个月的结束时间
  51 + $endTime = Carbon::now()->subMonth()->endOfMonth();
  52 + $list = DB::table('gl_inquiry_info')->groupBy('user_name')
  53 + ->select("user_name",DB::raw('COUNT(*) as count'))
  54 + ->where()->get();
  55 + if(!empty($list)){
  56 + $list = $list->toArray();
  57 + $forwardModel = new ForwardCount();
  58 + foreach ($list as $v){
  59 + $data = [
  60 + 'date'=>date('Y-m',time()),
  61 + 'name'=>$v['user_name'],
  62 + 'count'=>$v['count']
  63 + ];
  64 + $forwardModel->add($data);
  65 + }
  66 + }
  67 + }
  68 +}
@@ -6,6 +6,7 @@ use App\Enums\Common\Code; @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
6 use App\Http\Controllers\Aside\BaseController; 6 use App\Http\Controllers\Aside\BaseController;
7 use App\Http\Logic\Aside\Optimize\InquiryInfoLogic; 7 use App\Http\Logic\Aside\Optimize\InquiryInfoLogic;
8 use App\Models\Inquiry\AreaTimezone; 8 use App\Models\Inquiry\AreaTimezone;
  9 +use Carbon\Carbon;
9 use PhpOffice\PhpSpreadsheet\IOFactory; 10 use PhpOffice\PhpSpreadsheet\IOFactory;
10 11
11 /** 12 /**
@@ -262,6 +263,8 @@ class InquiryInfoController extends BaseController @@ -262,6 +263,8 @@ class InquiryInfoController extends BaseController
262 * @time :2023/8/18 9:18 263 * @time :2023/8/18 9:18
263 */ 264 */
264 public function getInternalCount(InquiryInfoLogic $inquiryInfoLogic){ 265 public function getInternalCount(InquiryInfoLogic $inquiryInfoLogic){
  266 + var_dump(Carbon::now()->subMonth()->startOfMonth());
  267 + die();
265 $list = $inquiryInfoLogic->getManagerCount(); 268 $list = $inquiryInfoLogic->getManagerCount();
266 $this->response('success',Code::SUCCESS,$list); 269 $this->response('success',Code::SUCCESS,$list);
267 } 270 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ForwardCount.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/8/18 9:55
  8 + */
  9 +
  10 +namespace App\Models\Inquiry;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +
  15 +class ForwardCount extends Base
  16 +{
  17 + protected $table = 'gl_inquiry_forward_count';
  18 +}