2025-08-16 19:10:54 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\api\model;
|
2025-08-25 19:31:12 +08:00
|
|
|
use app\common\controller\Push;
|
2025-09-04 18:26:01 +08:00
|
|
|
use think\Cache;
|
2025-08-16 19:10:54 +08:00
|
|
|
use think\Model;
|
|
|
|
|
use think\Db;
|
|
|
|
|
use think\Session;
|
|
|
|
|
/*
|
|
|
|
|
* 盲盒转盘
|
|
|
|
|
* 2025-08-16
|
|
|
|
|
*/
|
|
|
|
|
class BlindBoxTurntableGift extends Model
|
|
|
|
|
{
|
|
|
|
|
// 开启自动写入时间戳字段
|
|
|
|
|
protected $autoWriteTimestamp = true;
|
|
|
|
|
// 定义时间戳字段名
|
|
|
|
|
protected $createTime = 'createtime';
|
|
|
|
|
protected $updateTime = 'updatetime';
|
|
|
|
|
protected $table = 'fa_vs_gift';
|
|
|
|
|
|
2025-08-18 19:15:06 +08:00
|
|
|
//获取奖池礼物列表
|
2025-08-25 19:31:12 +08:00
|
|
|
public function get_gift_list($gift_bag_id,$room_id)
|
2025-08-16 19:10:54 +08:00
|
|
|
{
|
2025-08-18 19:15:06 +08:00
|
|
|
$box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find();
|
2025-08-16 19:10:54 +08:00
|
|
|
$gifts = db::name('vs_gift_bag_detail')->where('gift_bag_id',$gift_bag_id)->order("id desc")->select();
|
|
|
|
|
$gift_list = [];
|
|
|
|
|
foreach ($gifts as $key => $value) {
|
|
|
|
|
$gift_data = db::name('vs_gift')->where('gid',$value['foreign_id'])->where('delete_time',0)->find();
|
|
|
|
|
if($gift_data){
|
|
|
|
|
$gift_list[$key]['number'] = $key;
|
|
|
|
|
$gift_list[$key]['gift_id'] = $gift_data['gid'];
|
|
|
|
|
$gift_list[$key]['gift_name'] = $gift_data['gift_name'];
|
|
|
|
|
$gift_list[$key]['base_image'] = $gift_data['base_image'];
|
|
|
|
|
$gift_list[$key]['play_image'] = $gift_data['play_image'];
|
|
|
|
|
$gift_list[$key]['gift_price'] = $gift_data['gift_price'];
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-18 19:15:06 +08:00
|
|
|
$ext = json_decode($box['ext'],true);
|
|
|
|
|
$box_gift = Db::name('vs_gift')->where('gid',$ext['gift_id'])->find();
|
2025-08-25 19:31:12 +08:00
|
|
|
|
|
|
|
|
//巡乐会
|
|
|
|
|
$is_xlh = 0;
|
|
|
|
|
$xlh_box = db::name('vs_gift_bag')->where('id',13)->find();
|
|
|
|
|
$xlh_ext = json_decode($xlh_box['ext'],true);
|
|
|
|
|
$xlh = [];
|
|
|
|
|
if($xlh_ext['inlet_bag_id'] == $box['id']){
|
|
|
|
|
$is_xlh = 1;
|
|
|
|
|
$xlh['waiting_start_num'] = $xlh_ext['open_condition']['waiting_start_num'];//等待开奖次数
|
|
|
|
|
$xlh['start_num'] = $xlh_ext['open_condition']['start_num'];//开始开奖次数
|
|
|
|
|
//当前抽奖次数
|
2025-10-13 14:10:54 +08:00
|
|
|
$xlh['current_num'] = Cache::get("xlh_periods_num") ?? 0;
|
2025-08-25 19:31:12 +08:00
|
|
|
//状态
|
|
|
|
|
if($xlh['current_num'] >= $xlh_ext['open_condition']['start_num']){
|
|
|
|
|
$xlh['status'] = 1;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始
|
|
|
|
|
} elseif($xlh['current_num'] >= $xlh_ext['open_condition']['waiting_start_num'] && $xlh['current_num'] < $xlh_ext['open_condition']['start_num']){
|
|
|
|
|
$xlh['status'] = 2;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始
|
|
|
|
|
}else{
|
|
|
|
|
$xlh['status'] = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-18 19:15:06 +08:00
|
|
|
$result_data = [
|
|
|
|
|
'title' => $box['name'],
|
|
|
|
|
'rule_url' => get_system_config_value('web_site')."/api/Page/get_gift_box_rule?box_id=".$box["id"],
|
|
|
|
|
'box_price' => $box_gift['gift_price'],
|
2025-08-25 19:31:12 +08:00
|
|
|
'is_xlh' => $is_xlh,
|
|
|
|
|
'xlh_data' => $xlh,
|
2025-08-18 19:15:06 +08:00
|
|
|
'gift_list' => $gift_list,
|
|
|
|
|
];
|
|
|
|
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $result_data];
|
|
|
|
|
}
|
2025-09-10 22:41:11 +08:00
|
|
|
|
2025-08-18 19:15:06 +08:00
|
|
|
/*
|
2025-09-16 16:37:25 +08:00
|
|
|
* 礼物特效播放
|
2025-08-18 19:15:06 +08:00
|
|
|
*/
|
|
|
|
|
public function gift_send($send_id){
|
2025-09-24 22:52:40 +08:00
|
|
|
try{
|
|
|
|
|
$blind_box_turntable = db('vs_blind_box_turntable_log')->where(['id'=>$send_id,'is_sued'=>0])->find();
|
|
|
|
|
if(!$blind_box_turntable){
|
|
|
|
|
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
|
|
|
|
}
|
|
|
|
|
$room_id = $blind_box_turntable['room_id'];
|
|
|
|
|
$blind_box_turntable_log = db('vs_blind_box_turntable_results_log')->where(['tid'=>$send_id])->select();
|
|
|
|
|
if(!$blind_box_turntable_log){
|
|
|
|
|
return ['code' => 0, 'msg' => '数据不存在','data' => null];
|
2025-09-16 18:08:15 +08:00
|
|
|
}
|
2025-09-24 22:52:40 +08:00
|
|
|
$room_name = Db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->value('room_name');
|
|
|
|
|
$FromUserInfo = Db::name('user')->where(['id'=>$blind_box_turntable['user_id']])->find();
|
|
|
|
|
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($blind_box_turntable['user_id']);//财富图标
|
|
|
|
|
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($blind_box_turntable['user_id']);//魅力图标
|
|
|
|
|
$user_nickname = $FromUserInfo['nickname'];
|
|
|
|
|
$textMessage = $user_nickname;
|
|
|
|
|
$text_message = [];
|
|
|
|
|
foreach ($blind_box_turntable_log as $key => $value) {
|
|
|
|
|
$ToUserInfo = Db::name('user')->where(['id' => $value['gift_user_id']])->field('id as user_id,nickname,avatar,sex')->find();
|
|
|
|
|
$draw_gift = Db::name('vs_gift')->where(['gid'=>$value['gift_id']])->find();
|
|
|
|
|
$textMessage = $textMessage . ' 送给 ' . $ToUserInfo['nickname']. ' 盲盒转盘礼物 ' . $draw_gift['gift_name'].' x ' .$value['count']."\n";
|
|
|
|
|
$play_image[] = $draw_gift['play_image'];
|
|
|
|
|
$gift_names[] = $draw_gift['gift_name'];
|
|
|
|
|
|
|
|
|
|
$text_message = $user_nickname . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $draw_gift['gift_name'] . 'X' . $value['count']."\n";
|
|
|
|
|
if($draw_gift['is_public_server'] == 1) {
|
|
|
|
|
$text_list_new[] = [
|
|
|
|
|
'text' => $text_message,
|
|
|
|
|
'gift_picture' => $draw_gift['base_image'],
|
|
|
|
|
'room_id' => $room_id,
|
|
|
|
|
'fromUserName' => $FromUserInfo['nickname'],
|
|
|
|
|
'toUserName' => $ToUserInfo['nickname'],
|
|
|
|
|
'giftName' => $draw_gift['gift_name'],
|
|
|
|
|
'roomId' => $room_id,
|
|
|
|
|
'number' => $value['count'],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$ToUserInfosList[$value['gift_user_id']] = $ToUserInfo;
|
2025-09-16 16:37:25 +08:00
|
|
|
|
2025-09-24 22:52:40 +08:00
|
|
|
}
|
|
|
|
|
foreach($ToUserInfosList as &$userInfo) {
|
|
|
|
|
$userInfo['icon'][0] = model('UserData')->user_wealth_icon($userInfo['user_id']);//财富图标
|
|
|
|
|
$userInfo['icon'][1] = model('UserData')->user_charm_icon($userInfo['user_id']);//魅力图标
|
|
|
|
|
$userInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $userInfo['user_id'],'room_id' => $room_id])->value('charm');//魅力
|
|
|
|
|
$ToUserInfos[] = $userInfo;
|
|
|
|
|
}
|
|
|
|
|
$text = [
|
|
|
|
|
'FromUserInfo' => $FromUserInfo,
|
|
|
|
|
'ToUserInfos' => $ToUserInfos,
|
|
|
|
|
'GiftInfo' => [
|
|
|
|
|
'play_image' => implode(',',$play_image),
|
|
|
|
|
'gift_name' => implode(',',$gift_names),
|
|
|
|
|
],
|
|
|
|
|
'text' => rtrim($textMessage, "\n")
|
2025-09-16 16:37:25 +08:00
|
|
|
];
|
|
|
|
|
//聊天室推送系统消息
|
2025-09-24 22:52:40 +08:00
|
|
|
model('Chat')->sendMsg(1005,$room_id,$text);
|
|
|
|
|
$roomtype = Db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
|
|
|
|
if($roomtype == 6){
|
|
|
|
|
//推送消息
|
|
|
|
|
$hot_value = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',6)
|
|
|
|
|
->sum('total_price');
|
|
|
|
|
$text1 = [
|
|
|
|
|
'room_id' => $room_id,
|
|
|
|
|
'hot_value' => $hot_value * 10,
|
|
|
|
|
'text' => '房间心动值变化'
|
|
|
|
|
];
|
|
|
|
|
//聊天室推送系统消息
|
|
|
|
|
model('Chat')->sendMsg(1028,$room_id,$text1);
|
|
|
|
|
}else{
|
|
|
|
|
if(!empty($text_list_new)){
|
|
|
|
|
//推送礼物横幅
|
|
|
|
|
$push = new Push($blind_box_turntable['user_id'], $room_id);
|
|
|
|
|
$push->giftBanner($text_list_new);
|
|
|
|
|
}
|
2025-08-18 19:15:06 +08:00
|
|
|
}
|
2025-09-24 22:52:40 +08:00
|
|
|
db::name('vs_blind_box_turntable_log')->where('id', $send_id)->update(['is_sued' => 1, 'updatetime' => time()]);
|
|
|
|
|
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
return ['code' => 0, 'msg' => "网络请求错误,请重试!", 'data' => null];
|
2025-08-19 18:09:48 +08:00
|
|
|
}
|
2025-09-24 22:52:40 +08:00
|
|
|
|
2025-08-19 18:09:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 获取用户抽奖记录
|
|
|
|
|
*/
|
|
|
|
|
public function get_user_record($gift_bag_id,$user_id=0,$page=1,$page_size=12){
|
|
|
|
|
$where = [];
|
|
|
|
|
$where['b.gift_bag_id'] = $gift_bag_id;
|
|
|
|
|
if($user_id > 0){
|
|
|
|
|
$where['b.user_id'] = $user_id;
|
|
|
|
|
}
|
|
|
|
|
$list = db('vs_blind_box_turntable_results_log')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('vs_blind_box_turntable_log b','b.id = a.tid','left')
|
|
|
|
|
->join('user c','a.gift_user_id = c.id','left')
|
|
|
|
|
->join('vs_gift d','d.gid = a.gift_id','left')
|
2025-09-17 18:45:07 +08:00
|
|
|
->field('a.gift_id,a.count,a.gift_user_id,a.createtime,c.nickname,d.gift_name as gift_name,d.base_image')
|
2025-08-19 18:09:48 +08:00
|
|
|
->where($where)
|
2025-09-17 18:45:07 +08:00
|
|
|
->order('a.createtime desc')
|
2025-08-19 18:09:48 +08:00
|
|
|
->page($page,$page_size)
|
|
|
|
|
->select();
|
|
|
|
|
foreach ($list as &$v){
|
|
|
|
|
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
|
|
|
|
}
|
|
|
|
|
return ['code' => 1, 'msg' => '成功', 'data' => $list];
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* 获取全服抽奖记录
|
|
|
|
|
*/
|
|
|
|
|
public function get_all_record($gift_bag_id,$page=1,$page_size=12){
|
|
|
|
|
$where = [];
|
|
|
|
|
$where['b.gift_bag_id'] = $gift_bag_id;
|
|
|
|
|
$where['d.gift_bag_id'] = $gift_bag_id;
|
|
|
|
|
$where['d.is_world_show'] = 1;
|
|
|
|
|
$list = db('vs_blind_box_turntable_results_log')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('vs_blind_box_turntable_log b','b.id = a.tid','left')
|
|
|
|
|
->join('user c','b.user_id = c.id','left')
|
|
|
|
|
->join('vs_gift_bag_detail d','d.foreign_id = a.gift_id','left')
|
|
|
|
|
->join('vs_gift e','e.gid = a.gift_id','left')
|
2025-09-17 18:45:07 +08:00
|
|
|
->field('a.gift_id,a.count,b.user_id,a.createtime,c.nickname,d.name as gift_name,e.base_image')
|
2025-08-19 18:09:48 +08:00
|
|
|
->where($where)
|
2025-09-17 18:45:07 +08:00
|
|
|
->order('a.createtime desc')
|
2025-08-19 18:09:48 +08:00
|
|
|
->page($page,$page_size)
|
|
|
|
|
->select();
|
|
|
|
|
foreach ($list as &$v){
|
|
|
|
|
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
2025-08-18 19:15:06 +08:00
|
|
|
}
|
2025-08-19 18:09:48 +08:00
|
|
|
return ['code' => 1, 'msg' => '成功', 'data' => $list];
|
2025-08-16 19:10:54 +08:00
|
|
|
}
|
2025-08-26 16:19:26 +08:00
|
|
|
/*
|
|
|
|
|
* 巡乐会
|
|
|
|
|
*/
|
|
|
|
|
public function xlh_gift_list($room_id){
|
2025-09-25 16:35:22 +08:00
|
|
|
$room_data = db::name('vs_room')->field('xlh_periods,xlh_periods_num,user_id')-> where('id',$room_id)->find();
|
|
|
|
|
if(empty($room_data)){
|
|
|
|
|
return ['code' => 0, 'msg' => '房间不存在!', 'data' => null];
|
|
|
|
|
}
|
2025-08-26 16:19:26 +08:00
|
|
|
$gift_bag_id = 13;
|
|
|
|
|
$xlh_box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find();
|
|
|
|
|
$xlh_ext = json_decode($xlh_box['ext'],true);
|
|
|
|
|
$gifts = db::name('vs_gift_bag_detail')->where('gift_bag_id',$gift_bag_id)->order("id desc")->select();
|
|
|
|
|
$gift_list = [];
|
|
|
|
|
foreach ($gifts as $key => $value) {
|
|
|
|
|
$gift_data = db::name('vs_gift')->where('gid',$value['foreign_id'])->where('delete_time',0)->find();
|
|
|
|
|
if($gift_data){
|
|
|
|
|
$gift_list[$key]['number'] = $key;
|
|
|
|
|
$gift_list[$key]['gift_id'] = $gift_data['gid'];
|
|
|
|
|
$gift_list[$key]['gift_name'] = $gift_data['gift_name'];
|
|
|
|
|
$gift_list[$key]['base_image'] = $gift_data['base_image'];
|
|
|
|
|
$gift_list[$key]['play_image'] = $gift_data['play_image'];
|
|
|
|
|
$gift_list[$key]['gift_price'] = $gift_data['gift_price'];
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-25 16:35:22 +08:00
|
|
|
//房主信息
|
|
|
|
|
$room_user = db::name('user')->where('id',$room_data['user_id'])->find();
|
2025-08-26 16:19:26 +08:00
|
|
|
//房主礼物
|
|
|
|
|
$room_user_gift = db::name('vs_gift')->where('gid',$xlh_ext['locking_condition']['give_homeowner_gift_id'])->find();
|
|
|
|
|
//巡乐会主礼物
|
|
|
|
|
$xlh_main_gift = db::name('vs_gift')->where('gid',$xlh_ext['locking_condition']['locking_gift_id'])->find();
|
|
|
|
|
//中奖用户
|
2025-10-13 18:07:08 +08:00
|
|
|
$pan_xlh = db::name('vs_room_pan_xlh')->where(['send_time'=>0,'end_time'=>['>',time()]])->order('id desc')->find();
|
2025-10-13 16:10:37 +08:00
|
|
|
$xlh_periods_num = Cache::get("xlh_periods_num") ?? 0;
|
2025-08-26 18:16:22 +08:00
|
|
|
if(empty($pan_xlh)){
|
2025-10-13 16:10:37 +08:00
|
|
|
if($xlh_periods_num >= $xlh_ext['open_condition']['start_num']){
|
2025-10-13 18:07:08 +08:00
|
|
|
$xlh_periods = Cache::get("this_xlh_periods") ?? 0;
|
2025-09-22 09:28:10 +08:00
|
|
|
$pan_xlh_id = db::name('vs_room_pan_xlh')->insertGetId([
|
|
|
|
|
'room_id' => $room_id,
|
|
|
|
|
'gift_id' => $xlh_ext['locking_condition']['locking_gift_id'],
|
|
|
|
|
'homeowner_gift_id' => $xlh_ext['locking_condition']['give_homeowner_gift_id'],
|
|
|
|
|
'periods' => $xlh_periods+1,
|
|
|
|
|
'num' => 0,
|
|
|
|
|
'end_time' => time() + $xlh_ext['locking_time']['end_time'] * 60,
|
|
|
|
|
'createtime' => time()
|
|
|
|
|
]);
|
2025-10-13 18:07:08 +08:00
|
|
|
Cache::set("this_xlh_periods", $xlh_periods+1, 0);//修改巡乐会期数
|
2025-09-22 09:28:10 +08:00
|
|
|
$pan_xlh = db::name('vs_room_pan_xlh')->where(['id'=>$pan_xlh_id])->find();
|
|
|
|
|
}else{
|
|
|
|
|
return ['code' => 0, 'msg' => '未开始', 'data' => null];
|
|
|
|
|
}
|
2025-08-26 18:16:22 +08:00
|
|
|
}
|
2025-09-02 17:17:14 +08:00
|
|
|
$xlh_user_data= null;
|
2025-09-17 18:11:17 +08:00
|
|
|
if($pan_xlh && $pan_xlh['user_id']){
|
2025-08-26 18:16:22 +08:00
|
|
|
$xlh_user = db::name('user')->where('id',$pan_xlh['user_id'])->find();
|
2025-08-26 19:10:51 +08:00
|
|
|
$xlh_user_data = [
|
|
|
|
|
'user_id' => $xlh_user['id'],
|
|
|
|
|
'nickname' => $xlh_user['nickname'],
|
|
|
|
|
'avatar' => $xlh_user['avatar'],
|
|
|
|
|
];
|
2025-08-26 18:16:22 +08:00
|
|
|
}
|
2025-09-17 21:07:08 +08:00
|
|
|
//$gift_list 按gift_price 升序排序
|
|
|
|
|
usort($gift_list, function($a, $b) {
|
|
|
|
|
return $a['gift_price'] - $b['gift_price'];
|
|
|
|
|
});
|
|
|
|
|
|
2025-08-26 16:19:26 +08:00
|
|
|
$result_data = [
|
|
|
|
|
'title' => $xlh_box['name'],
|
|
|
|
|
'rule_url' => get_system_config_value('web_site')."/api/Page/get_gift_box_rule?box_id=".$xlh_box["id"],
|
|
|
|
|
'box_price' => $xlh_ext['xlh_box_price'],
|
2025-09-17 18:11:17 +08:00
|
|
|
'xlh_end_time' =>$pan_xlh['end_time']??0,
|
2025-08-26 16:19:26 +08:00
|
|
|
'give_homeowner_gift' => [
|
|
|
|
|
'gift_id' => $room_user_gift['gid'],
|
|
|
|
|
'gift_name' => $room_user_gift['gift_name'],
|
2025-09-25 19:36:32 +08:00
|
|
|
'gift_price' => $room_user_gift['gift_price'],
|
2025-08-26 16:19:26 +08:00
|
|
|
'base_image' => $room_user_gift['base_image'],
|
|
|
|
|
],
|
2025-09-25 16:35:22 +08:00
|
|
|
'homeowner_user' => [
|
|
|
|
|
'user_id' => $room_user['id'],
|
|
|
|
|
'nickname' => $room_user['nickname'],
|
|
|
|
|
'avatar' => $room_user['avatar'],
|
|
|
|
|
],
|
2025-08-26 16:19:26 +08:00
|
|
|
'locking_gift' => [
|
|
|
|
|
'gift_id' => $xlh_main_gift['gid'],
|
|
|
|
|
'gift_name' => $xlh_main_gift['gift_name'],
|
|
|
|
|
'gift_price' => $xlh_main_gift['gift_price'],
|
|
|
|
|
'base_image' => $xlh_main_gift['base_image'],
|
2025-09-17 18:11:17 +08:00
|
|
|
'gift_num' => $pan_xlh['num']??0
|
2025-08-26 16:19:26 +08:00
|
|
|
],
|
2025-08-26 19:10:51 +08:00
|
|
|
'xlh_user' => $xlh_user_data,
|
2025-08-26 16:19:26 +08:00
|
|
|
'gift_list' => $gift_list,
|
|
|
|
|
];
|
|
|
|
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $result_data];
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-28 18:44:56 +08:00
|
|
|
/*
|
|
|
|
|
* 巡乐会抽奖记录
|
|
|
|
|
*/
|
|
|
|
|
public function xlh_get_user_record($user_id,$room_id,$page=1,$page_size=12){
|
|
|
|
|
$where = [];
|
|
|
|
|
$where['a.gift_bag_id'] = 13;
|
|
|
|
|
$where['a.user_id'] = $user_id;
|
|
|
|
|
$where['a.room_id'] = $room_id;
|
2025-10-13 11:26:30 +08:00
|
|
|
$list = db('vs_gift_bag_receive_pan_log')
|
2025-08-28 18:44:56 +08:00
|
|
|
->alias('a')
|
|
|
|
|
->join('vs_room_pan_xlh b','b.id = a.parent_id','left')
|
|
|
|
|
->join('vs_gift c','c.gid = a.gift_id','left')
|
2025-09-17 18:45:07 +08:00
|
|
|
->field('a.gift_id,a.num as count,a.createtime,c.gift_name as gift_name,c.base_image')
|
2025-08-28 18:44:56 +08:00
|
|
|
->where($where)
|
2025-09-17 18:45:07 +08:00
|
|
|
->order('a.createtime desc')
|
2025-08-28 18:44:56 +08:00
|
|
|
->page($page,$page_size)
|
|
|
|
|
->select();
|
|
|
|
|
foreach ($list as &$v){
|
|
|
|
|
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
|
|
|
|
}
|
|
|
|
|
return ['code' => 1, 'msg' => '成功', 'data' => $list];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 巡乐会榜单
|
|
|
|
|
*/
|
|
|
|
|
public function xlh_ranking($room_id,$page=1,$page_size=12){
|
|
|
|
|
$where = [];
|
|
|
|
|
$where['a.gift_bag_id'] = 13;
|
|
|
|
|
$where['a.room_id'] = $room_id;
|
|
|
|
|
$where['e.is_world_show'] = 1;
|
2025-10-13 11:26:30 +08:00
|
|
|
$list = db('vs_gift_bag_receive_pan_log')
|
2025-08-28 18:44:56 +08:00
|
|
|
->alias('a')
|
|
|
|
|
->join('vs_room_pan_xlh b','b.id = a.parent_id','left')
|
|
|
|
|
->join('vs_gift c','c.gid = a.gift_id','left')
|
|
|
|
|
->join('fa_user d','d.id = a.user_id','left')
|
|
|
|
|
->join('vs_gift_bag_detail e','e.foreign_id = a.gift_id','left')
|
2025-09-17 18:45:07 +08:00
|
|
|
->field('a.gift_id,a.num as count,a.createtime,c.gift_name,c.base_image,d.nickname')
|
2025-08-28 18:44:56 +08:00
|
|
|
->where($where)
|
2025-09-17 18:45:07 +08:00
|
|
|
->order('a.createtime desc')
|
2025-08-28 18:44:56 +08:00
|
|
|
->page($page,$page_size)
|
|
|
|
|
->select();
|
|
|
|
|
foreach ($list as &$v){
|
|
|
|
|
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
|
|
|
|
}
|
|
|
|
|
return ['code' => 1, 'msg' => '成功', 'data' => $list];
|
|
|
|
|
}
|
2025-09-22 11:33:09 +08:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 获取用户当前房间的巡乐会信息
|
|
|
|
|
*/
|
|
|
|
|
public function get_user_xlh_info($room_id){
|
|
|
|
|
$gift_bag_id = 13;
|
|
|
|
|
$xlh_box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find();
|
|
|
|
|
$xlh_ext = json_decode($xlh_box['ext'],true);
|
2025-10-13 18:07:08 +08:00
|
|
|
$xlh_data = db('vs_room_pan_xlh')->where(["send_time"=>0,"end_time"=>[">",time()]])->field('id,room_id,periods,end_time')->order('periods desc')->find();
|
2025-09-22 11:33:09 +08:00
|
|
|
//寻乐会状态
|
|
|
|
|
$xlh_status = 0;
|
|
|
|
|
// 状态
|
2025-10-13 16:10:37 +08:00
|
|
|
$xlh_periods_num = Cache::get("xlh_periods_num") ?? 0;
|
|
|
|
|
if($xlh_periods_num >= $xlh_ext['open_condition']['start_num']){
|
2025-09-22 11:33:09 +08:00
|
|
|
$xlh_status = 1;//状态 1:巡乐会开始 2:即将开始 0:等待开始
|
2025-10-13 16:10:37 +08:00
|
|
|
} elseif($xlh_periods_num >= $xlh_ext['open_condition']['waiting_start_num'] && $xlh_periods_num < $xlh_ext['open_condition']['start_num']){
|
2025-09-22 11:33:09 +08:00
|
|
|
$xlh_status = 2;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始
|
|
|
|
|
}else{
|
|
|
|
|
$xlh_status = 0;//未开始
|
|
|
|
|
}
|
2025-09-22 14:20:17 +08:00
|
|
|
return [
|
|
|
|
|
'activities_name' => $xlh_box['name'],
|
2025-09-24 22:52:40 +08:00
|
|
|
'icon' => null,
|
2025-09-22 14:20:17 +08:00
|
|
|
'xlh_status'=>$xlh_status,
|
2025-09-22 11:33:09 +08:00
|
|
|
'end_time'=>$xlh_data['end_time'] ?? 0,
|
2025-09-22 14:20:17 +08:00
|
|
|
];
|
2025-09-22 11:33:09 +08:00
|
|
|
}
|
2025-09-26 17:06:48 +08:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 巡乐会榜单
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function xlh_ranking_list($room_id,$page=1,$page_size=12){
|
|
|
|
|
$gift_bag_id = 13;
|
|
|
|
|
$xlh_box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find();
|
|
|
|
|
$xlh_ext = json_decode($xlh_box['ext'],true);
|
2025-10-13 18:07:08 +08:00
|
|
|
$pan_xlh = db::name('vs_room_pan_xlh')
|
2025-09-26 17:38:38 +08:00
|
|
|
->order('id desc')
|
|
|
|
|
->page($page,$page_size)
|
|
|
|
|
->select();
|
2025-09-26 17:06:48 +08:00
|
|
|
$list = [];
|
|
|
|
|
foreach ($pan_xlh as $key=>$value){
|
|
|
|
|
$list[$key]['periods'] = "第".$value['periods']."期";
|
|
|
|
|
if(!empty($value['user_id'])){
|
|
|
|
|
$list[$key]['nickname'] = db::name('user')->where(['id'=>$value['user_id']])->value('nickname');
|
|
|
|
|
}else{
|
|
|
|
|
$list[$key]['nickname'] = "无";
|
|
|
|
|
}
|
2025-09-26 17:38:38 +08:00
|
|
|
if(!empty($value['gift_id'])){
|
|
|
|
|
$gift_data = db::name('vs_gift')->field('gift_name,base_image')->where(['gid'=>$value['gift_id']])->find();
|
2025-09-26 17:06:48 +08:00
|
|
|
$list[$key]['gift_name'] = 'x '.$value['num'].' '.$gift_data['gift_name'];
|
|
|
|
|
$list[$key]['base_image'] = $gift_data['base_image']??"";
|
|
|
|
|
}else{
|
|
|
|
|
$gift_data = db::name('vs_gift')->field('gift_name,base_image')->where(['gid'=>$xlh_ext['locking_condition']['locking_gift_id']])->find();
|
|
|
|
|
$list[$key]['gift_name'] = 'x 0 '.$gift_data['gift_name'];
|
|
|
|
|
$list[$key]['base_image'] = $gift_data['base_image']??"";
|
|
|
|
|
}
|
2025-09-26 17:38:38 +08:00
|
|
|
$list[$key]['createtime'] = $value['send_time'] ? date('Y-m-d H:i:s',$value['send_time']) : '' ;
|
2025-09-26 17:06:48 +08:00
|
|
|
}
|
|
|
|
|
return [
|
|
|
|
|
'code' => 1,
|
|
|
|
|
'msg' => '成功',
|
|
|
|
|
'data' => $list
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-16 19:10:54 +08:00
|
|
|
}
|