66 lines
2.6 KiB
PHP
66 lines
2.6 KiB
PHP
<?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/d', 0);//房间ID
|
||
$gift_id = input('gift_id/d', 0);//礼物ID
|
||
$gift_num = (int)input('gift_num/d', 1);//礼物数量
|
||
$to_uid = input('to_uid', 0);//收礼人ID,逗号隔开的字符串
|
||
$type = input('type/d', 1);//1金币购买 2送背包礼物
|
||
$heart_id = input('heart_id/d', 0);//助力时的 ID
|
||
$gift_bag_id = input('gift_bag_id/d', 0);//盲盒类型ID 7-初级,8-中级,9-高级
|
||
|
||
if($room_id <= 0 || $gift_id <= 0 || $to_uid <= 0 || $type <= 0){
|
||
redis_unlocks($key_name);
|
||
return V(0, '参数错误');
|
||
}
|
||
|
||
//获取幸运币
|
||
$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);
|
||
|
||
//送礼 (送礼用户,收礼用户组,礼物ID,数量,礼物类型,房间ID )
|
||
$reslut = model('SendGift')->send_gift($this->uid, $to_uid, $gift_id, $gift_num, $type, $room_id, $gift_bag_id, $heart_id);
|
||
|
||
if($room_type == 2){//2:练歌房(声网点歌)
|
||
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']);
|
||
}
|
||
|
||
redis_unlocks($key_name);
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
}
|
||
} |