瀏覽代碼

Bug fixed

Mike 4 年之前
父節點
當前提交
8b470f39e5
共有 1 個文件被更改,包括 7 次插入4 次删除
  1. 7 4
      app/Community/Controllers/ApiController.php

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

xqd xqd
@@ -457,10 +457,7 @@ class ApiController extends Controller
 //        echo '医生id '.$docterId.' 机构id '.$orgId . 'times ';
         $schedule = Schedule::where(['docter_id'=>$docterId,'organization_id'=>$orgId])->where('schedule_date','>=',date('Y-m-d',time()))
             ->distinct('schedule_date')->pluck('schedule_date','id')->toArray();
-        if($docterId == 0){
-            $schedule = Schedule::where(['docter_id'=>0,'organization_id'=>$orgId])->where('schedule_date','>=',date('Y-m-d',time()))
-                ->distinct('schedule_date')->pluck('schedule_date','id')->toArray();
-        }
+
         $allData = [];
         for($tType = 1; $tType<=3 ; $tType++){
             foreach ($schedule as $id => $date) {
@@ -490,6 +487,12 @@ class ApiController extends Controller
         }
 
         if($allData) SchedulePeriod::insert($allData);
+
+        //删除 Schedule里面SchedulePeriod 没有的日期
+        foreach ($schedule as $date) {
+            $c = SchedulePeriod::where(['docter_id'=>$docterId,'organization_id'=>$orgId])->where('schedule_date',$date)->count();
+            if($c==0) Schedule::where('schedule_date',$date)->delete();
+        }
         return apiReturn('200','ok');
 
     }