|
|
@@ -48,16 +48,15 @@ class Service extends Base
|
|
|
$param['field'] = "last_at";
|
|
|
$data = $this->service->setModel()->getList($param,['user' => function($query){
|
|
|
$query->field("openid,nickname,avatar,mobile,create_at");
|
|
|
- }],true,['last','avatar','last_time'],['last' => function($data,$resp) use($param){
|
|
|
+ }],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,'time' => time(),"create_at"=> formatTime(date("Y-m-d H:i:s",time()))];
|
|
|
}
|
|
|
- return ["content"=> str_cut_ellipsis($last['content']),'num' => 0,"create_at"=> formatTime($last['create_at']),"time"=> strtotime($last['create_at']),'type' => $last['type']];
|
|
|
+ $total = (new SaasChatMsg)->where(["poi_id" => $resp['poi_id'],"service_id" => $param['service_id'],"openid" => $resp['openid'],'is_read' => 0])->count();
|
|
|
+ return ["content"=> str_cut_ellipsis($last['content']),'num' => $total,"create_at"=> formatTime($last['create_at']),"time"=> strtotime($last['create_at']),'type' => $last['type']];
|
|
|
},'avatar' => function(){
|
|
|
return "https://washmy.oss-cn-guangzhou.aliyuncs.com/storage/20260511/23627b2cb8f73a8a90b95c31d726e6ecad0cbb9a.png";
|
|
|
- },'last_time' => function($data,$resp){
|
|
|
- return $resp['last_at']?date('Y-m-d',strtotime($resp['last_at'])):'-';
|
|
|
}]);
|
|
|
return successTrans(100010,pageFormat($data),200);
|
|
|
} catch (\Throwable $th) {
|
|
|
@@ -138,6 +137,7 @@ class Service extends Base
|
|
|
"poi_id" => $param['groupId'],
|
|
|
"service_id" => $request->user['id'],
|
|
|
]);
|
|
|
+ (new SaasChatMsg)->where(['openid' => $param['openid'],'service_id' => $request->user['id']])->save(['is_read' => 1]);
|
|
|
$api = new Api('http://127.0.0.1:3232', config('plugin.webman.push.app.app_key'),config('plugin.webman.push.app.app_secret'));
|
|
|
$api->trigger("user-{$param['openid']}","message",[
|
|
|
"type" => $param['type'],
|
|
|
@@ -149,7 +149,7 @@ class Service extends Base
|
|
|
"poi_id" => $param['groupId'],
|
|
|
"openid" => $param['openid'],
|
|
|
"service_id" => $request->user['id'],
|
|
|
- "create_at" => formatTime(time()),
|
|
|
+ "create_at" => formatTime(time())
|
|
|
]);
|
|
|
return successTrans("success.data",['time' => formatTime(time())]);
|
|
|
} catch (\Throwable $th) {
|