master
cody 9 months ago
parent f2bf487d96
commit 01db45dfbf

@ -51,14 +51,22 @@ class ChartController extends CommonController
$list = [ $list = [
'common_visit' => [ 'common_visit' => [
// 总人数
'total' => $buildQuery(1)->count(), 'total' => $buildQuery(1)->count(),
// 总入场人数
'enter_visit' => $buildQuery(1)->whereNotNull('accept_admin_sign')->count(), 'enter_visit' => $buildQuery(1)->whereNotNull('accept_admin_sign')->count(),
'today_total' => Visit::where('type', 1)->where('date', date('Y-m-d'))->count(),
'today_enter_visit' => Visit::where('type', 1)->where('date', date('Y-m-d'))->whereNotNull('accept_admin_sign')->count(),
// 离厂统计 // 离厂统计
'leave_total' => $buildQuery(1)->where('audit_status', Visit::AUDIT_STATUS_LEFT)->count(), 'leave_total' => $buildQuery(1)->where('audit_status', Visit::AUDIT_STATUS_LEFT)->count(),
// 总随访人数
'follow_total' => $buildQuery(1)->get()->sum('follw_people_total'),
// 今日总人数
'today_total' => $buildQuery(1)->where('date', date('Y-m-d'))->count(),
// 今日入场人数
'today_enter_visit' => $buildQuery(1)->where('date', date('Y-m-d'))->whereNotNull('accept_admin_sign')->count(),
// 今日离厂 // 今日离厂
'today_leave_total' => Visit::where('type', 1)->where('date', date('Y-m-d'))->where('audit_status', Visit::AUDIT_STATUS_LEFT)->count(), 'today_leave_total' => $buildQuery(1)->where('date', date('Y-m-d'))->where('audit_status', Visit::AUDIT_STATUS_LEFT)->count(),
// 今日随访人数
'today_follow_total' => $buildQuery(1)->where('date', date('Y-m-d'))->get()->sum('follw_people_total'),
], ],
'work_visit' => [ 'work_visit' => [
'total' => $buildQuery(2)->count(), 'total' => $buildQuery(2)->count(),
@ -69,6 +77,10 @@ class ChartController extends CommonController
'leave_total' => $buildQuery(2)->where('audit_status', Visit::AUDIT_STATUS_LEFT)->count(), 'leave_total' => $buildQuery(2)->where('audit_status', Visit::AUDIT_STATUS_LEFT)->count(),
// 今日离厂 // 今日离厂
'today_leave_total' => Visit::where('type', 2)->where('date', date('Y-m-d'))->where('audit_status', Visit::AUDIT_STATUS_LEFT)->count(), 'today_leave_total' => Visit::where('type', 2)->where('date', date('Y-m-d'))->where('audit_status', Visit::AUDIT_STATUS_LEFT)->count(),
// 总随访人数
'follow_total' => $buildQuery(2)->get()->sum('follw_people_total'),
// 今日随访人数
'today_follow_total' => $buildQuery(2)->where('date', date('Y-m-d'))->get()->sum('follw_people_total'),
], ],
'car_visit' => [ 'car_visit' => [
'total' => $buildQuery(3)->count(), 'total' => $buildQuery(3)->count(),
@ -79,6 +91,10 @@ class ChartController extends CommonController
'leave_total' => $buildQuery(3)->where('audit_status', Visit::AUDIT_STATUS_LEFT)->count(), 'leave_total' => $buildQuery(3)->where('audit_status', Visit::AUDIT_STATUS_LEFT)->count(),
// 今日离厂 // 今日离厂
'today_leave_total' => Visit::where('type', 3)->where('date', date('Y-m-d'))->where('audit_status', Visit::AUDIT_STATUS_LEFT)->count(), 'today_leave_total' => Visit::where('type', 3)->where('date', date('Y-m-d'))->where('audit_status', Visit::AUDIT_STATUS_LEFT)->count(),
// 总随访人数
'follow_total' => $buildQuery(3)->get()->sum('follw_people_total'),
// 今日随访人数
'today_follow_total' => $buildQuery(3)->where('date', date('Y-m-d'))->get()->sum('follw_people_total'),
], ],
]; ];

@ -32,7 +32,7 @@ class Visit extends SoftDeletesModel
protected $guarded = ['id']; protected $guarded = ['id'];
protected $appends = ['type_text', 'audit_status_text', 'file_detail', 'vehicle_images_detail']; protected $appends = ['type_text', 'audit_status_text', 'file_detail', 'vehicle_images_detail', 'follw_people_total'];
protected $casts = [ protected $casts = [
'follw_people' => 'json', 'follw_people' => 'json',
@ -51,6 +51,14 @@ class Visit extends SoftDeletesModel
return Upload::whereIn('id', $this->file)->get(); return Upload::whereIn('id', $this->file)->get();
} }
/**
* 获取随访人数
*/
public function getFollwPeopleTotalAttribute()
{
return $this->follw_people ? count($this->follw_people) : 0;
}
public function getVehicleImagesDetailAttribute() public function getVehicleImagesDetailAttribute()
{ {
if (empty($this->vehicle_images)) { if (empty($this->vehicle_images)) {

Loading…
Cancel
Save