Commit 248a7627 by 赵增煜

有效医师

parent 88e25395
...@@ -193,6 +193,7 @@ public function create(Request $request) ...@@ -193,6 +193,7 @@ public function create(Request $request)
$startOfDay = Carbon::now()->startOfDay(); $startOfDay = Carbon::now()->startOfDay();
$endOfDay = Carbon::now()->endOfDay(); $endOfDay = Carbon::now()->endOfDay();
$doctorIds = DoctorModel::query()->where('status', DoctorModel::STATUS_TRUE)->pluck('id')->toArray(); $doctorIds = DoctorModel::query()->where('status', DoctorModel::STATUS_TRUE)->pluck('id')->toArray();
Log::info('医师ids:'.json_encode($doctorIds));
$prescriptionCounts = PrescriptionModel::select('doctor_id', DB::raw('COUNT(*) as prescription_count')) $prescriptionCounts = PrescriptionModel::select('doctor_id', DB::raw('COUNT(*) as prescription_count'))
->whereIn('doctor_id', $doctorIds) ->whereIn('doctor_id', $doctorIds)
->whereBetween('created_at', [$startOfDay, $endOfDay]) ->whereBetween('created_at', [$startOfDay, $endOfDay])
...@@ -201,11 +202,11 @@ public function create(Request $request) ...@@ -201,11 +202,11 @@ public function create(Request $request)
Log::info('医师开方统计:'.json_encode($prescriptionCounts)); Log::info('医师开方统计:'.json_encode($prescriptionCounts));
if (count($prescriptionCounts) > 0) { if (count($prescriptionCounts) > 0) {
foreach ($doctorIds as $doctorId) { foreach ($doctorIds as $key=>$doctorId) {
if (isset($prescriptionCounts[$doctorId])) { if (isset($prescriptionCounts[$doctorId])) {
// 判断是否达到上限 // 判断是否达到上限
if (intval($prescriptionCounts[$doctorId]) >= intval($prescription_limit)) { if (intval($prescriptionCounts[$doctorId]) >= intval($prescription_limit)) {
unset($doctorIds[$doctorId]); unset($doctorIds[$key]);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment