| xqd
@@ -186,9 +186,7 @@ class DocterController extends AuthController
|
|
|
'latitude' => 'numeric',
|
|
|
'longitude' => 'numeric',
|
|
|
]);
|
|
|
- $user = $this->user;
|
|
|
- //todo Schedule表 考虑是否有必要性,日期可以通过timePeriod取到。
|
|
|
- $builder = Schedule::with(['schedulePeriod.timePeriod', 'schedulePeriod.organization'])->where('docter_id', $req['docter_id'])->where('schedule_day', '>=', date('Ymd'));
|
|
|
+ $builder = Schedule::with(['schedulePeriod.timePeriod', 'schedulePeriod.organization'])->where('docter_id', $req['docter_id'])->where('schedule_type',1)->where('schedule_day', '>=', date('Ymd'));
|
|
|
if (!empty($req['organization_id'])) {
|
|
|
$builder->where('organization_id', $req['organization_id']);
|
|
|
}
|
| xqd
@@ -271,21 +269,33 @@ class DocterController extends AuthController
|
|
|
|
|
|
public function timePeriodList()
|
|
|
{
|
|
|
+
|
|
|
$req = request()->post();
|
|
|
$this->validate(request(), [
|
|
|
- 'organization_id' => 'required|integer',
|
|
|
+ 'docter_id' => 'required|integer',
|
|
|
+ 'organization_id' => 'integer',
|
|
|
+ 'schedule_type' => 'integer',
|
|
|
+ 'per_page' => 'integer',
|
|
|
+ 'latitude' => 'numeric',
|
|
|
+ 'longitude' => 'numeric',
|
|
|
]);
|
|
|
-
|
|
|
- $data = [];
|
|
|
- //todo 门诊排班诊与医生相关
|
|
|
- $data['list'] = TimePeriod::select(['id', 'start_time_period', 'end_time_period'])->where('org_id', $req['organization_id'])->get()->toArray();
|
|
|
-
|
|
|
- for ($i = 0; $i < 7; $i++) {
|
|
|
- if ($i > 0) {
|
|
|
- $data['dates'][] = date('Y-m-d', strtotime("+$i days"));
|
|
|
- }
|
|
|
- else {
|
|
|
- $data['dates'][] = date('Y-m-d');
|
|
|
+ $builder = Schedule::with(['schedulePeriod.timePeriod', 'schedulePeriod.organization'])->where('docter_id', $req['docter_id'])->where('schedule_type', $req['schedule_type'])->where('schedule_day', '>=', date('Ymd'));
|
|
|
+ if (!empty($req['organization_id'])) {
|
|
|
+ $builder->where('organization_id', $req['organization_id']);
|
|
|
+ }
|
|
|
+ $data = $builder->paginate($req['per_page']??15)->toArray();
|
|
|
+ if (!empty($data)) {
|
|
|
+ foreach ($data['data'] as $k => &$v) {
|
|
|
+ foreach ($v['schedule_period'] as $k1 => &$v1) {
|
|
|
+ $docterSettings = DocterSetting::select(['service_num'])->where('docter_id', $req['docter_id'])->where('type', 1)->where('org_id', $v1['organization_id'])->first();
|
|
|
+ if (empty($docterSettings)) {
|
|
|
+ $v1['can_appoint_num'] = 0;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $can_appoint_num = $docterSettings['service_num'] - $v1['order_num'];
|
|
|
+ $v1['can_appoint_num'] = $can_appoint_num < 0 ? 0 : $can_appoint_num;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|