|
@@ -39,6 +39,7 @@ class Lesson extends Api
|
|
|
|
|
|
$where = [
|
|
|
'slot.starttime' => ['BETWEEN',[$date,$date+86399]],
|
|
|
+ 'slot.status' => 0
|
|
|
];
|
|
|
if($lesson_id){
|
|
|
$where['slot.lesson_id'] = $lesson_id;
|
|
@@ -131,6 +132,8 @@ class Lesson extends Api
|
|
|
|
|
|
//课时申请报名
|
|
|
public function slot_apply(){
|
|
|
+ $this->apiLimit();
|
|
|
+
|
|
|
$slot_id = input('slot_id',0,'intval');
|
|
|
$number = input('number',1,'intval');
|
|
|
$remark = input('remark','','trim');
|
|
@@ -147,7 +150,7 @@ class Lesson extends Api
|
|
|
$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();
|
|
|
+ ->where('slot.id',$slot_id)->where('slot.status',0)->find();
|
|
|
if(empty($info)){
|
|
|
$this->error('课程可能已取消,请刷新重试');
|
|
|
}
|
|
@@ -155,6 +158,15 @@ class Lesson extends Api
|
|
|
$this->error('课程已经结束了,不能再进行预约');
|
|
|
}
|
|
|
|
|
|
+ //报名人数不能超限
|
|
|
+ if($info['num_max' > 0]){
|
|
|
+ $pay_number = Db::name('lesson_order')->where('slot_id',$slot_id)->where('order_status',10)->sum('usernumber');
|
|
|
+ $num_remain = $info['num_max'] - $pay_number;
|
|
|
+ if($num_remain < $number){
|
|
|
+ $this->error('报名名额只剩'.$num_remain.'名');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$lesson_order = [
|
|
|
'order_no' => createUniqueNo('S',$this->auth->id),
|
|
|
'user_id' => $this->auth->id,
|