认证歌手 收礼升等级

This commit is contained in:
2025-11-13 11:25:46 +08:00
parent 8bc77df88d
commit 3d7a3226c8
2 changed files with 30 additions and 0 deletions

View File

@@ -193,6 +193,9 @@ class GiveGift extends Model
Db::rollback();
return ['code' => 0, 'msg' => '收礼人收益配置有误', 'data' => null];
}
//收礼人认证歌手等级升级
model('SingerSong')->singerLevelUp($to_id,$gift_price);
//1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏 5系统任务 6-cp房间送礼
if($from_type == 1 || $from_type == 2 || $from_type == 3 ||$from_type == 4 || $from_type == 6){
//增加收益并记录日志
@@ -650,6 +653,10 @@ class GiveGift extends Model
if($receiver_earnings <= 0){
return ['code' => 0, 'msg' => '收礼人收益配置有误', 'data' => null];
}
//收礼人认证歌手等级升级
model('SingerSong')->singerLevelUp($to_id,$gift_price);
//1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏 5系统任务 6-cp房间送礼
if($from_type == 1 || $from_type == 2 || $from_type == 3 ||$from_type == 4 || $from_type == 6){
//增加收益并记录日志

View File

@@ -214,4 +214,27 @@ class SingerSong extends Model
}
return ['code' => 1, 'msg' => '获取成功', 'data' => $res];
}
/*
* 歌手等级收礼升级
* @param user_id 用户id
*/
public function singerLevelUp($user_id,$coin)
{
//判断用户是否认证歌手
$is_singer = db::name('vs_singer')->where(['user_id' => $user_id,'status' => 1])->find();
if ($is_singer) {
//增加经验值并且判断是否可以升级
$exp = db::name('vs_singer')->where(['id' => $is_singer['id']])->value('exp');
$exp_coin = round($coin / get_system_config_value('singer_coin_exp'), 2);
$exps = $exp + $exp_coin;
//查询等级
$level = db::name('vs_singer_level')->where(['exp' => ['<=', $exps]])->order('exp desc')->find();
if ($level) {
db::name('vs_singer')->where(['id' => $is_singer['id']])->update(['exp' => $exps,'level' => $level['level']]);
}
}
return true;
}
}