Files
yusheng-php/application/api/controller/SendGift.php
2026-01-05 15:43:02 +08:00

64 lines
2.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\api\controller;
use app\common\controller\BaseCom;
use think\Db;
class SendGift extends BaseCom
{
/*
* 送礼
* @param int $gift_id
*/
public function send_gift()
{
$key_name = "api:send:gift:" . $this->uid;
redis_lock_exits($key_name);
$room_id = input('room_id', 0);//房间ID
$gift_id = input('gift_id', 0);//礼物ID
$gift_num = (int)input('gift_num', 1);//礼物数量
$to_uid = input('to_uid', 0);//收礼人ID逗号隔开的字符串
$type = input('type', 1);//1金币购买 2送背包礼物
$pit_number = input('pit_number', 0);
$heart_id = input('heart_id', 0);//助力时的 ID
//获取幸运币
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
if($gift_id == $pool_gift_id){//送的是幸运币
$reslut = model('Lottery')->gift($this->uid, $to_uid, $gift_id, $room_id,$gift_num);
redis_unlocks($key_name);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}else{
//获取房间类型 1:交友/pk(二卡八),2:练歌房(声网点歌),3:亲密拍,4:真爱拍,6:私密房,7:互娱房,9:点唱/歌手房,10:签约房,11:酒吧房
$room_type = model('Room')->get_room_type($room_id);
//送礼
$reslut = model('SendGift')->give_gift($this->uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number,0,);
if($room_type == 1){
redis_unlocks($key_name);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}elseif ($room_type == 2){
$reslut = model('GiveGift')->give_gift($this->uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number,0,$give_gift_ext);
if($reslut['code'] == 1){
$room_pits = model('RoomSong')->get_charm_rank($room_id);
if($room_pits['code'] == 1){
$room_pit = $room_pits['data'];
//推送给前端
$text = [
'userCharmList' => $room_pit,
];
model('Chat')->sendMsg(1019,$room_id,$text);//K歌房送礼后魅力变化 排序变化
}
}
redis_unlocks($key_name);
return V($reslut['code'], $reslut['msg'], $reslut['data']);
}else{
redis_unlocks($key_name);
return V(1, '送礼成功');
}
}
}
}