From 9df7c0be82847911a44839b4c0c4d9ff1a29e290 Mon Sep 17 00:00:00 2001 From: "DESKTOP-GG6FIN9\\Administrator" <15040771@qq.com> Date: Fri, 24 Jul 2020 18:31:18 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E8=AF=84=E8=AE=BA=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/ServiceEvaluateService.php | 28 ++++++++++++++----- .../ServiceEvaluateServiceInterface.php | 4 +-- composer.json | 3 +- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/app/Service/ServiceEvaluateService.php b/app/Service/ServiceEvaluateService.php index a6e1dc8..fee79bd 100644 --- a/app/Service/ServiceEvaluateService.php +++ b/app/Service/ServiceEvaluateService.php @@ -6,6 +6,7 @@ use App\Model\ServiceEvaluate; use Hyperf\DbConnection\Db; use Hyperf\HttpServer\Contract\RequestInterface; use Hyperf\Di\Annotation\Inject; +use Hyperf\Paginator\Paginator; class ServiceEvaluateService implements ServiceEvaluateServiceInterface { @@ -26,22 +27,35 @@ class ServiceEvaluateService implements ServiceEvaluateServiceInterface return ServiceEvaluate::create($data); } - public function getPersonnelInfo() + public function getPersonnelInfo($user_id) { - $data = $this->request->all(); $res = Db::table('lanzu_service_personnel') - ->where(['user_id' => $data['user_id']]) + ->where(['user_id' => $user_id]) ->first(); return $res; } - public function getEvaluateList() + public function getEvaluateList($service_personnel_id) { - $data = $this->request->all(); $res = Db::table('lanzu_service_evaluate') - ->where(['service_personnel_id' => $data['service_personnel_id']]) + ->where(['service_personnel_id' => $service_personnel_id]) + ->limit(4) ->get(); - return $res; +// return $res; + $currentPage = 1; + $perPage = 2; + + // 这里根据 $currentPage 和 $perPage 进行数据查询,以下使用 Collection 代替 +// $collection = new Collection([ +// ['id' => 1, 'name' => 'Tom'], +// ['id' => 2, 'name' => 'Sam'], +// ['id' => 3, 'name' => 'Tim'], +// ['id' => 4, 'name' => 'Joe'], +// ]); +// +// $users = array_values($collection->forPage($currentPage, $perPage)->toArray()); + + return new Paginator($res, $perPage, $currentPage); } } \ No newline at end of file diff --git a/app/Service/ServiceEvaluateServiceInterface.php b/app/Service/ServiceEvaluateServiceInterface.php index ee2418d..22c6aa1 100644 --- a/app/Service/ServiceEvaluateServiceInterface.php +++ b/app/Service/ServiceEvaluateServiceInterface.php @@ -9,8 +9,8 @@ interface ServiceEvaluateServiceInterface public function evaluate(); - public function getPersonnelInfo(); + public function getPersonnelInfo($user_id); - public function getEvaluateList(); + public function getEvaluateList($service_personnel_id); } \ No newline at end of file diff --git a/composer.json b/composer.json index 6dddec9..1ac7889 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,8 @@ "hyperf/redis": "~2.0.0", "hyperf/constants": "~2.0.0", "hyperf/model-cache": "~2.0.0", - "hyperf/validation": "^2.0" + "hyperf/validation": "^2.0", + "hyperf/paginator": "^2.0" }, "require-dev": { "swoole/ide-helper": "^4.5", From 7d4c6bd5c15e076321f2da421859e61685f73933 Mon Sep 17 00:00:00 2001 From: weigang Date: Fri, 24 Jul 2020 18:56:14 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E7=94=A8=E6=88=B7=E3=80=81=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E4=BA=BA=E5=91=98=E3=80=81=E5=B8=82=E5=9C=BAID?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/ServiceEvaluateController.php | 1 + app/Request/EvaluateRequest.php | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Controller/ServiceEvaluateController.php b/app/Controller/ServiceEvaluateController.php index 9b0c5d3..f0f4eba 100644 --- a/app/Controller/ServiceEvaluateController.php +++ b/app/Controller/ServiceEvaluateController.php @@ -29,6 +29,7 @@ class ServiceEvaluateController extends BaseController public function evaluate(EvaluateRequest $validator) { // TODO 数据保存失败的返回处理 + // TODO 自定义验证用户、市场、服务人员ID $ret = $this->evaluateService->evaluate(); return $this->success($ret); diff --git a/app/Request/EvaluateRequest.php b/app/Request/EvaluateRequest.php index 4d9856f..5d7d53c 100644 --- a/app/Request/EvaluateRequest.php +++ b/app/Request/EvaluateRequest.php @@ -26,21 +26,25 @@ class EvaluateRequest extends FormRequest 'c_service' => 'required|nonempty|integer', 'c_quality' => 'required|nonempty|integer', 'content' => 'required|nonempty|between:15,150', - 'user_id' => 'required|nonempty|integer', - 'service_personnel_id' => 'required|nonempty|integer', - 'market_id' => 'required|nonempty|integer', + 'user_id' => 'required|nonempty|integer|exists:ims_cjdc_user,id', + 'service_personnel_id' => 'required|nonempty|integer|exists:lanzu_service_personnel,id', + 'market_id' => 'required|nonempty|integer|exists:ims_cjdc_market,id', ]; } public function messages(): array { return [ + 'user_id.exists' => ':attribute不存在', + 'service_personnel_id.exists' => ':attribute不存在', + 'market_id.exists' => ':attribute不存在', 'user_id.*' => ':attribute信息不正确', 'service_personnel_id.*' => ':attribute信息不正确', 'market_id.*' => ':attribute信息不正确', 'c_attitude.*' => ':attribute信息不正确', 'c_service.*' => ':attribute信息不正确', 'c_quality.*' => ':attribute信息不正确', + 'content.between' => ':attribute字数限制在:min~:max字', 'content.*' => ':attribute信息不正确', ]; } @@ -54,7 +58,7 @@ class EvaluateRequest extends FormRequest 'c_attitude' => '服务态度评分', 'c_service' => '服务值评分', 'c_quality' => '服务质量评分', - 'content' => '服务评价', + 'content' => '服务评价内容', ]; } } From e38906a3c78943430eaa17c331d3828ec3b3bc8c Mon Sep 17 00:00:00 2001 From: "DESKTOP-GG6FIN9\\Administrator" <15040771@qq.com> Date: Mon, 27 Jul 2020 08:48:45 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=AF=84=E4=BB=B7=E5=88=97=E8=A1=A8=20?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/ServiceEvaluateService.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/app/Service/ServiceEvaluateService.php b/app/Service/ServiceEvaluateService.php index fee79bd..041a304 100644 --- a/app/Service/ServiceEvaluateService.php +++ b/app/Service/ServiceEvaluateService.php @@ -39,23 +39,8 @@ class ServiceEvaluateService implements ServiceEvaluateServiceInterface { $res = Db::table('lanzu_service_evaluate') ->where(['service_personnel_id' => $service_personnel_id]) - ->limit(4) - ->get(); -// return $res; - $currentPage = 1; - $perPage = 2; - - // 这里根据 $currentPage 和 $perPage 进行数据查询,以下使用 Collection 代替 -// $collection = new Collection([ -// ['id' => 1, 'name' => 'Tom'], -// ['id' => 2, 'name' => 'Sam'], -// ['id' => 3, 'name' => 'Tim'], -// ['id' => 4, 'name' => 'Joe'], -// ]); -// -// $users = array_values($collection->forPage($currentPage, $perPage)->toArray()); - - return new Paginator($res, $perPage, $currentPage); + ->paginate(4); + return $res; } } \ No newline at end of file From 9787fd304f775446df471b0540427f8b7ddbe9bc Mon Sep 17 00:00:00 2001 From: "DESKTOP-GG6FIN9\\Administrator" <15040771@qq.com> Date: Mon, 27 Jul 2020 10:43:51 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E5=99=A8=20=E6=9C=8D=E5=8A=A1=E4=B8=93=E5=91=98=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E8=AF=84=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/ServiceEvaluateController.php | 18 +++++--- app/Request/PersonnelRequest.php | 42 +++++++++++++++++++ app/Request/UserRequest.php | 42 +++++++++++++++++++ app/Service/ServiceEvaluateService.php | 21 +++++++++- .../ServiceEvaluateServiceInterface.php | 4 +- 5 files changed, 119 insertions(+), 8 deletions(-) create mode 100644 app/Request/PersonnelRequest.php create mode 100644 app/Request/UserRequest.php diff --git a/app/Controller/ServiceEvaluateController.php b/app/Controller/ServiceEvaluateController.php index f0f4eba..8440f30 100644 --- a/app/Controller/ServiceEvaluateController.php +++ b/app/Controller/ServiceEvaluateController.php @@ -5,6 +5,8 @@ namespace App\Controller; use App\Constants\ErrorCode; use App\Exception\BusinessException; use App\Request\EvaluateRequest; +use App\Request\UserRequest; +use App\Request\PersonnelRequest; use App\Service\ServiceEvaluateServiceInterface; use Hyperf\Di\Annotation\Inject; @@ -38,19 +40,25 @@ class ServiceEvaluateController extends BaseController /** *获取服务专员基本信息 */ - public function getPersonnelInfo() + public function getPersonnelInfo(PersonnelRequest $validator) { //根据用户iD 获取服务专员详细信息 - $user_id = $this->request->input('user_id', 0); - return $this->success($this->evaluateService->getPersonnelInfo($user_id)); + $service_personnel_id = $this->request->input('service_personnel_id', 0); + $res = $this->evaluateService->getPersonnelInfo($service_personnel_id); + //如果存在服务专员则获取默认快捷评价 + if(!empty($res)) { + $quick_evaluate = $this->evaluateService->getQuickEvaluate(); + $res->quick_evaluate = $quick_evaluate; + } + return $this->success($res); } /** *获取服务专员评价列表 */ - public function getEvaluateList() + public function getEvaluateList(PersonnelRequest $validator) { - //根据用户iD 获取服务专员详细信息 + //根据服务专员iD 获取服务专员评价列表 $service_personnel_id = $this->request->input('service_personnel_id', 0); return $this->success($this->evaluateService->getEvaluateList($service_personnel_id)); } diff --git a/app/Request/PersonnelRequest.php b/app/Request/PersonnelRequest.php new file mode 100644 index 0000000..f4afee6 --- /dev/null +++ b/app/Request/PersonnelRequest.php @@ -0,0 +1,42 @@ + 'required|nonempty|integer|exists:ims_cjdc_user,id', + ]; + } + + public function messages(): array + { + return [ + 'service_personnel_id.*' => ':attribute信息不正确', + ]; + } + + public function attributes(): array + { + return [ + 'service_personnel_id' => '服务专员', + ]; + } +} diff --git a/app/Request/UserRequest.php b/app/Request/UserRequest.php new file mode 100644 index 0000000..2eed8d4 --- /dev/null +++ b/app/Request/UserRequest.php @@ -0,0 +1,42 @@ + 'required|nonempty|integer|exists:ims_cjdc_user,id', + ]; + } + + public function messages(): array + { + return [ + 'user_id.*' => ':attribute信息不正确', + ]; + } + + public function attributes(): array + { + return [ + 'user_id' => '用户', + ]; + } +} diff --git a/app/Service/ServiceEvaluateService.php b/app/Service/ServiceEvaluateService.php index 041a304..13d26b3 100644 --- a/app/Service/ServiceEvaluateService.php +++ b/app/Service/ServiceEvaluateService.php @@ -27,10 +27,13 @@ class ServiceEvaluateService implements ServiceEvaluateServiceInterface return ServiceEvaluate::create($data); } - public function getPersonnelInfo($user_id) + public function getPersonnelInfo($service_personnel_id) { $res = Db::table('lanzu_service_personnel') - ->where(['user_id' => $user_id]) + ->where([ + ['id','=',$service_personnel_id], + ['status','=',1] + ]) ->first(); return $res; } @@ -43,4 +46,18 @@ class ServiceEvaluateService implements ServiceEvaluateServiceInterface return $res; } + public function getQuickEvaluate() + { + $data = (object)null; + $obj1 = (object)null; + $obj1->title1 = '服务态度超好'; + $obj1->title2 = '服务态度一般般'; + $data->quick_evaluate_title = $obj1; + $obj2 = (object)null; + $obj2->content1 = '超级细心'; + $obj2->content2 = '马马虎虎'; + $data->quick_evaluate_content = $obj2; + return $data; + } + } \ No newline at end of file diff --git a/app/Service/ServiceEvaluateServiceInterface.php b/app/Service/ServiceEvaluateServiceInterface.php index 22c6aa1..97ecbd6 100644 --- a/app/Service/ServiceEvaluateServiceInterface.php +++ b/app/Service/ServiceEvaluateServiceInterface.php @@ -9,8 +9,10 @@ interface ServiceEvaluateServiceInterface public function evaluate(); - public function getPersonnelInfo($user_id); + public function getPersonnelInfo($service_personnel_id); public function getEvaluateList($service_personnel_id); + public function getQuickEvaluate(); + } \ No newline at end of file From 1b79bd32a4686381f8fcf02215ec6f9541fa953d Mon Sep 17 00:00:00 2001 From: "DESKTOP-GG6FIN9\\Administrator" <15040771@qq.com> Date: Mon, 27 Jul 2020 11:28:05 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=AF=84=E4=BB=B7=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7=E5=9B=BE=E7=89=87=E5=92=8C?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Request/PersonnelRequest.php | 2 +- app/Service/ServiceEvaluateService.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Request/PersonnelRequest.php b/app/Request/PersonnelRequest.php index f4afee6..87aacb2 100644 --- a/app/Request/PersonnelRequest.php +++ b/app/Request/PersonnelRequest.php @@ -22,7 +22,7 @@ class PersonnelRequest extends FormRequest public function rules(): array { return [ - 'service_personnel_id' => 'required|nonempty|integer|exists:ims_cjdc_user,id', + 'service_personnel_id' => 'required|nonempty|integer|exists:lanzu_service_personnel,id', ]; } diff --git a/app/Service/ServiceEvaluateService.php b/app/Service/ServiceEvaluateService.php index 13d26b3..d7cf885 100644 --- a/app/Service/ServiceEvaluateService.php +++ b/app/Service/ServiceEvaluateService.php @@ -40,8 +40,10 @@ class ServiceEvaluateService implements ServiceEvaluateServiceInterface public function getEvaluateList($service_personnel_id) { - $res = Db::table('lanzu_service_evaluate') - ->where(['service_personnel_id' => $service_personnel_id]) + $res = Db::table('lanzu_service_evaluate as e') + ->join('ims_cjdc_user as u','u.id','=','e.user_id') + ->where(['e.service_personnel_id'=>$service_personnel_id]) + ->select('e.*','u.name','u.img') ->paginate(4); return $res; }