作者 lyh

gx

<?php
/**
* @remark :
* @name :ForwardInquiryCount.php
* @author :lyh
* @method :post
* @time :2023/8/18 9:41
*/
namespace App\Console\Commands\MonthlyCount;
use App\Models\Inquiry\ForwardCount;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
/**
* @remark :转发询盘人员统计
* @name :ForwardInquiryCount
* @author :lyh
* @method :post
* @time :2023/8/18 9:42
*/
class ForwardInquiryCount extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'forward_count';
/**
* The console command description.
*
* @var string
*/
protected $description = '月转发报告统计';
/**
* @remark :统计报告
* @name :handle
* @author :lyh
* @method :post
* @time :2023/8/18 9:52
*/
public function handle(){
// 获取上个月的开始时间
$startTime = Carbon::now()->subMonth()->startOfMonth();
// 获取上个月的结束时间
$endTime = Carbon::now()->subMonth()->endOfMonth();
$list = DB::table('gl_inquiry_info')->groupBy('user_name')
->select("user_name",DB::raw('COUNT(*) as count'))
->where()->get();
if(!empty($list)){
$list = $list->toArray();
$forwardModel = new ForwardCount();
foreach ($list as $v){
$data = [
'date'=>date('Y-m',time()),
'name'=>$v['user_name'],
'count'=>$v['count']
];
$forwardModel->add($data);
}
}
}
}
... ...
... ... @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Optimize\InquiryInfoLogic;
use App\Models\Inquiry\AreaTimezone;
use Carbon\Carbon;
use PhpOffice\PhpSpreadsheet\IOFactory;
/**
... ... @@ -262,6 +263,8 @@ class InquiryInfoController extends BaseController
* @time :2023/8/18 9:18
*/
public function getInternalCount(InquiryInfoLogic $inquiryInfoLogic){
var_dump(Carbon::now()->subMonth()->startOfMonth());
die();
$list = $inquiryInfoLogic->getManagerCount();
$this->response('success',Code::SUCCESS,$list);
}
... ...
<?php
/**
* @remark :
* @name :ForwardCount.php
* @author :lyh
* @method :post
* @time :2023/8/18 9:55
*/
namespace App\Models\Inquiry;
use App\Models\Base;
class ForwardCount extends Base
{
protected $table = 'gl_inquiry_forward_count';
}
... ...