Selaa lähdekoodia

我的课时记录

lizhen_gitee 1 vuosi sitten
vanhempi
commit
167b525656
1 muutettua tiedostoa jossa 33 lisäystä ja 0 poistoa
  1. 33 0
      application/api/controller/coach/Lesson.php

+ 33 - 0
application/api/controller/coach/Lesson.php

@@ -161,7 +161,40 @@ class Lesson extends Api
         $this->success('点名完成');
         $this->success('点名完成');
     }
     }
 
 
+    //我的课时记录,点过名的
+    public function my_slot_history(){
+        $date = input('date',date('Y-m-d'),'strtotime');
+        $lesson_id = input('lesson_id',0);
+
+        $where = [
+            'slot.starttime' => ['BETWEEN',[$date,$date+86399]],
+            'slot.status' => 20,
+        ];
+        if($lesson_id){
+            $where['slot.lesson_id'] = $lesson_id;
+        }
+        //课时
+        $list = Db::name('lesson_slot')->alias('slot')
+            ->field('slot.*,lesson.name,lesson.name_en')
+            ->join('lesson','slot.lesson_id = lesson.id','LEFT')
+            ->where('slot.status',20);
+
+        $list->where('find_in_set(:coach_ids,coach_ids)', ['coach_ids' => $this->auth->id]);
 
 
+        $list = $list->order('slot.starttime asc')->select();
+        if(empty($list)){
+            $this->success(1,[]);
+        }
+        $list = $this->list_lang($list,['name']);
 
 
+        foreach($list as $key => &$slot){
+
+            //已报名数量
+            $pay_number = Db::name('lesson_order')->where('slot_id',$slot['id'])->where('order_status',20)->sum('usernumber');
+            $slot['usernumber'] = $pay_number;
+        }
+
+        $this->success(1,$list);
+    }
 
 
 }
 }