model = new ClassesLib; parent::_initialize(); //判断登录用户是否是员工 } /** * @ApiTitle(课程查询参数接口) * @ApiSummary(课程查询参数接口) * @ApiRoute(/api/school/classes/index) * @ApiMethod(GET) * @ApiReturn({ * *}) */ public function index() { //距离查询参数 //展示的城市 //展示的查询距离 $distance_config = config("site.search_distance_list"); $distance_config_data = []; foreach ($distance_config as $k=>$v){ //组成类似sql二维数组 $distance_config_data[] = ['distance'=>$k,'distance_name'=>$v]; } $distance_city = SearchCity::order("id desc")->select(); foreach ($distance_city as $k=>&$v){ //字符串按斜杠分割后,取数值最后一个元素(切记:分割后数组长度不是等长) $v["address_city"] = explode("/",$v["address_city"]); $v["address_city"] = $v["address_city"][count($v["address_city"])-1]; } $cate = Cate::showList(1, 20,"","-1"); $label = Label::showList(1, 20,""); $this->success('获取成功', compact('distance_config_data',"distance_city","cate" ,"label" )); } /** * @ApiTitle(课程详情接口) * @ApiSummary(课程详情接口) * @ApiRoute(/api/school/classes/detail) * @ApiMethod(GET) * @ApiParams(name = "id", type = "int",required=true,description = "课程id") * @ApiReturn({ * *}) */ public function detail(){ $id = $this->request->get('id/d',''); $user_id = 0; $user = $this->auth->getUser();//登录用户 if($user)$user_id = $user['id']; if(empty($id)){ $this->error(__('缺少必要参数')); } try { $res = $this->model->detail($id,$user_id); } catch (\Exception $e){ // Log::log($e->getMessage()); $this->error($e->getMessage(),['errcode'=>$e->getCode()]); } $this->success('获取成功', ['detail' => $res]); } /** * @ApiTitle(课程参与者和报名者) * @ApiSummary(课程参与者和报名者) * @ApiRoute(/api/school/classes/people) * @ApiMethod(GET) * @ApiParams(name = "id", type = "int",required=true,description = "课程id") * @ApiReturn({ unpaid_user_data 参与中 paid_user_data 已报名 }) */ public function people(){ $id = $this->request->get('id/d',''); $user_id = 0; $user = $this->auth->getUser();//登录用户 if($user)$user_id = $user['id']; if(empty($id)){ $this->error(__('缺少必要参数')); } try { $res = $this->model->virtualParticipants($id,$user_id); } catch (\Exception $e){ // Log::log($e->getMessage()); $this->error($e->getMessage(),['errcode'=>$e->getCode()]); } $this->success('获取成功', $res); } /** * @ApiTitle(课程课时规格) * @ApiSummary(课程课时规格) * @ApiRoute(/api/school/classes/spec) * @ApiMethod(GET) * @ApiParams(name = "id", type = "int",required=true,description = "课程id") * @ApiReturn({ spec 课时规格 }) */ public function spec(){ $id = $this->request->get('id/d',''); if(empty($id)){ $this->error(__('缺少必要参数')); } try { $res = $this->model->spec($id); } catch (\Exception $e){ // Log::log($e->getMessage()); $this->error($e->getMessage(),['errcode'=>$e->getCode()]); } $this->success('获取成功', ['spec'=>$res]); } /** * @ApiTitle( 课程分类列表) * @ApiSummary(课程分类列表) * @ApiRoute(/api/school/classes/cate_list) * @ApiMethod(GET) * @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字") * @ApiParams(name = "page", type = "string",required=true,description = "页数") * @ApiParams(name = "limit", type = "string",required=true,description = "条数") * @ApiParams(name = "hot", type = "string",required=false,description = "状态搜索条件:-1=全部分类,0=非热门分类,1=热门分类") * @ApiReturn({ * *}) */ public function cate_list() { $user_id = 0; $user = $this->auth->getUser();//登录用户 if($user)$user_id = $user['id']; $page = $this->request->get('page/d', 0); //页数 $limit = $this->request->get('limit/d', 0); //条数 $keywords = $this->request->get('keywords/s', ''); //搜索关键字 $hot = $this->request->get('hot/s', '-1'); //搜索关键字 // $type = $this->request->get('type/s', ''); //筛选学员和教练单 try{ //当前申请状态 $res = Cate::showList($page, $limit,$keywords,$hot); // if($user_id =='670153'){ // file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql()); // } }catch (\Exception $e){ $this->error($e->getMessage()); } $this->success('查询成功', $res); } /** * @ApiTitle( 课程标签列表) * @ApiSummary(课程标签列表) * @ApiRoute(/api/school/classes/label_list) * @ApiMethod(GET) * @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字") * @ApiParams(name = "page", type = "string",required=true,description = "页数") * @ApiParams(name = "limit", type = "string",required=true,description = "条数") * @ApiReturn({ * *}) */ public function label_list() { $user_id = 0; $user = $this->auth->getUser();//登录用户 if($user)$user_id = $user['id']; $page = $this->request->get('page/d', 0); //页数 $limit = $this->request->get('limit/d', 0); //条数 $keywords = $this->request->get('keywords/s', ''); //搜索关键字 // $type = $this->request->get('type/s', ''); //筛选学员和教练单 try{ //当前申请状态 $res = Label::showList($page, $limit,$keywords); // if($user_id =='670153'){ // file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql()); // } }catch (\Exception $e){ $this->error($e->getMessage()); } $this->success('查询成功', $res); } /** * @ApiTitle( 通用课程大索索列表) * @ApiSummary(通用课程大索索列表) * @ApiRoute(/api/school/classes/classes_list) * @ApiMethod(GET) * @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字") * @ApiParams(name = "page", type = "string",required=true,description = "页数") * @ApiParams(name = "limit", type = "string",required=true,description = "条数") * @ApiParams(name = "user_id", type = "int",required=false,description = "主讲师用户id") * @ApiParams(name = "shop_id", type = "int",required=false,description = "机构店铺id") * @ApiParams(name = "teacher_id", type = "int",required=false,description = "老师id") * @ApiParams(name = "classes_cate_ids", type = "string",required=false,description = "平台课程分类ids") * @ApiParams(name = "classes_label_ids", type = "string",required=false,description = "平台课程热门标签ids") * @ApiParams(name = "self_label_tag", type = "string",required=false,description = "机构特色标签") * @ApiParams(name = "keyword", type = "string",required=false,description = "关键字搜索") * @ApiParams(name = "type", type = "string",required=false,description = "地点类型:out=户外,in=室内") * @ApiParams(name = "address_type", type = "string",required=false,description = "地址类型:1=按机构,2=独立位置") * @ApiParams(name = "province", type = "string",required=false,description = "省编号") * @ApiParams(name = "city", type = "string",required=false,description = "市编号") * @ApiParams(name = "district", type = "string",required=false,description = "县区编号") * @ApiParams(name = "status", type = "string",required=false,description = "不传则默认查上架的 状态: 1=上架,2=下架,3=平台下架") * @ApiParams(name = "recommend", type = "string",required=false,description = "平台推荐:0=否,1=是") * @ApiParams(name = "hot", type = "string",required=false,description = "平台热门:0=否,1=是") * @ApiParams(name = "new", type = "string",required=false,description = "平台最新:0=否,1=是") * @ApiParams(name = "selfhot", type = "string",required=false,description = "机构热门:0=否,1=是") * @ApiParams(name = "feel", type = "string",required=false,description = "是否免费:0=否,1=是") * @ApiParams(name = "collect", type = "int",required=false,description = "是否专查我的收藏(需登录):1=是") * @ApiParams(name = "order", type = "string",required=false,description = " normal=综合排序推薦優先,distance=距离优先,hot=熱門优先,new=平台最新优先,selfhot=机构热门优先,sale=銷量优先") * @ApiParams(name = "nearby", type = "string",required=false,description = "限制最大搜索距离(米)") * @ApiParams(name = "latitude", type = "string",required=false,description = "latitude") * @ApiParams(name = "longitude", type = "string",required=false,description = "longitude") * @ApiReturn({ * *}) */ public function classes_list() { $user_id = 0; $user = $this->auth->getUser();//登录用户 if($user)$user_id = $user['id']; $params =[]; $params["my_user_id"] = $user_id; $params["collect"] = $this->request->get('collect/d', 0); //页数 $params["page"] = $this->request->get('page/d', 1); //页数 $params["limit"] = $this->request->get('limit/d', 10); //条数 $params["keywords"] = $this->request->get('keywords/s', ''); //搜索关键字 $params["user_id"] = $this->request->get('user_id/d', ''); //主讲师用户id $params["shop_id"] = $this->request->get('shop_id/d', ''); //机构店铺id $params["teacher_id"] = $this->request->get('teacher_id/d', ''); //机构店铺id $params["classes_cate_ids"] = $this->request->get('classes_cate_ids/s', ''); //机构店铺id $params["classes_label_ids"] = $this->request->get('classes_label_ids/s', ''); //机构店铺id $params["self_label_tag"] = $this->request->get('self_label_tag/s', ''); //机构店铺id $params["keyword"] = $this->request->get('keyword/s', ''); //机构店铺id $params["type"] = $this->request->get('type/s', ''); //机构店铺id $params["address_type"] = $this->request->get('address_type/s', ''); //机构店铺id $params["province"] = $this->request->get('province/s', ''); //机构店铺id $params["city"] = $this->request->get('city/s', ''); //机构店铺id $params["district"] = $this->request->get('district/s', ''); //机构店铺id $params["status"] = $this->request->get('status/s', ''); //机构店铺id $params["recommend"] = $this->request->get('recommend/s', ''); //机构店铺id $params["hot"] = $this->request->get('hot/s', ''); //机构店铺id $params["new"] = $this->request->get('new/s', ''); //机构店铺id $params["selfhot"] = $this->request->get('selfhot/s', ''); //机构店铺id $params["feel"] = $this->request->get('feel/s', ''); //机构店铺id $params["order"] = $this->request->get('order/s', ''); //机构店铺id $params["nearby"] = $this->request->get('nearby/s', ''); //机构店铺id $params["latitude"] = $this->request->get('latitude/s', ''); //机构店铺id $params["longitude"] = $this->request->get('longitude/s', ''); //机构店铺id // $type = $this->request->get('type/s', ''); //筛选学员和教练单 try{ //当前申请状态 $res = ClassesLib::getVaildList($params); // if($user_id =='670153'){ // file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql()); // } }catch (\Exception $e){ $this->error($e->getMessage()); } $this->success('查询成功', ["list"=>$res]); } /** * @ApiTitle( 设置课程收藏和取消收藏) * @ApiSummary(设置课程收藏和取消收藏) * @ApiRoute(/api/school/classes/collect) * @ApiMethod(POST) * @ApiParams(name = "id", type = "int",required=true,description = "课程id") * @ApiParams(name = "is_collect", type = "int",required=true,description = "收藏操作:0取消收藏,1收藏") * @ApiReturn({ * *}) */ public function collect(){ $user_id = 0; $user = $this->auth->getUser();//登录用户 if($user)$user_id = $user['id']; $id = $this->request->post('id/d', 0); //搜索关键字 $collect = $this->request->post('is_collect/d', 0); //搜索关键字 try{ $res = $this->model->collect($id,$user_id,$collect,'user',$user_id,true); }catch (\Throwable $e){ $this->error($e->getMessage()); } $this->success('查询成功', $res); } }