2026-01-05 15:16:42 +08:00
|
|
|
|
<?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);
|
2026-01-05 15:43:02 +08:00
|
|
|
|
redis_unlocks($key_name);
|
|
|
|
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
}else{
|
2026-01-05 15:43:02 +08:00
|
|
|
|
//获取房间类型 1:交友/pk(二卡八),2:练歌房(声网点歌),3:亲密拍,4:真爱拍,6:私密房,7:互娱房,9:点唱/歌手房,10:签约房,11:酒吧房
|
2026-01-05 15:16:42 +08:00
|
|
|
|
$room_type = model('Room')->get_room_type($room_id);
|
2026-01-05 15:43:02 +08:00
|
|
|
|
|
|
|
|
|
|
//送礼
|
|
|
|
|
|
$reslut = model('SendGift')->give_gift($this->uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number,0,);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
if($room_type == 1){
|
2026-01-05 15:43:02 +08:00
|
|
|
|
redis_unlocks($key_name);
|
|
|
|
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
}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歌房送礼后魅力变化 排序变化
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-01-05 15:43:02 +08:00
|
|
|
|
redis_unlocks($key_name);
|
|
|
|
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
redis_unlocks($key_name);
|
|
|
|
|
|
return V(1, '送礼成功');
|
2026-01-05 15:16:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-05 15:43:02 +08:00
|
|
|
|
}
|
2026-01-05 15:16:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|