|
|
@@ -0,0 +1,53 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\controller\service;
|
|
|
+
|
|
|
+use app\extra\basic\Base;
|
|
|
+use app\middleware\AuthMiddleware;
|
|
|
+use app\model\saas\SaasChatMsg;
|
|
|
+use app\model\saas\SaasChatStore;
|
|
|
+use app\service\saas\ChatStoreService;
|
|
|
+use DI\Attribute\Inject;
|
|
|
+use LinFly\Annotation\Attributes\Route\Controller;
|
|
|
+use LinFly\Annotation\Attributes\Route\GetMapping;
|
|
|
+use LinFly\Annotation\Attributes\Route\Middleware;
|
|
|
+use support\Request;
|
|
|
+use support\Response;
|
|
|
+
|
|
|
+
|
|
|
+#[Controller("/api/service/chat"),Middleware(AuthMiddleware::class)]
|
|
|
+class Service extends Base
|
|
|
+{
|
|
|
+
|
|
|
+ #[Inject]
|
|
|
+ protected ChatStoreService $service;
|
|
|
+
|
|
|
+ #[Inject]
|
|
|
+ protected SaasChatStore $model;
|
|
|
+
|
|
|
+ #[GetMapping('list')]
|
|
|
+ public function getServiceData(Request $request): Response
|
|
|
+ {
|
|
|
+
|
|
|
+ try {
|
|
|
+ $param = $request->all();
|
|
|
+ $param['poi_id'] = $request->user['store_id'];
|
|
|
+ $param['service_id'] = $request->user['id'];
|
|
|
+ $data = $this->service->setModel()->getList($param,['user' => function($query){
|
|
|
+ $query->field("openid,nickname,mobile");
|
|
|
+ }],true,['last','avatar'],['last' => function($data,$resp) use($param){
|
|
|
+ $last = (new SaasChatMsg)->where(["poi_id" => $resp['poi_id'],"service_id" => $param['service_id'],"openid" => $resp['openid']])->order("create_at desc")->field("content,create_at,type")->findOrEmpty();
|
|
|
+ if ($last->isEmpty()) {
|
|
|
+ return ['type' => "text","content"=>"无",'num' => 0,"create_at"=> formatTime(date("Y-m-d H:i:s",time()))];
|
|
|
+ }
|
|
|
+ return ["content"=> $last['content'],'num' => 0,"create_at"=> formatTime($last['create_at']),'type' => $last['type']];
|
|
|
+ },'avatar' => function(){
|
|
|
+ return "https://washmy.oss-cn-guangzhou.aliyuncs.com/storage/20260511/23627b2cb8f73a8a90b95c31d726e6ecad0cbb9a.png";
|
|
|
+ }]);
|
|
|
+ return successTrans(100010,pageFormat($data),200);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return error($th->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|