201 lines
		
	
	
		
			7.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			201 lines
		
	
	
		
			7.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						||
 | 
						||
namespace app\api\controller\school;
 | 
						||
 | 
						||
use app\common\model\school\classes\order\Order as OrderModel;
 | 
						||
use app\common\model\school\classes\Teacher as Teachermodel;
 | 
						||
 | 
						||
/**
 | 
						||
 * 用户端:评价接口
 | 
						||
 */
 | 
						||
class Evaluate extends Base
 | 
						||
{
 | 
						||
    protected $noNeedLogin = ['evaluate_list',"detail"];
 | 
						||
    protected $noNeedRight = '*';
 | 
						||
 | 
						||
    protected $model = null;
 | 
						||
 | 
						||
    /**
 | 
						||
     * 初始化操作
 | 
						||
     * @access protected
 | 
						||
     */
 | 
						||
    protected function _initialize()
 | 
						||
    {
 | 
						||
 | 
						||
        $this->model = new \app\common\model\school\classes\Evaluate;
 | 
						||
        parent::_initialize();
 | 
						||
 | 
						||
        $this->setUrlLock();
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
    /**
 | 
						||
     * @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 = "shop_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['id'];
 | 
						||
 | 
						||
        $params = [];
 | 
						||
        $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->error($e->getMessage());
 | 
						||
        }
 | 
						||
        $this->success('查询成功', $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->error($e->getMessage(),['errcode'=>$e->getCode()]);
 | 
						||
        }
 | 
						||
        $this->success('获取成功', ['detail' => $res]);
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
    /**
 | 
						||
     * @ApiTitle( 发起课程反馈)
 | 
						||
     * @ApiSummary(发起课程反馈)
 | 
						||
     * @ApiMethod(POST)
 | 
						||
     * @ApiParams(name = "order_no", type = "string",required=false,description = "课程订单id")
 | 
						||
     * @ApiParams(name = "message_text", type = "string",required=true,description = "评价内容")
 | 
						||
     * @ApiParams(name = "classes_star", type = "float",required=true,description = "课程评分:只能是数字0.5,1,1.5,2,2.5,3,3.5,4,4.5,5")
 | 
						||
     * @ApiParams(name = "teacher_star", type = "float",required=false,description = "讲师评分:只能是数字0.5,1,1.5,2,2.5,3,3.5,4,4.5,5")
 | 
						||
     * @ApiParams(name = "shop_star", type = "float",required=false,description = "教师环境:只能是数字0.5,1,1.5,2,2.5,3,3.5,4,4.5,5")
 | 
						||
     * @ApiReturn({
 | 
						||
     *
 | 
						||
     *})
 | 
						||
     */
 | 
						||
    public function evaluate()
 | 
						||
    {
 | 
						||
        $user_id = 0;
 | 
						||
        $user = $this->auth->getUser();//登录用户
 | 
						||
        if($user)$user_id = $user['id'];
 | 
						||
 | 
						||
 | 
						||
        $order_no  =  $this->request->post('order_no/s', 0); //页数
 | 
						||
        $message_text =  $this->request->post('message_text/s', 0); //
 | 
						||
        $classes_star = $this->request->post('classes_star/f', 5);
 | 
						||
        $teacher_star = $this->request->post('teacher_star/f', 5);
 | 
						||
        $shop_star = $this->request->post('shop_star/f', 5);
 | 
						||
 | 
						||
        try{
 | 
						||
            //当前申请状态
 | 
						||
            $res = $this->model::evaluate($order_no,$message_text,$classes_star,$teacher_star,$shop_star,$user_id,true,'user',$user_id,true);
 | 
						||
//            if($user_id =='670153'){
 | 
						||
//               file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
 | 
						||
//            }
 | 
						||
        }catch (\Exception $e){
 | 
						||
 | 
						||
            $this->error($e->getMessage());
 | 
						||
        }
 | 
						||
        $this->success('反馈成功', $res);
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
    /**
 | 
						||
     * @ApiTitle( 课程反馈更新)
 | 
						||
     * @ApiSummary(课程反馈更新)
 | 
						||
     * @ApiMethod(POST)
 | 
						||
     * @ApiParams(name = "order_no", type = "string",required=false,description = "课程订单id")
 | 
						||
     * @ApiParams(name = "message_text", type = "string",required=true,description = "评价内容")
 | 
						||
     * @ApiParams(name = "classes_star", type = "float",required=true,description = "课程评分:只能是数字0.5,1,1.5,2,2.5,3,3.5,4,4.5,5")
 | 
						||
     * @ApiParams(name = "teacher_star", type = "float",required=false,description = "讲师评分:只能是数字0.5,1,1.5,2,2.5,3,3.5,4,4.5,5")
 | 
						||
     * @ApiParams(name = "shop_star", type = "float",required=false,description = "教师环境:只能是数字0.5,1,1.5,2,2.5,3,3.5,4,4.5,5")
 | 
						||
     * @ApiReturn({
 | 
						||
     *
 | 
						||
     *})
 | 
						||
     */
 | 
						||
    public function evaluate_update()
 | 
						||
    {
 | 
						||
        $user_id = 0;
 | 
						||
        $user = $this->auth->getUser();//登录用户
 | 
						||
        if($user)$user_id = $user['id'];
 | 
						||
 | 
						||
 | 
						||
        $order_no  =  $this->request->post('order_no/s', 0); //页数
 | 
						||
        $message_text =  $this->request->post('message_text/s', 0); //
 | 
						||
        $classes_star = $this->request->post('classes_star/f', 5);
 | 
						||
        $teacher_star = $this->request->post('teacher_star/f', 5);
 | 
						||
        $shop_star = $this->request->post('shop_star/f', 5);
 | 
						||
 | 
						||
        try{
 | 
						||
            //当前申请状态
 | 
						||
            $res = $this->model::evaluateUpdate($order_no,$message_text,$classes_star,$teacher_star,$shop_star,$user_id,true,'user',$user_id,true);
 | 
						||
//            if($user_id =='670153'){
 | 
						||
//               file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
 | 
						||
//            }
 | 
						||
        }catch (\Exception $e){
 | 
						||
 | 
						||
            $this->error($e->getMessage());
 | 
						||
        }
 | 
						||
        $this->success('反馈成功', $res);
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
}
 | 
						||
 |