浏览代码

timePeriodList

Mike 4 年之前
父节点
当前提交
4cac5b2c47
共有 2 个文件被更改,包括 19 次插入2 次删除
  1. 4 0
      app/Community/Controllers/ApiController.php
  2. 15 2
      app/Http/Controllers/Api/V1/DocterController.php

+ 4 - 0
app/Community/Controllers/ApiController.php

xqd xqd xqd xqd
@@ -441,6 +441,7 @@ class ApiController extends Controller
             $scheduleData['schedule_date'] = $date;
             $scheduleData['schedule_day'] = $numDate;
             $scheduleData['schedule_type'] = $sType;
+            if($sType!=1)$scheduleData['organization_id'] = $orgId;
 
             $scheduleIsHave = Schedule::where($scheduleData)->count();
 //            $scheduleData['per_time_num'] = $serviceNum;
@@ -1021,6 +1022,7 @@ class ApiController extends Controller
                         $scheduleData['schedule_date'] = $date;
                         $scheduleData['schedule_day'] = $numDate;
                         $scheduleData['schedule_type'] = $sType;
+                        if($sType!=1)$scheduleData['organization_id'] = $orgId;
 //                        dd($scheduleData);
                         $scheduleId = Schedule::insertGetId($scheduleData);
                     }
@@ -1051,6 +1053,7 @@ class ApiController extends Controller
                         $scheduleData['schedule_date'] = $date;
                         $scheduleData['schedule_day'] = $numDate;
                         $scheduleData['schedule_type'] = $sType;
+                        if($sType!=1)$scheduleData['organization_id'] = $orgId;
 //                        dd($scheduleData);
                         $scheduleId = Schedule::insertGetId($scheduleData);
                     }
@@ -1173,6 +1176,7 @@ class ApiController extends Controller
                     //判断是否有排班信息
                     $s_id = Schedule::where($sche_data)->value('id');
                     if(!$s_id){
+                        if($sType!=1)$scheduleData['organization_id'] = $orgId;
                         $s_id = Schedule::insertGetId($sche_data);
                     }
                     //获取时间段

+ 15 - 2
app/Http/Controllers/Api/V1/DocterController.php

xqd
@@ -278,9 +278,22 @@ class DocterController extends AuthController
             'latitude' => 'numeric',
             'longitude' => 'numeric',
         ]);
-        $builder = SchedulePeriod::with(['timePeriod'])->where('organization_id', $req['organization_id'])->where('schedule_type',$req['schedule_type'])->where('', '>=', date('Ymd'))->orderBy('schedule_date');
+        $builder = Schedule::with(['schedulePeriod.timePeriod', 'schedulePeriod.organization'])->where('organization_id', $req['organization_id'])->where('schedule_type', $req['schedule_type'])->where('schedule_day', '>=', date('Ymd'));
         $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;
+                    }
+                }
+            }
+        }
         return out($data);
     }
 }