|
|
@@ -69,9 +69,14 @@ class Service extends Base
|
|
|
$store = (new SaasStore)->where("poi_id",$param['poi'])->findOrEmpty();
|
|
|
if ($store->isEmpty()) return error("店铺不存在");
|
|
|
$chatStore = (new SaasChatStore)->where(['poi_id'=> $store['poi_id'],"openid" => $request->user['openid']])->findOrEmpty();
|
|
|
+ $userAvatar = $request->user['avatar'];
|
|
|
// 获取最新的10条聊天记录
|
|
|
- $msg = (new SaasChatMsg)->where(['openid' => $request->user['openid'],'poi_id' => $store['poi_id']])->append(['avatar','time'])->withAttr(['avatar' => function(){
|
|
|
- return "https://washmy.oss-cn-guangzhou.aliyuncs.com/storage/20260511/23627b2cb8f73a8a90b95c31d726e6ecad0cbb9a.png";
|
|
|
+ $msg = (new SaasChatMsg)->where(['openid' => $request->user['openid'],'poi_id' => $store['poi_id']])->append(['avatar','time'])->withAttr(['avatar' => function($data,$resp) use($userAvatar){
|
|
|
+ if ($resp['source'] == 1) { // 用户
|
|
|
+ return $userAvatar??'';
|
|
|
+ } else {
|
|
|
+ return "https://washmy.oss-cn-guangzhou.aliyuncs.com/storage/20260511/23627b2cb8f73a8a90b95c31d726e6ecad0cbb9a.png";
|
|
|
+ }
|
|
|
},'time' => function($resp,$data){
|
|
|
return strtotime($data['create_at']) * 1000;
|
|
|
}])->order("id","desc")->paginate([
|
|
|
@@ -96,7 +101,7 @@ class Service extends Base
|
|
|
$chatStore->goods = $param['goods']??'';
|
|
|
$chatStore->save();
|
|
|
}
|
|
|
- return $this->encode("ok",['store' => $store,'code' => 1,'sendId' => $request->user['openid'],'msg' => pageFormatMsg($msg),"serviceId" => $service['id']]); // 客服在线
|
|
|
+ return $this->encode("ok",['store' => $store,'code' => 1,'sendId' => $request->user['openid'],'msg' => pageFormatMsg($msg),"serviceId" => $service['id'],'avatar' => $userAvatar]); // 客服在线
|
|
|
} catch (\Throwable $throwable) {
|
|
|
echo $throwable->getMessage()."\n";
|
|
|
echo $throwable->getFile()."\n";
|
|
|
@@ -115,8 +120,13 @@ class Service extends Base
|
|
|
"size.default" => 10
|
|
|
],$request->method());
|
|
|
if (!is_array($param)) return error($param);
|
|
|
- $msg = (new SaasChatMsg)->where(['openid' => $request->user['openid'],'poi_id' => $param['poi']])->append(['avatar','time'])->withAttr(['avatar' => function(){
|
|
|
- return "https://washmy.oss-cn-guangzhou.aliyuncs.com/storage/20260511/23627b2cb8f73a8a90b95c31d726e6ecad0cbb9a.png";
|
|
|
+ $userAvatar = $request->user['avatar'];
|
|
|
+ $msg = (new SaasChatMsg)->where(['openid' => $request->user['openid'],'poi_id' => $param['poi']])->append(['avatar','time'])->withAttr(['avatar' => function($data,$resp) use($userAvatar){
|
|
|
+ if ($resp['source'] == 1) {
|
|
|
+ return $userAvatar??'';
|
|
|
+ } else {
|
|
|
+ return "https://washmy.oss-cn-guangzhou.aliyuncs.com/storage/20260511/23627b2cb8f73a8a90b95c31d726e6ecad0cbb9a.png";
|
|
|
+ }
|
|
|
},'time' => function($resp,$data){
|
|
|
return strtotime($data['create_at']) * 1000;
|
|
|
}])->order("id","desc")->paginate([
|
|
|
@@ -167,7 +177,8 @@ class Service extends Base
|
|
|
"service_id" => $param['sendId'],
|
|
|
"create_at" => formatTime(time()),
|
|
|
"user" => [
|
|
|
- "nickname" => $request->user['nickname']
|
|
|
+ "nickname" => $request->user['nickname'],
|
|
|
+ "avatar" => $request->user['avatar']
|
|
|
]
|
|
|
]);
|
|
|
return successTrans("success.data");
|