|
@@ -24,6 +24,104 @@ class Lesson extends Api
|
|
|
$this->success(1,$list);
|
|
|
}
|
|
|
|
|
|
+ //教练列表
|
|
|
+ public function coach_list(){
|
|
|
+ $list = Db::name('coach')->field('id,nickname')->where('status',1)->order('nickname asc')->select();
|
|
|
+ $this->success(1,$list);
|
|
|
+ }
|
|
|
+
|
|
|
+ //课时首页
|
|
|
+ public function slot_list(){
|
|
|
+
|
|
|
+ $date = input('date',date('Y-m-d'),'strtotime');
|
|
|
+ $lesson_id = input('lesson_id',0);
|
|
|
+ $coach_id = input('coach_id',0);
|
|
|
+
|
|
|
+ $where = [
|
|
|
+ 'slot.starttime' => ['BETWEEN',[$date,$date+864010]],
|
|
|
+ ];
|
|
|
+ if($lesson_id){
|
|
|
+ $where['slot.lesson_id'] = $lesson_id;
|
|
|
+ }
|
|
|
+
|
|
|
+ //课时
|
|
|
+ $list = Db::name('lesson_slot')->alias('slot')
|
|
|
+ ->field('slot.*,lesson.name,lesson.name_en,lesson.image,lesson.price')
|
|
|
+ ->join('lesson','slot.lesson_id = lesson.id','LEFT')
|
|
|
+ ->where($where);
|
|
|
+ if($coach_id){
|
|
|
+ $list->where('find_in_set(:coach_ids,coach_ids)', ['coach_ids' => $coach_id]);
|
|
|
+ }
|
|
|
+ $list = $list->order('slot.starttime asc')->select();
|
|
|
+ if(empty($list)){
|
|
|
+ $this->success(1,[]);
|
|
|
+ }
|
|
|
+ $list = list_domain_image($list,['image']);
|
|
|
+ $list = $this->list_lang($list,['name']);
|
|
|
+
|
|
|
+ //准备教练数据
|
|
|
+ $coach_list = Db::name('coach')->column('id,nickname');
|
|
|
+
|
|
|
+ foreach($list as $key => &$slot){
|
|
|
+ //放入教练
|
|
|
+ $coach_text = '';
|
|
|
+ $coach_ids = explode(',',$slot['coach_ids']);
|
|
|
+ foreach($coach_ids as $coach_id){
|
|
|
+ $coach_text .= $coach_list[$coach_id].',';
|
|
|
+ }
|
|
|
+ $slot['coach_text'] = substr($coach_text,0,-1);
|
|
|
+
|
|
|
+ //剩余空位数量
|
|
|
+ $pay_number = Db::name('lesson_order')->where('slot_id',$slot['id'])->where('order_status',10)->sum('usernumber');
|
|
|
+ $slot['num_remain'] = $slot['num_max'] - $pay_number;
|
|
|
+
|
|
|
+ //右上角备注
|
|
|
+ if(time() >= $slot['starttime']){
|
|
|
+ $slot['num_remark'] = '报名已截止';
|
|
|
+ }else{
|
|
|
+ $slot['num_remark'] = '剩'.$slot['num_remain'].'空位';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success(1,$list);
|
|
|
+ }
|
|
|
+
|
|
|
+ //课时详情
|
|
|
+ public function slot_info(){
|
|
|
+ $slot_id = input('slot_id',0);
|
|
|
+
|
|
|
+ //课时
|
|
|
+ $info = Db::name('lesson_slot')->alias('slot')
|
|
|
+ ->field('slot.*,lesson.name,lesson.name_en,lesson.image,lesson.price')
|
|
|
+ ->join('lesson','slot.lesson_id = lesson.id','LEFT')
|
|
|
+ ->where('slot.id',$slot_id)->find();
|
|
|
+ if(empty($info)){
|
|
|
+ $this->error('课程可能已取消,请刷新重试');
|
|
|
+ }
|
|
|
+
|
|
|
+ $info = info_domain_image($info,['image']);
|
|
|
+ $info = $this->info_lang($info,['name']);
|
|
|
+
|
|
|
+ //准备教练数据
|
|
|
+ $coach_list = Db::name('coach')->where('id','IN',$info['coach_ids'])->column('nickname');
|
|
|
+ $info['coach_text'] = implode(',',$coach_list);
|
|
|
+
|
|
|
+ //剩余空位数量
|
|
|
+ $pay_number = Db::name('lesson_order')->where('slot_id',$info['id'])->where('order_status',10)->sum('usernumber');
|
|
|
+ $info['num_remain'] = $info['num_max'] - $pay_number;
|
|
|
+
|
|
|
+ $this->success(1,$info);
|
|
|
+ }
|
|
|
+
|
|
|
+ //课时申请报名
|
|
|
+ public function slot_apply(){
|
|
|
+ $slot_id = input('slot_id',0);
|
|
|
+ $number = input('number',1);
|
|
|
+ $remark = input('remark','');
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ }
|
|
|
+
|
|
|
//售课套餐列表
|
|
|
public function package_list(){
|
|
|
$lesson_id = input('lesson_id',0);
|