CommonController.php 3.9 KB
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Powerless < wzxaini9@gmail.com>
// +----------------------------------------------------------------------
namespace app\user\controller;

use app\user\model\CommentModel;
use cmf\controller\AdminBaseController;
use cmf\controller\UserBaseController;
use app\user\model\UserModel;
use think\Db;


class CommonController extends AdminBaseController
{



    //    中介评价
    public function comment(){
        $data = $this->request->param();
        $where_comment['m.status'] = 1;
        if($data){
            $startTime = empty($data['start_time']) ? 0 : strtotime($data['start_time']);
            $endTime   = empty($data['end_time']) ? 0 : strtotime($data['end_time']);
            if ($startTime && $endTime) {
                $where_comment['c.create_time'] = array('between',"$startTime,$endTime");
                $this->assign('start_time', $data['start_time']);
                $this->assign('end_time', $data['end_time']);
            }else{
                if($startTime){
                    $where_comment['c.create_time'] = array('egt',$startTime);
                    $this->assign('start_time', $data['start_time']);
                }
                if($endTime){
                    $where_comment['c.create_time'] = array('elt',$endTime);
                    $this->assign('end_time', $data['end_time']);
                }
            }

            if(!empty($data['name'])){
                $where_comment['m.name'] = array('like','%'.$data['name'].'%');
                $this->assign('name', $data['name']);
            }
            if(!empty($data['tel'])){
                $where_comment['m.tel'] = array('like','%'.$data['tel'].'%');
                $this->assign('tel', $data['tel']);
            }
        }
        $comment_list = Db::name('Comment')->alias('c')
            ->join("Member m",'m.id=c.user_id')
            ->where($where_comment)
            ->field('m.name as user_name,m.tel as user_tel,m.id as user_id,c.*')
            ->select()->toArray();
        foreach ($comment_list as $comk=>$comv){
//            $where_user['id'] = $comv['user_id'];
//            $user = Db::name('Member')->where($where_user)->field('id,name,tel')->find();
            $where_agency['id'] = $comv['intermediary_id'];
            $agency = Db::name('Member')->where($where_agency)->field('id,name,tel')->find();
//            $comment_list[$comk]['user_id'] = $user['id'];
//            $comment_list[$comk]['user_name'] = $user['name'];
//            $comment_list[$comk]['user_tel'] = $user['tel'];
            $comment_list[$comk]['agency_id'] = $agency['id'];
            $comment_list[$comk]['agency_name'] = $agency['name'];
            $comment_list[$comk]['agency_tel'] = $agency['tel'];
        }
//        $this->assign('uid',$data['id']);
        $this->assign('lists',$comment_list);
        return $this->fetch('common');
    }

//    删除中介评价
    public function agencyDel(){
        $data = $this->request->param();
        $where_com['id'] = $data['id'];
        $where_com['status'] = array('neq',9);
        $complaint = Db::name('Comment')->where($where_com)->find();
        if($complaint){
            $save['status'] = 9;
            $save['update_time'] = time();
            $update = Db::name('Comment')->where($where_com)->update($save);
            if($update){
                $this->success('删除成功');
            }else{
                $this->error('删除失败');
            }
        }else{
            $this->error('评论状态错误');
        }
    }


}