From 2fd11dcab76c8dac6e900ed664d170a382631f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Fri, 14 Nov 2025 15:26:04 +0800 Subject: [PATCH] =?UTF-8?q?CP=20=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/UserCp.php | 6 ++++-- application/api/model/Chat.php | 6 ++++++ application/api/model/UserCp.php | 30 +++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/application/api/controller/UserCp.php b/application/api/controller/UserCp.php index f82e153..3a363a2 100644 --- a/application/api/controller/UserCp.php +++ b/application/api/controller/UserCp.php @@ -8,9 +8,11 @@ use think\Db; class UserCp extends BaseCom { - //检测是否送了一个cp礼物 - public function checkCp() + //Cp 空间 + public function cpZone() { + $reslut = model('UserCp')->cpZone($this->uid); + return V($reslut['code'], $reslut['msg'], $reslut['data']); } } \ No newline at end of file diff --git a/application/api/model/Chat.php b/application/api/model/Chat.php index 3f4f2d8..d231040 100644 --- a/application/api/model/Chat.php +++ b/application/api/model/Chat.php @@ -128,6 +128,12 @@ class Chat extends Model //歌曲发生变化 // SongChange = 1070, + //CP房间推送信息 + // CP房间表达心动信号 + // CPRoomExpression = 1080, + // CP组建成功 + // CPRoomBuildSuccess = 1081, + diff --git a/application/api/model/UserCp.php b/application/api/model/UserCp.php index cf189f3..95aa59c 100644 --- a/application/api/model/UserCp.php +++ b/application/api/model/UserCp.php @@ -142,4 +142,34 @@ class UserCp extends Model Db::name('user_cp_zone')->where(['id' => $cp_zone_id])->update($data); return true; } + + + /* + * Cp空间 + * @param $user_id 用户ID + */ + public function cpZone($user_id) + { + $res = Db::name('user_cp_zone')->where(['user_id1' => $user_id,'status' => 1])->select(); + if(!$res){ + $res = Db::name('user_cp_zone')->where(['user_id2' => $user_id,'status' => 1])->select(); + } + if($res){ + $res['user_info1'] = Db::name('user')->where(['id' => $res['user_id1']])->field('id user_id,nickname,avatar')->find(); + $res['user_info2'] = Db::name('user')->where(['id' => $res['user_id2']])->field('id user_id,nickname,avatar')->find(); + //升下一级所需经验值 + $next_level_exp = Db::name('user_cp_level')->where(['level' => ['>',$res['level']]])->order('level asc')->value('exp'); + $res['next_level_exp'] = $next_level_exp - $res['exp']; + //送礼记录 + $res['gift_log'] = Db::name('user_cp_gift_log')->where(['cp_zone_id' => $res['id']])->select(); + foreach ($res['gift_log'] as &$v){ + $v['gift_name'] = Db::name('vs_gift')->where(['gid' => $v['gift_id']])->value('gift_name'); + $v['from_user_info'] = Db::name('user')->where(['id' => $v['from_user_id']])->field('id user_id,nickname,avatar')->find(); + $v['to_user_info'] = Db::name('user')->where(['id' => $v['to_user_id']])->field('id user_id,nickname,avatar')->find(); + } + return ['code' => 1, 'msg' => '成功', 'data' => $res ]; + }else{ + return ['code' => 0, 'msg' => '暂无Cp空间', 'data' => null]; + } + } } \ No newline at end of file