119 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			119 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						||
 | 
						||
namespace app\manystoreapi\controller;
 | 
						||
 | 
						||
use app\common\controller\ManystoreApiBase;
 | 
						||
use app\common\model\school\classes\Evaluate as EvaluateModel;
 | 
						||
use app\common\model\school\classes\Teacher as Teachermodel;
 | 
						||
 | 
						||
/**
 | 
						||
 * 机构API后台:评价查看接口
 | 
						||
 */
 | 
						||
class Evaluate extends ManystoreApiBase
 | 
						||
{
 | 
						||
//    protected $noNeedLogin = ['evaluate_list',"detail"];
 | 
						||
//    protected $noNeedRight = '*';
 | 
						||
 | 
						||
    protected $model = null;
 | 
						||
 | 
						||
    /**
 | 
						||
     * 初始化操作
 | 
						||
     * @access protected
 | 
						||
     */
 | 
						||
    public function _initialize()
 | 
						||
    {
 | 
						||
 | 
						||
        $this->model = new EvaluateModel;
 | 
						||
        parent::_initialize();
 | 
						||
 | 
						||
        //判断登录用户是否是员工
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
    /**
 | 
						||
     * @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 = "my", type = "string",required=false,description = "是否查我的评价(需登录)")
 | 
						||
     * @ApiParams(name = "classes_lib_id", type = "string",required=false,description = "课程id")
 | 
						||
     * @ApiParams(name = "classes_order_id", type = "string",required=false,description = "课程订单id")
 | 
						||
     * @ApiParams(name = "teacher_id", type = "string",required=false,description = "老师id")
 | 
						||
     * @ApiParams(name = "time", type = "string",required=false,description = "复合时间查询:today今天,week本周,month本月,year本年,yesterday昨天,last year上一年,last week上周,last month上個月,lately7最近7天 , lately30最近30天,按开始时间区间查传值格式:Y/m/d H:M:S-Y/m/d H:M:S")
 | 
						||
     *
 | 
						||
     * @ApiReturn({
 | 
						||
     *
 | 
						||
     *})
 | 
						||
     */
 | 
						||
    public function evaluate_list()
 | 
						||
    {
 | 
						||
        $user_id = 0;
 | 
						||
        $user = $this->auth->getUser();//登录用户
 | 
						||
        if($user)$user_id = $user['user_id'];
 | 
						||
 | 
						||
        $params = [
 | 
						||
            "shop_id"=>$this->auth->shop_id,
 | 
						||
        ];
 | 
						||
        $my  =  $this->request->get('my/d', 0); //我的评价
 | 
						||
        if($my && $user_id){
 | 
						||
            $params['user_id'] = $user_id;
 | 
						||
        }
 | 
						||
        $page  =  $this->request->get('page/d', 0); //页数
 | 
						||
        $limit =  $this->request->get('limit/d', 0); //条数
 | 
						||
        $params["keywords"] = $this->request->get('keywords/s', ''); //搜索关键字
 | 
						||
        $params["classes_lib_id"] = $this->request->get('classes_lib_id/d', ''); //搜索关键字
 | 
						||
        $params["classes_order_id"] =  $this->request->get('classes_order_id/d', ''); //搜索关键字
 | 
						||
//        $params["shop_id"] =  $this->request->get('shop_id/d', ''); //时间
 | 
						||
        $params["teacher_id"] =  $this->request->get('teacher_id/d', ''); //时间
 | 
						||
        $params["time"] =  $this->request->get('time/s', ''); //时间
 | 
						||
 | 
						||
        try{
 | 
						||
            //当前申请状态
 | 
						||
            $res = $this->model::evaluateList($page, $limit,$params);
 | 
						||
//            if($user_id =='670153'){
 | 
						||
//               file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
 | 
						||
//            }
 | 
						||
        }catch (\Exception $e){
 | 
						||
 | 
						||
            $this->apierror($e->getMessage());
 | 
						||
        }
 | 
						||
        $this->apisuccess('查询成功', $res);
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
    /**
 | 
						||
     * @ApiTitle( 评价详情)
 | 
						||
     * @ApiSummary(评价详情)
 | 
						||
     * @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->apierror($e->getMessage(),['errcode'=>$e->getCode()]);
 | 
						||
        }
 | 
						||
        $this->apisuccess('获取成功', ['detail' => $res]);
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
}
 | 
						||
 |