AI对话功能优化
This commit is contained in:
@@ -83,7 +83,51 @@ class WechatChatroomController extends BaseController
|
||||
return ResponseHelper::success(['list'=>$list,'total'=>$total]);
|
||||
}
|
||||
|
||||
public function getDetail(){
|
||||
$id = input('id', 0);
|
||||
|
||||
if (!$id) {
|
||||
return ResponseHelper::error('聊天室ID不能为空');
|
||||
}
|
||||
|
||||
$accountId = $this->getUserInfo('s2_accountId');
|
||||
if (empty($accountId)){
|
||||
return ResponseHelper::error('请先登录');
|
||||
}
|
||||
|
||||
$detail = Db::table('s2_wechat_chatroom')
|
||||
->where(['accountId' => $accountId, 'id' => $id, 'isDeleted' => 0])
|
||||
->find();
|
||||
|
||||
if (!$detail) {
|
||||
return ResponseHelper::error('聊天室不存在或无权限访问');
|
||||
}
|
||||
|
||||
// 处理时间格式
|
||||
$detail['createTime'] = !empty($detail['createTime']) ? date('Y-m-d H:i:s', $detail['createTime']) : '';
|
||||
$detail['updateTime'] = !empty($detail['updateTime']) ? date('Y-m-d H:i:s', $detail['updateTime']) : '';
|
||||
|
||||
// 查询未读消息数量
|
||||
$unreadCount = Db::table('s2_wechat_message')
|
||||
->where('wechatChatroomId', $id)
|
||||
->where('isRead', 0)
|
||||
->count();
|
||||
|
||||
// 查询最新消息
|
||||
$latestMessage = Db::table('s2_wechat_message')
|
||||
->where('wechatChatroomId', $id)
|
||||
->order('id desc')
|
||||
->find();
|
||||
|
||||
$config = [
|
||||
'unreadCount' => $unreadCount,
|
||||
'chat' => !empty($latestMessage),
|
||||
'msgTime' => isset($latestMessage['wechatTime']) ? $latestMessage['wechatTime'] : 0
|
||||
];
|
||||
$detail['config'] = $config;
|
||||
|
||||
return ResponseHelper::success($detail);
|
||||
}
|
||||
|
||||
public function aiAnnouncement()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user