|
|
|
|
@ -40,32 +40,30 @@ class HomeController extends CommonController
|
|
|
|
|
// 护工陪护
|
|
|
|
|
$paramedic = [
|
|
|
|
|
'total' => Paramedic::count(),
|
|
|
|
|
'has_accompany' => '',
|
|
|
|
|
'no_accompany' => '',
|
|
|
|
|
'accompany_order' => '',
|
|
|
|
|
'rate' => ''
|
|
|
|
|
'has_accompany' => Paramedic::whereHas('ongoingOrders')->count(),
|
|
|
|
|
'no_accompany' => Paramedic::whereDoesntHave('ongoingOrders')->count(),
|
|
|
|
|
'accompany_order' => Orders::where('status', Orders::STATUS_ONGOING)->count(),
|
|
|
|
|
];
|
|
|
|
|
// 床位陪护
|
|
|
|
|
$bed = [
|
|
|
|
|
'total' => Bed::count(),
|
|
|
|
|
'has_accompany' => '',
|
|
|
|
|
'no_accompany' => '',
|
|
|
|
|
'rate' => ''
|
|
|
|
|
'has_accompany' => Bed::whereHas('onGoingOrder')->count(),
|
|
|
|
|
'no_accompany' => Bed::whereDoesntHave('onGoingOrder')->count(),
|
|
|
|
|
];
|
|
|
|
|
// 陪护统计表
|
|
|
|
|
$project = Project::get();
|
|
|
|
|
foreach ($project as $item) {
|
|
|
|
|
|
|
|
|
|
$item->total = Orders::where('project_id', $item->id)->count();
|
|
|
|
|
}
|
|
|
|
|
// 最新陪护单
|
|
|
|
|
$lastOrder = Orders::with('project')
|
|
|
|
|
->where('status', 0)
|
|
|
|
|
->where('status', Orders::STATUS_UNCONFIRMED)
|
|
|
|
|
->orderBy('id', 'desc')
|
|
|
|
|
->limit(8)
|
|
|
|
|
->get();
|
|
|
|
|
// 最新出院信息
|
|
|
|
|
$outOrder = Orders::with('project')
|
|
|
|
|
->where('status', 100)
|
|
|
|
|
->where('status', Orders::STATUS_FINISHED)
|
|
|
|
|
->orderBy('id', 'desc')
|
|
|
|
|
->limit(8)
|
|
|
|
|
->get();
|
|
|
|
|
@ -74,9 +72,20 @@ class HomeController extends CommonController
|
|
|
|
|
// 上月满意度评价分析
|
|
|
|
|
$satisfied = [];
|
|
|
|
|
// 本月营收分析
|
|
|
|
|
$income = [];
|
|
|
|
|
$income = Project::get();
|
|
|
|
|
foreach ($income as $item) {
|
|
|
|
|
$item->total = Orders::where('project_id', $item->id)
|
|
|
|
|
->where('created_at', 'like', '%' . date('Y-m') . '%')
|
|
|
|
|
->where('status', Orders::STATUS_FINISHED)
|
|
|
|
|
->sum('paid_total');
|
|
|
|
|
}
|
|
|
|
|
// 本月陪护订单
|
|
|
|
|
$monthAccompany = [];
|
|
|
|
|
$monthAccompany = Project::get();
|
|
|
|
|
foreach ($income as $item) {
|
|
|
|
|
$item->total = Orders::where('project_id', $item->id)
|
|
|
|
|
->where('created_at', 'like', '%' . date('Y-m') . '%')
|
|
|
|
|
->count();
|
|
|
|
|
}
|
|
|
|
|
return $this->ajaxSuccess('获取成功', compact('paramedic', 'bed', 'project',
|
|
|
|
|
'lastOrder', 'outOrder', 'tip', 'satisfied', 'income', 'monthAccompany'));
|
|
|
|
|
}
|
|
|
|
|
|