|
@@ -67,16 +67,17 @@ class Service extends Base
|
|
|
$store = (new SaasStore)->where("poi_id",$param['poi'])->findOrEmpty();
|
|
$store = (new SaasStore)->where("poi_id",$param['poi'])->findOrEmpty();
|
|
|
if ($store->isEmpty()) return error("店铺不存在");
|
|
if ($store->isEmpty()) return error("店铺不存在");
|
|
|
$chatStore = (new SaasChatStore)->where(['poi_id'=> $store['poi_id'],"openid" => $request->user['openid']])->findOrEmpty();
|
|
$chatStore = (new SaasChatStore)->where(['poi_id'=> $store['poi_id'],"openid" => $request->user['openid']])->findOrEmpty();
|
|
|
|
|
+ // 获取在线客服
|
|
|
|
|
+ $service = (new SystemUser)->where("store_id",$param['poi'])->where("type",3)->where("is_line",1)->findOrEmpty();
|
|
|
|
|
+ if ($service->isEmpty()) return $this->encode("ok",['store' => $store,'code' => 3]); // 无客服在线
|
|
|
if ($chatStore->isEmpty()) {
|
|
if ($chatStore->isEmpty()) {
|
|
|
$chatStore->insertGetId([
|
|
$chatStore->insertGetId([
|
|
|
"poi_id" => $store['poi_id'],
|
|
"poi_id" => $store['poi_id'],
|
|
|
"poi_name" => $store['poi_name'],
|
|
"poi_name" => $store['poi_name'],
|
|
|
- "openid" => $request->user['openid']
|
|
|
|
|
|
|
+ "openid" => $request->user['openid'],
|
|
|
|
|
+ "service_id" => $service['id']
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
- // 获取在线客服
|
|
|
|
|
- $service = (new SystemUser)->where("store_id",$param['poi'])->where("type",3)->where("is_line",1)->findOrEmpty();
|
|
|
|
|
- if ($service->isEmpty()) return $this->encode("ok",['store' => $store,'code' => 3]); // 无客服在线
|
|
|
|
|
// 获取最新的10条聊天记录
|
|
// 获取最新的10条聊天记录
|
|
|
$msg = (new SaasChatMsg)->where(['openid' => $request->user['openid'],'poi_id' => $store['poi_id']])->append(['avatar','time'])->withAttr(['avatar' => function(){
|
|
$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";
|
|
return "https://washmy.oss-cn-guangzhou.aliyuncs.com/storage/20260511/23627b2cb8f73a8a90b95c31d726e6ecad0cbb9a.png";
|
|
@@ -91,4 +92,21 @@ class Service extends Base
|
|
|
return error($throwable->getMessage());
|
|
return error($throwable->getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 发送消息
|
|
|
|
|
+ * @param Request $request
|
|
|
|
|
+ * @return Response
|
|
|
|
|
+ */
|
|
|
|
|
+ #[PostMapping("send")]
|
|
|
|
|
+ public function sendMsg(Request $request): Response
|
|
|
|
|
+ {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $param = $request->all();
|
|
|
|
|
+
|
|
|
|
|
+ return error("err");
|
|
|
|
|
+ } catch (\Throwable $throwable) {
|
|
|
|
|
+ return error($throwable->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|