From 6365251c153d273beba281c8a36120369ef10b0c Mon Sep 17 00:00:00 2001 From: "DESKTOP-GG6FIN9\\Administrator" <15040771@qq.com> Date: Tue, 28 Jul 2020 18:31:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E6=97=B6=E9=97=B4=E6=88=B3=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E5=9C=A8=E5=90=8E=E7=AB=AF=E6=89=A7=E8=A1=8C=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/ServiceEvaluate.php | 8 ++++++++ app/Service/ServiceEvaluateService.php | 14 +++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/Model/ServiceEvaluate.php b/app/Model/ServiceEvaluate.php index 82ee480..544a30d 100644 --- a/app/Model/ServiceEvaluate.php +++ b/app/Model/ServiceEvaluate.php @@ -19,4 +19,12 @@ class ServiceEvaluate extends Model */ protected $attributes = []; + /** + * + */ + protected $casts = [ + 'created_at' => 'datetime:Y-m-d h:i:s', + 'updated_at' => 'datetime:Y-m-d h:i:s', + ]; + } \ No newline at end of file diff --git a/app/Service/ServiceEvaluateService.php b/app/Service/ServiceEvaluateService.php index 6a2bd96..28313d9 100644 --- a/app/Service/ServiceEvaluateService.php +++ b/app/Service/ServiceEvaluateService.php @@ -3,6 +3,7 @@ namespace App\Service; use App\Model\ServiceEvaluate; +use App\Model\ServicePersonnel; use App\Model\Users; use Hyperf\DbConnection\Db; use Hyperf\HttpServer\Contract\RequestInterface; @@ -39,9 +40,9 @@ class ServiceEvaluateService implements ServiceEvaluateServiceInterface $res = Db::table('lanzu_service_personnel') ->where([ ['user_id','=',$user_id], - ['status','=',1] ]) - ->exists(); + ->select('id') + ->first(); return $res; } @@ -66,11 +67,10 @@ class ServiceEvaluateService implements ServiceEvaluateServiceInterface //踩坑 paginate 只能接收int型参数 $per_page = isset($data['per_page']) && $data['per_page'] > 0 ? intval($data['per_page']) : 6; //查询评论列表 按照创建时间降序排序 - $res = Db::table('lanzu_service_evaluate as e') - ->join('ims_cjdc_user as u','u.id','=','e.user_id') - ->where(['e.service_personnel_id'=>$data['service_personnel_id']]) - ->select('e.*','u.name','u.img') - ->orderBy('created_at','desc') + $res = ServiceEvaluate::join('ims_cjdc_user as u','u.id','=','lanzu_service_evaluate.user_id') + ->where(['lanzu_service_evaluate.service_personnel_id'=>$data['service_personnel_id']]) + ->select('lanzu_service_evaluate.*','u.name','u.img') + ->orderBy('lanzu_service_evaluate.created_at','desc') ->paginate($per_page); return $res; }