DiverseYouthNightSchool/application/api/controller/school/Shop.php

237 lines
9.1 KiB
PHP

<?php
namespace app\api\controller\school;
use app\common\model\dyqc\ManystoreShop;
/**
* 机构接口
*/
class Shop extends Base
{
protected $noNeedLogin = ["detail",'people','spec','shop_list'];
protected $noNeedRight = '*';
protected $model = null;
/**
* 初始化操作
* @access protected
*/
protected function _initialize()
{
$this->model = new ManystoreShop;
parent::_initialize();
//判断登录用户是否是员工
}
/**
* @ApiTitle( 机构详情)
* @ApiSummary(机构详情)
* @ApiRoute(/api/school/shop/detail)
* @ApiMethod(GET)
* @ApiParams(name = "id", type = "int",required=true,description = "机构id")
* @ApiReturn({
*
*})
*/
public function detail(){
$id = $this->request->get('id/d','');
if(empty($id)){
$this->error(__('缺少必要参数'));
}
try {
$res = $this->model->detail($id);
} catch (\Exception $e){
// Log::log($e->getMessage());
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
$this->success('获取成功', ['detail' => $res]);
}
/** 机构申请
* @ApiTitle( 机构申请)
* @ApiSummary(机构申请)
* @ApiRoute(/api/school/shop/shopapply)
* @ApiMethod(POST)
* @ApiParams(name = "name", type = "string",required=true,description = "机构名称")
* @ApiParams(name = "tel", type = "string",required=false,description = "服务电话(非必填)")
* @ApiParams(name = "desc", type = "string",required=false,description = "申请备注(非必填)")
* @ApiParams(name = "front_idcard_image", type = "string",required=true,description = "法人身份证正面")
* @ApiParams(name = "reverse_idcard_image", type = "string",required=true,description = "法人身份证反面")
* @ApiParams(name = "images", type = "string",required=true,description = "机构环境照片(多个逗号拼接)")
* @ApiParams(name = "yyzz_images", type = "string",required=true,description = "营业执照照片(多个逗号拼接)")
* @ApiReturn({
*
*})
*/
public function shopapply(){
$params=[];
$params["name"] = $this->request->post('name/s','');
$params["tel"] = $this->request->post('tel/s','');
$params["desc"] = $this->request->post('desc/s','');
$params["front_idcard_image"] = $this->request->post('front_idcard_image/s','');
$params["reverse_idcard_image"] = $this->request->post('reverse_idcard_image/s','');
$params["images"] = $this->request->post('images/s','');
$params["yyzz_images"] = $this->request->post('yyzz_images/s','');
// if(empty($id)){
// $this->error(__('缺少必要参数'));
// }
$type = "2";
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
try {
$res = $this->model->apply($type,$user_id,$params,true,true);
} catch (\Exception $e){
// Log::log($e->getMessage());
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
$this->success('获取成功', ['detail' => $res]);
}
/** 个人申请
* @ApiTitle( 个人申请)
* @ApiSummary(个人申请)
* @ApiRoute(/api/school/shop/userapply)
* @ApiMethod(POST)
* @ApiParams(name = "name", type = "string",required=true,description = "姓名")
* @ApiParams(name = "tel", type = "string",required=false,description = "服务电话(非必填)")
* @ApiParams(name = "desc", type = "string",required=false,description = "申请备注(非必填)")
* @ApiParams(name = "front_idcard_image", type = "string",required=true,description = "身份证正面")
* @ApiParams(name = "reverse_idcard_image", type = "string",required=true,description = "身份证反面")
* @ApiReturn({
*
*})
*/
public function userapply(){
$params=[];
$params["name"] = $this->request->post('name/s','');
$params["tel"] = $this->request->post('tel/s','');
$params["desc"] = $this->request->post('desc/s','');
$params["front_idcard_image"] = $this->request->post('front_idcard_image/s','');
$params["reverse_idcard_image"] = $this->request->post('reverse_idcard_image/s','');
// if(empty($id)){
// $this->error(__('缺少必要参数'));
// }
$type = "1";
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
try {
$res = $this->model->apply($type,$user_id,$params,true,true);
} catch (\Exception $e){
// Log::log($e->getMessage());
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
$this->success('获取成功', ['detail' => $res]);
}
/**
* @ApiTitle(机构申请状态)
* @ApiSummary(机构申请状态)
* @ApiRoute(/api/school/shop/auth_info)
* @ApiMethod(GET)
*/
public function auth_info(){
try {
$res = ManystoreShop::getAuthInfo($this->auth->id);
} catch (\Exception $e){
// Log::log($e->getMessage());
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
$this->success('获取成功', $res);
}
/**
* @ApiTitle( 通用机构大索索列表)
* @ApiSummary(通用机构大索索列表)
* @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 = "keyword", type = "string",required=false,description = "关键字搜索")
* @ApiParams(name = "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 = "不传则默认查上架的 审核状态:0=待审核,1=审核通过,2=审核失败")
* @ApiParams(name = "order", type = "string",required=false,description = " normal=综合排序優先,distance=距离优先")
* @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 shop_list()
{
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
$params =[];
$params["my_user_id"] = $user_id;
$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["id"] = $this->request->get('shop_id/d', ''); //机构店铺id
$params["teacher_id"] = $this->request->get('teacher_id/d', ''); //机构店铺id
$params["keyword"] = $this->request->get('keyword/s', ''); //机构店铺id
$params["type"] = $this->request->get('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["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 = $this->model::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]);
}
}