130 lines
7.5 KiB
PHP
130 lines
7.5 KiB
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings; //设置标题
|
|
use App\Models\ApproveHistory;
|
|
class UserApprovedExport implements FromCollection,WithHeadings
|
|
{
|
|
private $data;
|
|
public function __construct()
|
|
{
|
|
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'序号',
|
|
'部门',
|
|
'姓名',
|
|
'推广号码',
|
|
'人数',
|
|
];
|
|
}
|
|
public function columnFormats(): array
|
|
{
|
|
return [
|
|
'A' => NumberFormat::FORMAT_TEXT,
|
|
];
|
|
}
|
|
public function collection()
|
|
{
|
|
$workers = $this->workers();
|
|
$start_time = request()->input('start_time');
|
|
$end_time = request()->input('end_time');
|
|
$logs = ApproveHistory::with('fromUser')->where('type', 'body')->where('status', 1)->whereBetween('created_at', [$start_time, $end_time])->get();
|
|
foreach ($logs as $log) {
|
|
foreach ($workers as &$worker) {
|
|
$type = 0;
|
|
if ($log->from_user_id) {
|
|
if ($worker['mobile'] == $log->fromUser->mobile) {
|
|
$worker['num'] += 1;
|
|
$type = 1;
|
|
break;
|
|
}
|
|
if ($worker['mobile'] != $log->fromUser->mobile && $worker['id'] == 57) {
|
|
$worker['num'] += 1;
|
|
$type = 1;
|
|
break;
|
|
}
|
|
}else{// no from_user_id
|
|
if ($worker['name'] == '未记录') {
|
|
$worker['num'] += 1;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$workers[] = ['id'=>'总数', 'num'=>count($logs)];
|
|
$data = collect($workers);
|
|
return $data;
|
|
}
|
|
|
|
public function workers()
|
|
{
|
|
$arr = [
|
|
['id'=>1, 'branch'=>'客服部', 'name'=>'但齐', 'mobile'=>13058071372, 'num'=>0],
|
|
['id'=>2, 'branch'=>'客服部', 'name'=>'但齐', 'mobile'=>18145852809, 'num'=>0],
|
|
['id'=>3, 'branch'=>'客服部', 'name'=>'但齐', 'mobile'=>13122565695, 'num'=>0],
|
|
['id'=>4, 'branch'=>'客服部', 'name'=>'杨嘉恩', 'mobile'=>15800001890, 'num'=>0],
|
|
['id'=>5, 'branch'=>'客服部', 'name'=>'杨嘉恩', 'mobile'=>13751693656, 'num'=>0],
|
|
['id'=>6, 'branch'=>'客服部', 'name'=>'杨嘉恩', 'mobile'=>13202316035, 'num'=>0],
|
|
['id'=>7, 'branch'=>'客服部', 'name'=>'谭妙平', 'mobile'=>15818572612, 'num'=>0],
|
|
['id'=>8, 'branch'=>'客服部', 'name'=>'阳平', 'mobile'=>15659761561, 'num'=>0],
|
|
['id'=>9, 'branch'=>'客服部', 'name'=>'金虹燕', 'mobile'=>13600158195, 'num'=>0],
|
|
['id'=>10, 'branch'=>'客服部', 'name'=>'杨乐恩', 'mobile'=>13249888386, 'num'=>0],
|
|
['id'=>11, 'branch'=>'客服部', 'name'=>'杨乐恩', 'mobile'=>15018266605, 'num'=>0],
|
|
['id'=>12, 'branch'=>'客服部', 'name'=>'陈成', 'mobile'=>17666132809, 'num'=>0],
|
|
['id'=>13, 'branch'=>'客服部', 'name'=>'陈成', 'mobile'=>13671968879, 'num'=>0],
|
|
['id'=>14, 'branch'=>'客服部', 'name'=>'陈成', 'mobile'=>13265478879, 'num'=>0],
|
|
['id'=>15, 'branch'=>'客服部', 'name'=>'张聿俊', 'mobile'=>15629390906, 'num'=>0],
|
|
['id'=>16, 'branch'=>'客服部', 'name'=>'张薇薇', 'mobile'=>13266890532, 'num'=>0],
|
|
['id'=>17, 'branch'=>'客服部', 'name'=>'张薇薇', 'mobile'=>13929563819, 'num'=>0],
|
|
['id'=>18, 'branch'=>'客服部', 'name'=>'张薇薇', 'mobile'=>18194066804, 'num'=>0],
|
|
['id'=>19, 'branch'=>'商务部', 'name'=>'林文静', 'mobile'=>13428728141, 'num'=>0],
|
|
['id'=>20, 'branch'=>'商务部', 'name'=>'张瑞玲', 'mobile'=>18922809346, 'num'=>0],
|
|
['id'=>21, 'branch'=>'商务部', 'name'=>'张瑞玲', 'mobile'=>13670180767, 'num'=>0],
|
|
['id'=>22, 'branch'=>'商务部', 'name'=>'张瑞玲', 'mobile'=>18818570521, 'num'=>0],
|
|
['id'=>23, 'branch'=>'商务部', 'name'=>'王庆吉', 'mobile'=>15989575285, 'num'=>0],
|
|
['id'=>24, 'branch'=>'商务部', 'name'=>'张艳彬', 'mobile'=>13377553550, 'num'=>0],
|
|
['id'=>25, 'branch'=>'商务部', 'name'=>'李芳贤', 'mobile'=>18711720959, 'num'=>0],
|
|
['id'=>26, 'branch'=>'商务部', 'name'=>'李芳贤', 'mobile'=>17688979885, 'num'=>0],
|
|
['id'=>27, 'branch'=>'商务部', 'name'=>'熊怡凯', 'mobile'=>13809640078, 'num'=>0],
|
|
['id'=>28, 'branch'=>'商务部', 'name'=>'赵艳敏', 'mobile'=>13266550216, 'num'=>0],
|
|
['id'=>29, 'branch'=>'新媒体', 'name'=>'殷配环', 'mobile'=>15820768996, 'num'=>0],
|
|
['id'=>30, 'branch'=>'新媒体', 'name'=>'李昆', 'mobile'=>18677369475, 'num'=>0],
|
|
['id'=>31, 'branch'=>'新媒体', 'name'=>'黎美余', 'mobile'=>13420978248, 'num'=>0],
|
|
['id'=>32, 'branch'=>'新媒体', 'name'=>'谭宏', 'mobile'=>18879165527, 'num'=>0],
|
|
['id'=>33, 'branch'=>'新媒体', 'name'=>'周金辉', 'mobile'=>13178822477, 'num'=>0],
|
|
['id'=>34, 'branch'=>'新媒体', 'name'=>'周金辉', 'mobile'=>18898888797, 'num'=>0],
|
|
['id'=>35, 'branch'=>'新媒体', 'name'=>'赵淑美', 'mobile'=>13510197130, 'num'=>0],
|
|
['id'=>36, 'branch'=>'客服部', 'name'=>'郭鳌', 'mobile'=>18402011334, 'num'=>0],
|
|
['id'=>37, 'branch'=>'行政', 'name'=>'王美玲', 'mobile'=>15323715085, 'num'=>0],
|
|
['id'=>38, 'branch'=>'行政', 'name'=>'王美玲', 'mobile'=>13829133831, 'num'=>0],
|
|
['id'=>39, 'branch'=>'特别', 'name'=>'金文文', 'mobile'=>19925470983, 'num'=>0],
|
|
['id'=>40, 'branch'=>'特别', 'name'=>'李雪花', 'mobile'=>18038040879, 'num'=>0],
|
|
['id'=>41, 'branch'=>'特别', 'name'=>'李雪花', 'mobile'=>15914022467, 'num'=>0],
|
|
['id'=>42, 'branch'=>'特别', 'name'=>'李恒飞', 'mobile'=>13138853376, 'num'=>0],
|
|
['id'=>43, 'branch'=>'技术', 'name'=>'蓝志辉', 'mobile'=>15622316024, 'num'=>0],
|
|
['id'=>44, 'branch'=>'技术', 'name'=>'黄济', 'mobile'=>15872844805, 'num'=>0],
|
|
['id'=>45, 'branch'=>'技术', 'name'=>'廖世熙', 'mobile'=>15779459915, 'num'=>0],
|
|
['id'=>46, 'branch'=>'技术', 'name'=>'曾斌', 'mobile'=>15112292112, 'num'=>0],
|
|
['id'=>47, 'branch'=>'技术', 'name'=>'林兰', 'mobile'=>15012955320, 'num'=>0],
|
|
['id'=>48, 'branch'=>'技术', 'name'=>'邓智锋', 'mobile'=>15707534403, 'num'=>0],
|
|
['id'=>49, 'branch'=>'技术', 'name'=>'申维祯', 'mobile'=>18363129725, 'num'=>0],
|
|
['id'=>50, 'branch'=>'技术', 'name'=>'曾荣耀', 'mobile'=>18922809435, 'num'=>0],
|
|
['id'=>51, 'branch'=>'技术', 'name'=>'叶其焕', 'mobile'=>13682473213, 'num'=>0],
|
|
['id'=>52, 'branch'=>'技术', 'name'=>'王立军', 'mobile'=>15211212467, 'num'=>0],
|
|
['id'=>53, 'branch'=>'技术', 'name'=>'吕燕青', 'mobile'=>13536370059, 'num'=>0],
|
|
['id'=>54, 'branch'=>'技术', 'name'=>'刘晋', 'mobile'=>18171893605, 'num'=>0],
|
|
['id'=>55, 'branch'=>'技术', 'name'=>'秦磊', 'mobile'=>18667151881, 'num'=>0],
|
|
['id'=>56, 'branch'=>'技术', 'name'=>'杨少锋', 'mobile'=>18778113153, 'num'=>0],
|
|
['id'=>57, 'branch'=>'', 'name'=>'其他人', 'mobile'=>'', 'num'=>0],
|
|
['id'=>58, 'branch'=>'', 'name'=>'未记录', 'mobile'=>'', 'num'=>0]
|
|
];
|
|
return $arr;
|
|
}
|
|
}
|