2025-08-13 10:43:56 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace app\api\model;
|
|
|
|
|
|
|
|
|
|
|
|
use think\Db;
|
|
|
|
|
|
use think\Log;
|
|
|
|
|
|
use think\Model;
|
|
|
|
|
|
|
|
|
|
|
|
class Chat extends Model
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
//腾讯IM发送消息
|
|
|
|
|
|
public function sendMsg($type,$roomId,$content,$userId = 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
// /// 系统消息
|
|
|
|
|
|
// QXRoomMessageTypeSystem = 1000,
|
|
|
|
|
|
// /// 用户进入房间
|
|
|
|
|
|
// QXRoomMessageTypeJoin = 1001,
|
|
|
|
|
|
// /// 用户退出房间
|
|
|
|
|
|
// QXRoomMessageTypeQuit = 1002,
|
|
|
|
|
|
// /// 用户上麦
|
|
|
|
|
|
// QXRoomMessageTypeUpSeat = 1003,
|
|
|
|
|
|
// /// 用户下麦
|
|
|
|
|
|
// QXRoomMessageTypeDownSeat = 1004,
|
|
|
|
|
|
// /// 房间收到礼物
|
|
|
|
|
|
// QXRoomMessageTypeGift = 1005,
|
|
|
|
|
|
// /// 设置管理员
|
|
|
|
|
|
// QXRoomMessageTypeSetManage = 1006,
|
|
|
|
|
|
// /// 设置主持
|
|
|
|
|
|
// QXRoomMessageTypeSetCompere = 1007,
|
|
|
|
|
|
// /// 禁麦/解禁
|
|
|
|
|
|
// QXRoomMessageTypeSeatMute = 1008,
|
|
|
|
|
|
// /// 锁麦/解除锁麦
|
|
|
|
|
|
// QXRoomMessageTypeSeatLock = 1009,
|
|
|
|
|
|
// /// 踢出房间
|
|
|
|
|
|
// QXRoomMessageTypeTakeOff = 1011,
|
|
|
|
|
|
// /// 房间类型发生变化
|
|
|
|
|
|
// QXRoomMessageTypeRoomTypeChanged = 1012,
|
|
|
|
|
|
// /// 申请点歌/切歌/同意点歌
|
|
|
|
|
|
// QXRoomMessageTypeSwicthSong = 1013,
|
|
|
|
|
|
//房间上麦模式改变
|
|
|
|
|
|
// UpRoomPItType = 1014,
|
|
|
|
|
|
//pk房数值变化
|
|
|
|
|
|
// PkRoomVaule = 1015,
|
|
|
|
|
|
//禁言,禁麦。解禁
|
|
|
|
|
|
// SeatMute = 1016,
|
|
|
|
|
|
//删除管理员
|
|
|
|
|
|
// DeleteManager = 1017,
|
|
|
|
|
|
// 删除主持
|
|
|
|
|
|
// DeleteCompere = 1018,
|
|
|
|
|
|
//K歌房送礼后魅力变化 排序变化
|
|
|
|
|
|
// KRoomGiftChange = 1019,
|
|
|
|
|
|
//修改房间信息
|
|
|
|
|
|
// ModifyRoomInfo = 1020,
|
|
|
|
|
|
//清除房间魅力
|
|
|
|
|
|
// ClearRoomCharm = 1021,
|
|
|
|
|
|
|
|
|
|
|
|
//拍卖者被抱上麦
|
|
|
|
|
|
// AuctionerUpSeat = 1022,
|
|
|
|
|
|
//拍卖者选完关系(拍卖开始)
|
|
|
|
|
|
// AuctionerSelectRelation = 1023,
|
|
|
|
|
|
//参与竞拍
|
|
|
|
|
|
// RoomAuctionJoin = 1024,
|
|
|
|
|
|
//竞拍结束
|
|
|
|
|
|
// RoomAuctionEnd = 1025,
|
|
|
|
|
|
//拍卖延时
|
|
|
|
|
|
// RoomAuctionDelay = 1026,
|
|
|
|
|
|
//竞拍类型转换
|
|
|
|
|
|
// RoomAuctionTypeChange = 1027,
|
|
|
|
|
|
//cp房送礼物推送心动值
|
|
|
|
|
|
// KRoomGiftChange = 1028,
|
|
|
|
|
|
//PK房发起邀请
|
|
|
|
|
|
// RoomAuctionPK = 1029,
|
|
|
|
|
|
//房间PK 拒绝和同意
|
|
|
|
|
|
// RoomAuctionPK = 1030,
|
|
|
|
|
|
//房间PK 开始
|
|
|
|
|
|
// RoomAuctionPK = 1031,
|
|
|
|
|
|
//房间PK 结束
|
|
|
|
|
|
// RoomAuctionPK = 1032,
|
|
|
|
|
|
//房间PK 断开
|
|
|
|
|
|
// RoomAuctionPK = 1033,
|
|
|
|
|
|
//申请上麦
|
|
|
|
|
|
// RoomApplyOnPit = 1034,
|
|
|
|
|
|
//用户修改信息
|
|
|
|
|
|
// ModifyUserInfo = 1035,
|
|
|
|
|
|
//房间在线人数
|
|
|
|
|
|
// RoomOnlineNumber = 1036,
|
|
|
|
|
|
//房间PK 失败者在惩罚阶段提前申请断开链接
|
|
|
|
|
|
// RoomAuctionPK = 1037,
|
|
|
|
|
|
//送盲盒礼物推送文字消息
|
|
|
|
|
|
// RoomGiftBlindBox = 1038,
|
2025-09-01 17:03:40 +08:00
|
|
|
|
//换麦
|
|
|
|
|
|
// RoomChangePit = 1039,
|
2025-08-13 10:43:56 +08:00
|
|
|
|
|
2025-08-16 18:48:10 +08:00
|
|
|
|
//交友房间内发送消息
|
|
|
|
|
|
//交友房游戏阶段
|
2025-08-20 15:15:47 +08:00
|
|
|
|
// FriendRoomGameStart = 1049,
|
2025-08-16 18:48:10 +08:00
|
|
|
|
//交友房延时
|
2025-08-20 15:15:47 +08:00
|
|
|
|
// FriendRoomDelay = 1050,
|
2025-08-16 18:48:10 +08:00
|
|
|
|
//交友结束推送是否创建小房间
|
2025-08-20 15:15:47 +08:00
|
|
|
|
// FriendRoomEnd = 1051,
|
2025-08-18 16:33:01 +08:00
|
|
|
|
//交友房 私密小屋送礼增加结束时间
|
2025-08-20 15:15:47 +08:00
|
|
|
|
// FriendRoomGiftBlindBox = 1052,
|
2025-08-21 11:15:53 +08:00
|
|
|
|
//交友 房间换麦位
|
|
|
|
|
|
// FriendRoomChangePit = 1053,
|
|
|
|
|
|
//交友 心动值变化
|
|
|
|
|
|
// FriendRoomChangeCharm = 1054,
|
2025-08-22 15:18:36 +08:00
|
|
|
|
//交友 退出小房间
|
|
|
|
|
|
// FriendRoomQuit = 1055,
|
2025-08-16 18:48:10 +08:00
|
|
|
|
|
2025-08-28 20:09:58 +08:00
|
|
|
|
//盲盒转盘相关推送
|
|
|
|
|
|
//巡乐会进度推送
|
|
|
|
|
|
// BlindBoxTurnTableProgress = 1056,
|
|
|
|
|
|
//巡乐会抽奖结果推送
|
|
|
|
|
|
// BlindBoxTurnTableResult = 1057,
|
|
|
|
|
|
|
2025-09-02 18:29:57 +08:00
|
|
|
|
//直播群成员在离线状态变更
|
|
|
|
|
|
// RoomMemberOffline = 1058,
|
|
|
|
|
|
|
2025-09-09 17:59:10 +08:00
|
|
|
|
//清空个人魅力
|
|
|
|
|
|
// ClearUserCharm = 1059,
|
|
|
|
|
|
|
2025-08-16 18:48:10 +08:00
|
|
|
|
|
2025-08-13 10:43:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$text = [
|
|
|
|
|
|
'MsgType' => $type,
|
|
|
|
|
|
'RoomId' => $roomId,
|
|
|
|
|
|
'Text' => $content
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
$data = model('api/Tencent')->send_group_system_notification('room'.$roomId,json_encode($text));
|
|
|
|
|
|
|
|
|
|
|
|
if($data['code'] == 0){
|
|
|
|
|
|
Log::record("腾讯发送群消息:".$data['msg'].$type,"info");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
Log::record("腾讯发送群消息:".$data['msg'].$type,"info");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//指定用户发送给谁单聊消息
|
|
|
|
|
|
public function sendMsgToUser($userId,$ToUserId,$content,$type = 2000)
|
|
|
|
|
|
{
|
|
|
|
|
|
//type 2000 发起PK
|
|
|
|
|
|
/*
|
|
|
|
|
|
* $text = [
|
|
|
|
|
|
'SendUserId' => $create_user_id,//发送者id
|
|
|
|
|
|
'SendUserName' => db::name('user')->where('id', $create_user_id)->value('nickname'),//发送者昵称
|
|
|
|
|
|
'RoomId' => $room_id_a,//发起者所在房间id
|
|
|
|
|
|
'AcceptRoomId' => $room_id_b,//接受者所在房间id
|
|
|
|
|
|
'Text' => 'PK邀请',
|
|
|
|
|
|
];
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
$text = [
|
|
|
|
|
|
'MsgType' => $type,
|
|
|
|
|
|
'ToUserId' => $ToUserId,
|
|
|
|
|
|
'Text' => $content
|
|
|
|
|
|
];
|
|
|
|
|
|
//谁发送给谁,什么消息,是否同步到发送者1是,2否,消息是否只下发给在线用户 1 是,0 否
|
|
|
|
|
|
model('Tencent')->user_sendmsg($userId,$ToUserId,json_encode($text),2,1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|