12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- /**
- * 试课
- */
- class Trylesson extends Api
- {
- // 无需登录的接口,*表示全部
- protected $noNeedLogin = [];
- // 无需鉴权的接口,*表示全部
- protected $noNeedRight = ['*'];
- public function lists(){
- $list = Db::name('trylesson')->where('is_show',1)->order('weigh desc')->autopage()->select();
- $list = list_domain_image($list,['image']);
- $list = $this->list_lang($list,['name','content']);
- $this->success(1,$list);
- }
- public function info(){
- $id = input('id');
- $info = Db::name('trylesson')->where('id',$id)->find();
- $info = info_domain_image($info,['image']);
- $info = $this->info_lang($info,['name','content']);
- $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');
- $this->success(1,$info);
- }
- public function apply(){
- $id = input('id',0);
- $info = Db::name('trylesson')->where('id',$id)->where('is_show',1)->find();
- if(empty($info)){
- $this->error('该试课已下架');
- }
- $field = ['firstname','lastname','mobile','email','height','age','weight','address','health','emergency','comefrom','is_first'];
- $data = request_post_hub($field);
- $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 = array_merge($data,$sysdata);
- $id = Db::name('trylesson_order')->insertGetId($data);
- $this->success('提交成功',$id);
- }
- }
|