Procházet zdrojové kódy

医生端,排班

lizhen_gitee před 10 měsíci
rodič
revize
0fe96db71f

+ 59 - 0
application/api/controller/doctor/Index.php

@@ -18,7 +18,66 @@ class Index extends Apic
     protected $noNeedRight = '*';
 
 
+    public function paiban_info(){
+        $today = date('Y-m-d');
+        $today_start = strtotime(date('Y-m-d'));
 
+        //本周
+        $this_week = this_week();
+
+        //医生排班
+        $paiban = Db::name('doctor_paiban')->where('doctor_id',$this->auth->id)->where('activetime','BETWEEN',$this_week)->order('activetime asc')->column('activetime,active');
+        //dump($paiban);
+        //组合数据
+        $week_text = [1=>'周一',2=>'周二',3=>'周三',4=>'周四',5=>'周五',6=>'周六',7=>'周日'];
+
+        $week_data = [];
+        for($i=1;$i<=7;$i++){
+            $i_time = $this_week[0] + 86400*($i-1);
+            $i_data = [
+                'time'      => $i_time,
+                'date'      => date('Y-m-d',$i_time),
+                'date_text' => date('d日',$i_time),
+                'week'      => date('w',$i_time),
+                'is_today'  => 0,
+            ];
+
+            if($i_data['date'] == $today){
+                $i_data['is_today'] = 1;
+            }
+            if($i_data['week'] == 0){
+                $i_data['week'] = 7;
+            }
+            $i_data['week_text'] = $week_text[$i_data['week']];
+
+            //今天各整点
+            $i_child = [];
+            for($y=8;$y<=20;$y++){
+                $y_hour = $i_time + $y*3600;
+                $child = [
+                    'time' => $y_hour,
+                    'date' => date('Y-m-d H:i',$y_hour),
+                    'date_text' => date('H:i',$y_hour),
+                    'active' => 0,
+                ];
+
+                if(isset($paiban[$y_hour]) && $paiban[$y_hour] == 1){
+                    $child['active'] = 1;
+                }
+
+                $i_child[] = $child;
+            }
+            $i_data['child'] = $i_child;
+
+            //
+            $week_data[] = $i_data;
+        }
+
+        //dump($week_data);
+        $this->success(1,$week_data);
+
+
+    }
 
 
 

+ 4 - 4
application/common.php

@@ -793,13 +793,13 @@ if (!function_exists('day_yesterday')) {
         return $arr;
     }
 }
-if (!function_exists('week_now')) {
+if (!function_exists('this_week')) {
     //获取当前时间的本周开始结束时间
-    function week_now()
+    function this_week()
     {
         $arr = [
-            strtotime(date('Y-m-d', strtotime("+0 week Monday", time()))),
-            strtotime(date('Y-m-d', strtotime("+0 week Sunday", time())))
+            strtotime('Monday this week'),
+            strtotime('Sunday this week'),
         ];
 
         return $arr;