|
@@ -14,6 +14,7 @@ class Lesson extends Api
|
|
|
// 无需鉴权的接口,*表示全部
|
|
|
protected $noNeedRight = ['*'];
|
|
|
|
|
|
+ //售课列表
|
|
|
public function lists(){
|
|
|
|
|
|
$list = Db::name('lesson')->where('is_show',1)->order('weigh desc')->autopage()->select();
|
|
@@ -23,42 +24,85 @@ class Lesson extends Api
|
|
|
$this->success(1,$list);
|
|
|
}
|
|
|
|
|
|
- public function info(){
|
|
|
- $id = input('id');
|
|
|
+ //售课套餐列表
|
|
|
+ public function package_list(){
|
|
|
+ $lesson_id = input('lesson_id',0);
|
|
|
|
|
|
- $info = Db::name('trylesson')->where('id',$id)->find();
|
|
|
- $info = info_domain_image($info,['image']);
|
|
|
- $info = $this->info_lang($info,['name','content']);
|
|
|
+ //套餐列表
|
|
|
+ $list = Db::name('lesson_package')->alias('p')
|
|
|
+ ->field('p.*,e.image')
|
|
|
+ ->join('lesson e','p.lesson_id = e.id','LEFT')
|
|
|
+ ->where('p.lesson_id',$lesson_id)
|
|
|
+ ->where('p.is_show',1)
|
|
|
+ ->order('p.weigh desc')->select();
|
|
|
+ $list = list_domain_image($list,['image']);
|
|
|
+ $list = $this->list_lang($list,['name','validity','activeremark']);
|
|
|
+
|
|
|
+ $this->success(1,$list);
|
|
|
+ }
|
|
|
|
|
|
- $info['map_image'] = localpath_to_netpath(config('site.index_bottom_image'));
|
|
|
- $info['public_store_address'] = config('site.public_store_address');
|
|
|
- $info['trylesson_cancel_text'] = config('site.trylesson_cancel_text');
|
|
|
+ //售课套餐详情
|
|
|
+ public function package_info(){
|
|
|
+ $package_id = input('package_id',0);
|
|
|
|
|
|
- $this->success(1,$info);
|
|
|
+ //套餐详情
|
|
|
+ $list = Db::name('lesson_package')->alias('p')
|
|
|
+ ->field('p.*,e.image')
|
|
|
+ ->join('lesson e','p.lesson_id = e.id','LEFT')
|
|
|
+ ->where('p.id',$package_id)
|
|
|
+ ->order('p.weigh desc')->find();
|
|
|
+ $list = info_domain_image($list,['image']);
|
|
|
+ $list = $this->info_lang($list,['name','validity','activeremark']);
|
|
|
+
|
|
|
+ $this->success(1,$list);
|
|
|
}
|
|
|
|
|
|
- public function apply(){
|
|
|
- $id = input('id',0);
|
|
|
- $info = Db::name('trylesson')->where('id',$id)->where('is_show',1)->find();
|
|
|
- if(empty($info)){
|
|
|
- $this->error('该试课已下架');
|
|
|
- }
|
|
|
+ //下单购买售课套餐
|
|
|
+ public function package_buy(){
|
|
|
+ $package_id = input('package_id',0);
|
|
|
|
|
|
- $field = ['firstname','lastname','mobile','email','height','age','weight','address','health','emergency','comefrom','is_first'];
|
|
|
- $data = request_post_hub($field);
|
|
|
+ $package_info = Db::name('lesson_package')->where('id',$package_id)->find();
|
|
|
|
|
|
- $sysdata = [
|
|
|
- 'order_no' => createUniqueNo('T',$this->auth->id),
|
|
|
- 'user_id' => $this->auth->id,
|
|
|
- 'trylesson_id' => $id,
|
|
|
- 'order_amount' => $info['price'],
|
|
|
- 'order_status' => 0,
|
|
|
- 'createtime' => time(),
|
|
|
+ //套餐
|
|
|
+ $data = [
|
|
|
+ 'order_no' => createUniqueNo('P',$this->auth->id),
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ 'package_id' => $package_id,
|
|
|
+ 'lesson_id' => $package_info['lesson_id'],
|
|
|
+ 'sessions' => $package_info['sessions'],
|
|
|
+ //'starttime' => ,
|
|
|
+ 'days' => $package_info['days'],
|
|
|
+ //'endtime' => ,
|
|
|
+ 'price' => $package_info['price'],
|
|
|
+ 'remain' => $package_info['sessions'],
|
|
|
+ 'order_status'=> 0,
|
|
|
+ 'paytime' => 0,
|
|
|
+ 'createtime' => time(),
|
|
|
+ 'updatetime' => 0,
|
|
|
+ 'is_gift' => 0,
|
|
|
];
|
|
|
|
|
|
- $data = array_merge($data,$sysdata);
|
|
|
+ //如果有赠品
|
|
|
+ if(!empty($package_info['gift_lesson_id']) && !empty($package_info['gift_sessions'])){
|
|
|
+ $gift = $data;
|
|
|
+
|
|
|
+ //订单号不换了
|
|
|
+ $gift['lesson_id'] = $package_info['gift_lesson_id'];
|
|
|
+ $gift['sessions'] = $package_info['gift_sessions'];
|
|
|
+ $gift['remain'] = $package_info['gift_sessions'];
|
|
|
+ $gift['is_gift'] = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ //支付订单下单
|
|
|
+ //写到这里了,上面已确认
|
|
|
+ $pay_order = [];
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+
|
|
|
|
|
|
- $id = Db::name('trylesson_order')->insertGetId($data);
|
|
|
- $this->success('提交成功',$id);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|