送礼优化 相关

This commit is contained in:
2026-01-06 17:40:13 +08:00
parent 581122b4d9
commit 132e9df303
13 changed files with 2167 additions and 1526 deletions

View File

@@ -321,16 +321,12 @@ class Friend extends Model
* @param $room_id 房间id
* @param $pit_number 坑位
*/
public function room_give_gift($uid, $to_uid, $gift_id, $gift_num, $from_type, $type, $room_id, $pit_number, $heart_id,$give_gift_ext)
public function room_give_gift($uid, $to_uid,$room_id,$res,$heart_id = 0)
{
$res = model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num, $from_type, $type, $room_id, $pit_number,0,$give_gift_ext);
if($res['code'] != 1){
return $res;
}
//送礼成功后续操作
//查看当前时间是否在交友表的创建时间和结束时间段内 用来区分是否要拉取心动值高的用户上麦
$friend = db::name('vs_user_friending')->where(['room_id' => $room_id,'status' => 1])->order('id desc')->find();
//查看当前时间是否在交友表的创建时间和结束时间段内 用来区分是否要拉取心动值高的用户上麦
if($friend && time() >= $friend['create_time'] && time() <= $friend['end_time']){
$heart_exp = get_system_config_value('coin_charm_exp');//金币与魅力值转换比
$sumPrice = $res['data']['gift_total'] * $heart_exp;
@@ -338,7 +334,7 @@ class Friend extends Model
if($heart_id){//有这个值就是助力 不参加抢麦操作
db::name('vs_user_friending_heart')->where(['id' => $heart_id])->setInc('heart_value', $sumPrice);
$this->pullHeartChange($room_id,$friend['id']);//聊天室心动值变化通知
// $this->pullHeartChange($room_id,$friend['id']);//聊天室心动值变化通知 注释掉是因为下面那个函数会处理
//生成新排名 判断抱上麦 还是换麦
$this->pullUserPit($room_id,$friend['id']);
}else{
@@ -346,7 +342,7 @@ class Friend extends Model
$host = $this->is_host($uid,$to_uid,$room_id);
$user_idd = explode(",", $user_idd); // 将字符串转换为数组
//判断是否是主持
if($host['is_preside'] == 1){
if($host && $host['is_preside'] == 1){
if(!in_array($uid,$host['is_preside_user'])){//主持不是当前送礼人,那就是在收礼人中
//从数组中剔除主持人 && $is_preside_user!= UID
$user_idd = array_diff($user_idd, $host['is_preside_user']); // 从数组中移除
@@ -382,13 +378,13 @@ class Friend extends Model
foreach ($user_ids as $value) {
//判断收礼人是否是主持
if (in_array($value, $host)) {
$is_preside = 1;
$is_preside = 1;//是主持
$is_preside_user[] = $value;
}
}
//送礼人是主持或嘉宾
if (in_array($uid, $host)) {
$is_preside = 1;
$is_preside = 1;//是嘉宾
$is_preside_user[] = $uid;
}
return ['is_preside' =>$is_preside,'is_preside_user' => $is_preside_user];