<?php

namespace app\manystoreapi\controller;

use app\common\controller\ManystoreApiBase;
use app\common\model\school\classes\activity\Activity as ActivityModel;
use app\common\model\school\classes\activity\ActivityAuth as ActivityAuthModel;

/**
 * 机构API后台：机构活动和审核活动管理
 *
 *
 */
class Activity extends ManystoreApiBase
{

    protected $model = null;
    protected $auth_model = null;

    /**
     * 初始化操作
     * @access protected
     */
    public function _initialize()
    {

        $this->model = new ActivityModel;
        $this->auth_model = new ActivityAuthModel;
        parent::_initialize();

//        //判断登录用户是否是员工
//        $this->setUrlLock();
        // 判断员工权限
        $this->check_worker_auth();
    }







    /**
     *
     * @ApiTitle( 活动跳转链接)
     * @ApiSummary(活动跳转链接)
     * @ApiMethod(GET)
     * @ApiParams(name = "id", type = "int",required=true,description = "活动id")
     * @ApiReturn({
     *
     *})
     */
    public function url($ids = ''){
        $param = $this->request->param();
        if($this->request->isPost()){
            try{
                if(isset($param['ids']))$ids = $param['id'];
                //设置模拟资格
                $url =  ActivityModel::getPath($ids);

            }catch (\Exception $e){
                $this->apierror($e->getMessage());
            }
            $this->apisuccess($url);
        }
    }




    /**
     *
     * @ApiTitle( 活动微信小程序码)
     * @ApiSummary(活动微信小程序码)
     * @ApiMethod(GET)
     * @ApiParams(name = "id", type = "int",required=true,description = "活动id")
     * @ApiReturn({
     *
     *})
     */
    public function miniqrcode($ids = ''){
        $param = $this->request->param();
        try{
            if(isset($param['ids']))$ids = $param['id'];
            //设置模拟资格
            $url =  ActivityModel::getMiniQrcodeLink($ids);

        }catch (\Exception $e){
            $this->apierror($e->getMessage());
        }

        return $url["response"];
    }







    /**
     * @ApiTitle(活动添加)
     * @ApiSummary(活动添加)
     * @ApiMethod(POST)
     * @ApiParams(name = "status", type = "string",required=true,description = "上架状态:1=上架,2=下架,3=平台下架")
     * @ApiParams(name = "title", type = "string",required=true,description = "活动标题")
     * @ApiParams(name = "headimage", type = "string",required=true,description = "活动头图")
     * @ApiParams(name = "images", type = "string",required=true,description = "活动轮播图多值逗号拼接")
     * @ApiParams(name = "type", type = "string",required=true,description = "地点类型:out=户外,in=室内")
     * @ApiParams(name = "item_json", type = "string",required=true,description = "活动多规格：[{'id':17,'classes_activity_id':10,'name':'xxxxx','price':'0.00','age':'18-60','sex':'3','limit_num':30,'status':'1','weigh':1}] ")
     * @ApiParams(name = "address_type", type = "string",required=true,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 = "address", type = "string",required=false,description = "地图定位地址")
     * @ApiParams(name = "address_detail", type = "string",required=false,description = "手录详细地址")
     * @ApiParams(name = "longitude", type = "string",required=false,description = "经度")
     * @ApiParams(name = "latitude", type = "string",required=false,description = "纬度")
     * @ApiParams(name = "content", type = "string",required=false,description = "活动详情")
     * @ApiParams(name = "time", type = "string",required=false,description = "活动开始结束时间 Y/m/d H:M:S-Y/m/d H:M:S ")
     * @ApiParams(name = "sign_time", type = "string",required=false,description = "活动報名开始结束时间 Y/m/d H:M:S-Y/m/d H:M:S ")
     * @ApiParams(name = "price", type = "string",required=false,description = "活动參考价格")
     * @ApiParams(name = "selfhot", type = "string",required=false,description = "机构热门:0=否,1=是")
     * @ApiReturn({
     *
     *})
     */
    public function add(){
        $user_id = 0;
        $user = $this->auth->getUser();//登录用户
        if($user)$user_id = $user['id'];
        $params = [];
        $params["status"] =  $this->request->post('status/s', 0); //上架状态:1=上架,2=下架,3=平台下架
        $params["title"] =  $this->request->post('title/s', ''); //老师id
        $params["headimage"] =  $this->request->post('headimage/s', ''); //老师id
        $params["images"] =  $this->request->post('images/s', ''); //老师id
        $params["type"] =  $this->request->post('type/s', ''); //老师id
        $params["item_json"] =  $this->request->post('item_json/s', ''); //老师id

        $params["address_type"] =  $this->request->post('address_type/s', ''); //老师id
        $params["province"] =  $this->request->post('province/d', 0); //老师id
        $params["city"] =  $this->request->post('city/d', 0); //老师id
        $params["district"] =  $this->request->post('district/d', 0); //老师id
        $params["address"] =  $this->request->post('address/s', ''); //老师id
        $params["address_detail"] =  $this->request->post('address_detail/s', ''); //老师id
        $params["longitude"] =  $this->request->post('longitude/s', 0); //老师id
        $params["latitude"] =  $this->request->post('latitude/s', 0); //老师id
        $params["content"] =  $this->request->post('content/s', ''); //老师id
        $params["time"] =  $this->request->post('time/s', ''); //老师id
        $params["sign_time"] =  $this->request->post('sign_time/s', ''); //老师id
        $params["price"] =  $this->request->post('price/f', 0); //老师id
        $params["selfhot"] =  $this->request->post('selfhot/s', ''); //老师id


        //classes_type

        try{
            $res = $this->auth_model->createActivityAuthByOper($params,true,'shop',$user_id,true);
        }catch (\Throwable $e){
            $this->apierror($e->getMessage());
        }
        $this->apisuccess('添加成功', $res);
    }






    /**
     * @ApiTitle(活动编辑)
     * @ApiSummary(活动编辑)
     * @ApiMethod(POST)
     * @ApiParams(name = "id", type = "string",required=true,description = "活动id")
     * @ApiParams(name = "status", type = "string",required=true,description = "上架状态:1=上架,2=下架,3=平台下架")
     * @ApiParams(name = "title", type = "string",required=true,description = "活动标题")
     * @ApiParams(name = "headimage", type = "string",required=true,description = "活动头图")
     * @ApiParams(name = "images", type = "string",required=true,description = "活动轮播图多值逗号拼接")
     * @ApiParams(name = "type", type = "string",required=true,description = "地点类型:out=户外,in=室内")
     * @ApiParams(name = "item_json", type = "string",required=true,description = "活动多规格：[{'id':17,'classes_activity_id':10,'name':'xxxxx','price':'0.00','age':'18-60','sex':'3','limit_num':30,'status':'1','weigh':1}] ")
     * @ApiParams(name = "address_type", type = "string",required=true,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 = "address", type = "string",required=false,description = "地图定位地址")
     * @ApiParams(name = "address_detail", type = "string",required=false,description = "手录详细地址")
     * @ApiParams(name = "longitude", type = "string",required=false,description = "经度")
     * @ApiParams(name = "latitude", type = "string",required=false,description = "纬度")
     * @ApiParams(name = "content", type = "string",required=false,description = "活动详情")
     * @ApiParams(name = "time", type = "string",required=false,description = "活动开始结束时间 Y/m/d H:M:S-Y/m/d H:M:S ")
     * @ApiParams(name = "sign_time", type = "string",required=false,description = "活动報名开始结束时间 Y/m/d H:M:S-Y/m/d H:M:S ")
     * @ApiParams(name = "price", type = "string",required=false,description = "活动參考价格")
     * @ApiParams(name = "selfhot", type = "string",required=false,description = "机构热门:0=否,1=是")
     * @ApiReturn({
     *
     *})
     */
    public function edit(){
        $user_id = 0;
        $user = $this->auth->getUser();//登录用户
        if($user)$user_id = $user['id'];
        $params = [];
        $id =  $this->request->post('id/d', 0);
        $params["status"] =  $this->request->post('status/s', 0); //上架状态:1=上架,2=下架,3=平台下架
        $params["title"] =  $this->request->post('title/s', ''); //老师id
        $params["headimage"] =  $this->request->post('headimage/s', ''); //老师id
        $params["images"] =  $this->request->post('images/s', ''); //老师id
        $params["type"] =  $this->request->post('type/s', ''); //老师id
        $params["item_json"] =  $this->request->post('item_json/s', ''); //老师id

        $params["address_type"] =  $this->request->post('address_type/s', ''); //老师id
        $params["province"] =  $this->request->post('province/d', 0); //老师id
        $params["city"] =  $this->request->post('city/d', 0); //老师id
        $params["district"] =  $this->request->post('district/d', 0); //老师id
        $params["address"] =  $this->request->post('address/s', ''); //老师id
        $params["address_detail"] =  $this->request->post('address_detail/s', ''); //老师id
        $params["longitude"] =  $this->request->post('longitude/s', 0); //老师id
        $params["latitude"] =  $this->request->post('latitude/s', 0); //老师id
        $params["content"] =  $this->request->post('content/s', ''); //老师id
        $params["time"] =  $this->request->post('time/s', ''); //老师id
        $params["sign_time"] =  $this->request->post('sign_time/s', ''); //老师id
        $params["price"] =  $this->request->post('price/f', 0); //老师id
        $params["selfhot"] =  $this->request->post('selfhot/s', ''); //老师id


        //classes_type

        try{
            $res = $this->model->updateActivityByOper($params,$id,true,'shop',$user_id,true);
        }catch (\Throwable $e){
            $this->apierror($e->getMessage());
        }
        $this->apisuccess('编辑成功', $res);
    }




    /**
     * @ApiTitle(审核活动编辑)
     * @ApiSummary(审核活动编辑)
     * @ApiMethod(POST)
     * @ApiParams(name = "id", type = "string",required=true,description = "审核活动id")
     * @ApiParams(name = "status", type = "string",required=true,description = "上架状态:1=上架,2=下架,3=平台下架")
     * @ApiParams(name = "title", type = "string",required=true,description = "活动标题")
     * @ApiParams(name = "headimage", type = "string",required=true,description = "活动头图")
     * @ApiParams(name = "images", type = "string",required=true,description = "活动轮播图多值逗号拼接")
     * @ApiParams(name = "type", type = "string",required=true,description = "地点类型:out=户外,in=室内")
     * @ApiParams(name = "item_json", type = "string",required=true,description = "活动多规格：[{'id':17,'classes_activity_id':10,'name':'xxxxx','price':'0.00','age':'18-60','sex':'3','limit_num':30,'status':'1','weigh':1}] ")
     * @ApiParams(name = "address_type", type = "string",required=true,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 = "address", type = "string",required=false,description = "地图定位地址")
     * @ApiParams(name = "address_detail", type = "string",required=false,description = "手录详细地址")
     * @ApiParams(name = "longitude", type = "string",required=false,description = "经度")
     * @ApiParams(name = "latitude", type = "string",required=false,description = "纬度")
     * @ApiParams(name = "content", type = "string",required=false,description = "活动详情")
     * @ApiParams(name = "time", type = "string",required=false,description = "活动开始结束时间 Y/m/d H:M:S-Y/m/d H:M:S ")
     * @ApiParams(name = "sign_time", type = "string",required=false,description = "活动報名开始结束时间 Y/m/d H:M:S-Y/m/d H:M:S ")
     * @ApiParams(name = "price", type = "string",required=false,description = "活动參考价格")
     * @ApiParams(name = "selfhot", type = "string",required=false,description = "机构热门:0=否,1=是")
     * @ApiReturn({
     *
     *})
     */
    public function authedit(){
        $user_id = 0;
        $user = $this->auth->getUser();//登录用户
        if($user)$user_id = $user['id'];
        $params = [];
        $id =  $this->request->post('id/d', 0);
        $params["status"] =  $this->request->post('status/s', 0); //上架状态:1=上架,2=下架,3=平台下架
        $params["title"] =  $this->request->post('title/s', ''); //老师id
        $params["headimage"] =  $this->request->post('headimage/s', ''); //老师id
        $params["images"] =  $this->request->post('images/s', ''); //老师id
        $params["type"] =  $this->request->post('type/s', ''); //老师id
        $params["item_json"] =  $this->request->post('item_json/s', ''); //老师id

        $params["address_type"] =  $this->request->post('address_type/s', ''); //老师id
        $params["province"] =  $this->request->post('province/d', 0); //老师id
        $params["city"] =  $this->request->post('city/d', 0); //老师id
        $params["district"] =  $this->request->post('district/d', 0); //老师id
        $params["address"] =  $this->request->post('address/s', ''); //老师id
        $params["address_detail"] =  $this->request->post('address_detail/s', ''); //老师id
        $params["longitude"] =  $this->request->post('longitude/s', 0); //老师id
        $params["latitude"] =  $this->request->post('latitude/s', 0); //老师id
        $params["content"] =  $this->request->post('content/s', ''); //老师id
        $params["time"] =  $this->request->post('time/s', ''); //老师id
        $params["sign_time"] =  $this->request->post('sign_time/s', ''); //老师id
        $params["price"] =  $this->request->post('price/f', 0); //老师id
        $params["selfhot"] =  $this->request->post('selfhot/s', ''); //老师id


        //classes_type

        try{
            $res = $this->auth_model->updateActivityAuthByOper($params,$id,true,'shop',$user_id,true);
        }catch (\Throwable $e){
            $this->apierror($e->getMessage());
        }
        $this->apisuccess('编辑成功', $res);
    }





    /**
     * @ApiTitle(活动批量删除)
     * @ApiSummary(活动批量删除)
     * @ApiMethod(POST)
     * @ApiParams(name = "ids", type = "string",required=true,description = "需要删除的一组活动id，多值逗号拼接")
     * @ApiReturn({
     *
     *})
     */
    public function del(){
        $user_id = 0;
        $user = $this->auth->getUser();//登录用户
        if($user)$user_id = $user['id'];

        $ids =  $this->request->post('ids/s', '');

        try{
            $res = $this->model->deleteActivityByOper($ids,true,'shop',$user_id,true);
        }catch (\Throwable $e){
            $this->apierror($e->getMessage());
        }
        $this->apisuccess("成功删除{$res}条数据",["delete_number"=>$res]);
    }




    /**
     * @ApiTitle(审核活动批量删除)
     * @ApiSummary(审核活动批量删除)
     * @ApiMethod(POST)
     * @ApiParams(name = "ids", type = "string",required=true,description = "需要删除的一组审核活动id，多值逗号拼接")
     * @ApiReturn({
     *
     *})
     */
    public function authdel(){
        $user_id = 0;
        $user = $this->auth->getUser();//登录用户
        if($user)$user_id = $user['id'];

        $ids =  $this->request->post('ids/s', '');

        try{
            $res = $this->auth_model->deleteActivityAuthByOper($ids,true,'shop',$user_id,true);
        }catch (\Throwable $e){
            $this->apierror($e->getMessage());
        }
        $this->apisuccess("成功删除{$res}条数据",["delete_number"=>$res]);
    }




    /**
     * @ApiTitle(活动更改状态)
     * @ApiSummary(活动更改状态)
     * @ApiMethod(POST)
     * @ApiParams(name = "id", type = "string",required=true,description = "需要更改状态的活动id")
     * @ApiParams(name = "status", type = "string",required=true,description = "需要更改状态:1=上架,2=下架")
     * @ApiReturn({
     *
     *})
     */
    public function update_status(){
        $user_id = 0;
        $user = $this->auth->getUser();//登录用户
        if($user)$user_id = $user['id'];

        $id =  $this->request->post('id/s', '');
        $status =  $this->request->post('status/s', '');
        try{
            $res = $this->model->updateStatusByOper($status,$id,true,'shop',$user_id,true);
        }catch (\Throwable $e){
            $this->apierror($e->getMessage());
        }
        $this->apisuccess("状态更改成功",["self"=>$res]);
    }



    /**
     * @ApiTitle(活动详情接口)
     * @ApiSummary(活动详情接口)
     * @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->apierror(__('缺少必要参数'));
        }

        try {
            $res =  $this->model->detail($id,$user_id);
        } catch (\Exception $e){
//            Log::log($e->getMessage());
            $this->apierror($e->getMessage(),['errcode'=>$e->getCode()]);
        }
        $this->apisuccess('获取成功', ['detail' => $res]);
    }



    /**
     * @ApiTitle(审核活动详情接口)
     * @ApiSummary(审核活动详情接口)
     * @ApiMethod(GET)
     * @ApiParams(name = "id", type = "int",required=true,description = "审核活动id")
     * @ApiReturn({

     *
     *})
     */
    public function authdetail(){
        $id = $this->request->get('id/d','');
        $user_id = 0;
        $user = $this->auth->getUser();//登录用户
//        if($user)$user_id = $user['id'];
        if(empty($id)){
            $this->apierror(__('缺少必要参数'));
        }

        try {
            $res =  $this->auth_model->detail($id,$user_id);
        } catch (\Exception $e){
//            Log::log($e->getMessage());
            $this->apierror($e->getMessage(),['errcode'=>$e->getCode()]);
        }
        $this->apisuccess('获取成功', ['detail' => $res]);
    }




    /**
     * @ApiTitle(活动规格)
     * @ApiSummary(活动规格)
     * @ApiMethod(GET)
     * @ApiParams(name = "id", type = "int",required=true,description = "活动id")
     * @ApiReturn({  })
     */
    public function spec(){
        $id = $this->request->get('id/d','');
        $user = $this->auth->getUser();//登录用户

        if(empty($id)){
            $this->apierror(__('缺少必要参数'));
        }

        try {


            $res =  $this->model->spec($id);
        } catch (\Exception $e){
//            Log::log($e->getMessage());
            $this->apierror($e->getMessage(),['errcode'=>$e->getCode()]);
        }
        $this->apisuccess('获取成功', ['spec'=>$res]);
    }



    /**
     * @ApiTitle(审核活动规格)
     * @ApiSummary(审核活动规格)
     * @ApiMethod(GET)
     * @ApiParams(name = "id", type = "int",required=true,description = "审核活动id")
     * @ApiReturn({  })
     */
    public function authspec(){
        $id = $this->request->get('id/d','');
        $user = $this->auth->getUser();//登录用户

        if(empty($id)){
            $this->apierror(__('缺少必要参数'));
        }

        try {


            $res =  $this->auth_model->spec($id);
        } catch (\Exception $e){
//            Log::log($e->getMessage());
            $this->apierror($e->getMessage(),['errcode'=>$e->getCode()]);
        }
        $this->apisuccess('获取成功', ['spec'=>$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 = "start_time", type = "int",required=false,description = "开始时间10位秒级时间戳")
     * @ApiParams(name = "end_time", type = "int",required=false,description = "结束时间10位秒级时间戳")
     * @ApiParams(name = "sign_start_time", type = "int",required=false,description = "报名开始时间10位秒级时间戳")
     * @ApiParams(name = "sign_end_time", type = "int",required=false,description = "报名结束时间10位秒级时间戳")
     * @ApiParams(name = "has_shop", type = "int",required=false,description = "是否查机构")
     * @ApiParams(name = "is_expire", type = "int",required=false,description = "是否查过期：1只查过期,2只查不过期,0全查")
     * @ApiParams(name = "is_sign_expire", type = "int",required=false,description = "是否查报名过期：1只查过期,2只查不过期,0全查")
     * @ApiParams(name = "shop_id", type = "int",required=false,description = "机构店铺id")
     * @ApiParams(name = "keyword", type = "string",required=false,description = "关键字搜索")
     * @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=銷量优先,views=浏览量优先,collect=收藏量优先")
     * @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 activity_list()
    {
        $user_id = 0;
        $user = $this->auth->getUser();//登录用户
        if($user)$user_id = $user['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["shop_id"] =  $this->auth->shop_id; //机构店铺id

        $params["keyword"] =  $this->request->get('keyword/s', ''); //机构店铺id

        $params["address_type"] =  $this->request->get('address_type/s', ''); //机构店铺id
        $params["province"] =  $this->request->get('province/s', ''); //机构店铺id

        $params["classes_type"] =  $this->request->get('classes_type/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', '-2'); //机构店铺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["is_expire"] =  $this->request->get('is_expire/d', 0); //机构店铺id
        $params["is_sign_expire"] =  $this->request->get('is_sign_expire/d', 0); //机构店铺id


        $params["order"] =  $this->request->get('order/s', ''); //机构店铺id
        $params["nearby"] =  $this->request->get('nearby/s', ''); //机构店铺id
        $params["has_shop"] =  $this->request->get('has_shop/d', ''); //主讲师用户id

        $params["latitude"] =  $this->request->get('latitude/s', ''); //机构店铺id
        $params["longitude"] =  $this->request->get('longitude/s', ''); //机构店铺id


        $params["sign_start_time"] =  $this->request->get('sign_start_time/d', ''); //主讲师用户id
        $params["sign_end_time"] =  $this->request->get('sign_end_time/d', ''); //机构店铺id

        $params["start_time"] =  $this->request->get('start_time/d', ''); //主讲师用户id
        $params["end_time"] =  $this->request->get('end_time/d', ''); //机构店铺id

//        $params["auth_status"] =  $this->request->get('auth_status/d', '-2'); //机构店铺id



//        $type =  $this->request->get('type/s', ''); //筛选学员和教练单

        try{
            //当前申请状态
            $res = ActivityModel::getVaildList($params);
//            if($user_id =='670153'){
//               file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
//            }
        }catch (\Exception $e){

            $this->apierror($e->getMessage());
        }
        $this->apisuccess('查询成功', ["list"=>$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 = "start_time", type = "int",required=false,description = "开始时间10位秒级时间戳")
     * @ApiParams(name = "end_time", type = "int",required=false,description = "结束时间10位秒级时间戳")
     * @ApiParams(name = "sign_start_time", type = "int",required=false,description = "报名开始时间10位秒级时间戳")
     * @ApiParams(name = "sign_end_time", type = "int",required=false,description = "报名结束时间10位秒级时间戳")
     * @ApiParams(name = "has_shop", type = "int",required=false,description = "是否查机构")
     * @ApiParams(name = "is_expire", type = "int",required=false,description = "是否查过期：1只查过期,2只查不过期,0全查")
     * @ApiParams(name = "is_sign_expire", type = "int",required=false,description = "是否查报名过期：1只查过期,2只查不过期,0全查")
     * @ApiParams(name = "shop_id", type = "int",required=false,description = "机构店铺id")
     * @ApiParams(name = "keyword", type = "string",required=false,description = "关键字搜索")
     * @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=銷量优先,views=浏览量优先,collect=收藏量优先")
     * @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 auth_activity_list()
    {
        $user_id = 0;
        $user = $this->auth->getUser();//登录用户
        if($user)$user_id = $user['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["shop_id"] =  $this->auth->shop_id; //机构店铺id

        $params["keyword"] =  $this->request->get('keyword/s', ''); //机构店铺id

        $params["address_type"] =  $this->request->get('address_type/s', ''); //机构店铺id
        $params["province"] =  $this->request->get('province/s', ''); //机构店铺id

        $params["classes_type"] =  $this->request->get('classes_type/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', '-2'); //机构店铺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["is_expire"] =  $this->request->get('is_expire/d', 0); //机构店铺id
        $params["is_sign_expire"] =  $this->request->get('is_sign_expire/d', 0); //机构店铺id


        $params["order"] =  $this->request->get('order/s', ''); //机构店铺id
        $params["nearby"] =  $this->request->get('nearby/s', ''); //机构店铺id
        $params["has_shop"] =  $this->request->get('has_shop/d', ''); //主讲师用户id

        $params["latitude"] =  $this->request->get('latitude/s', ''); //机构店铺id
        $params["longitude"] =  $this->request->get('longitude/s', ''); //机构店铺id


        $params["sign_start_time"] =  $this->request->get('sign_start_time/d', ''); //主讲师用户id
        $params["sign_end_time"] =  $this->request->get('sign_end_time/d', ''); //机构店铺id

        $params["start_time"] =  $this->request->get('start_time/d', ''); //主讲师用户id
        $params["end_time"] =  $this->request->get('end_time/d', ''); //机构店铺id

//        $params["auth_status"] =  $this->request->get('auth_status/d', '-2'); //机构店铺id



//        $type =  $this->request->get('type/s', ''); //筛选学员和教练单

        try{
            //当前申请状态
            $res = ActivityAuthModel::getVaildList($params);
//            if($user_id =='670153'){
//               file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
//            }
        }catch (\Exception $e){

            $this->apierror($e->getMessage());
        }
        $this->apisuccess('查询成功', ["list"=>$res]);
    }



}