巡乐会抽奖接口提交.-推送添加

This commit is contained in:
2025-08-29 14:17:42 +08:00
parent 1df47f6b89
commit 6d36d9f506
2 changed files with 30 additions and 18 deletions

View File

@@ -44,15 +44,12 @@ class BlindBoxTurntableGift extends Model
$xlh_ext = json_decode($xlh_box['ext'],true);
$xlh = [];
if($xlh_ext['inlet_bag_id'] == $box['id']){
$room = db::name('vs_room')->field('id,xlh_periods,xlh_periods_num')->where(['id'=>$room_id])->find();
$is_xlh = 1;
$xlh['waiting_start_num'] = $xlh_ext['open_condition']['waiting_start_num'];//等待开奖次数
$xlh['start_num'] = $xlh_ext['open_condition']['start_num'];//开始开奖次数
//本期总次数
$total_number = db::name('vs_gift_bag_detail')->where(['gift_bag_id'=>$gift_bag_id])->sum('quantity')??0;
//本期剩余次数
$remaining_number = db::name('vs_room_pan')->where(['room_id'=>$room_id,'gift_bag_id'=>$gift_bag_id])->sum('remaining_number')??'0';
//当前抽奖次数
$xlh['current_num'] = $total_number - $remaining_number;
$xlh['current_num'] = $room['xlh_periods_num'];
//状态
if($xlh['current_num'] >= $xlh_ext['open_condition']['start_num']){
$xlh['status'] = 1;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始
@@ -82,7 +79,7 @@ class BlindBoxTurntableGift extends Model
$ext = json_decode($bag_data['ext'],true);
$bag_gift = db::name("vs_gift")->where(['gid'=>$ext['gift_id']])->find();// 获取盲盒信息
$toarray = explode(',',$gift_user_ids);
$room = db::name('vs_room')->field('id,xlh_periods,xlh_periods_num,is_open_blind_box_turntable,blind_box_turntable_periods')->where(['id'=>$room_id])->find();
//巡乐会
$is_xlh = 0;
$xlh_box = db::name('vs_gift_bag')->where('id',13)->find();
@@ -92,12 +89,8 @@ class BlindBoxTurntableGift extends Model
$is_xlh = 1;
$xlh['waiting_start_num'] = $xlh_ext['open_condition']['waiting_start_num'];//等待开奖次数
$xlh['start_num'] = $xlh_ext['open_condition']['start_num'];//开始开奖次数
//本期总次数
$total_number = db::name('vs_gift_bag_detail')->where(['gift_bag_id'=>$gift_bag_id])->sum('quantity')??0;
//本期剩余次数
$remaining_number = db::name('vs_room_pan')->where(['room_id'=>$room_id,'gift_bag_id'=>$gift_bag_id])->sum('remaining_number')??'0';
//当前抽奖次数
$xlh['current_num'] = $total_number - $remaining_number;
$xlh['current_num'] = $room['xlh_periods_num'];
//状态
if($xlh['current_num'] >= $xlh_ext['open_condition']['start_num']){
$xlh['status'] = 1;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始
@@ -112,7 +105,6 @@ class BlindBoxTurntableGift extends Model
if ($user_waller['coin'] < $bag_gift['gift_price'] * $num) {
return ['code' => 0, 'msg' => '用户金币不足', 'data' => null];
}
$room = db::name('vs_room')->where(['id'=>$room_id])->find();
if ($room['is_open_blind_box_turntable'] != 1) {
return ['code' => 0, 'msg' => '该房间未开启盲盒转盘', 'data' => null];
}
@@ -276,7 +268,8 @@ class BlindBoxTurntableGift extends Model
$xlh_box = db::name('vs_gift_bag')->where('id',13)->find();
$xlh_ext = json_decode($xlh_box['ext'],true);
if($xlh_ext['inlet_bag_id'] == $gift_bag_id){
if($total_draw_times == $xlh_ext['open_condition']['waiting_start_num']){
$room = Db::name('vs_room')->field('room_name,blind_box_turntable_periods')->where(['id' => $room_id, 'apply_status' => 2])->find();
if($room['xlh_periods_num'] == $xlh_ext['open_condition']['waiting_start_num']){
$room_name = Db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->value('room_name');
//即将开始推送飘屏
$text = $room_name."的巡乐会即将开始,请大家尽快参与哦!";
@@ -284,19 +277,20 @@ class BlindBoxTurntableGift extends Model
$push = new Push(UID, $room_id);
$text_list_new = [
'text' => $text,
'room_id' => $room_id
'room_id' => $room_id,
'from_type' => 1
];
$push->xunlehui($text_list_new);
}
if($total_draw_times == $xlh_ext['open_condition']['start_num']){
$room = Db::name('vs_room')->field('room_name,blind_box_turntable_periods')->where(['id' => $room_id, 'apply_status' => 2])->find();
if($room['xlh_periods_num'] == $xlh_ext['open_condition']['start_num']){
//正式开始推送飘屏
$text = $room['room_name']."的巡乐会正式开始,请大家尽快参与哦!";
//推送礼物横幅
$push = new Push(UID, $room_id);
$text_list_new = [
'text' => $text,
'room_id' => $room_id
'room_id' => $room_id,
'from_type' => 2
];
$push->xunlehui($text_list_new);
//巡乐会正式开始
@@ -311,6 +305,9 @@ class BlindBoxTurntableGift extends Model
if(!$pan_xlh_id){
return ['code' => 0, 'msg' => '失败!', 'data' => []];
}
db::name("vs_room")->where('id',$room_id)->setInc('xlh_periods');
}else{
db::name("vs_room")->where('id',$room_id)->setInc('xlh_periods_num');
}
}
$result_data = [

View File

@@ -2,6 +2,7 @@
namespace app\cron\controller;
use app\common\controller\Push;
use think\Db;
@@ -88,8 +89,22 @@ class RoomPan
echo "处理发放记录失败 \n";
continue;
}
db::name("vs_room")->where('id',$value['room_id'])->update([
'xlh_periods_num' => 0
]);
//推送
$FromUserInfo = db::name('user')->field('nickname,avatar')->where(['id'=>$value['user_id']])->find();
$room_name = db::name('vs_room')->where(['id'=>$value['room_id']])->value('name');
$gift_name = db::name('vs_gift')->where(['id'=>$value['gift_id']])->value('gift_name');
$text = $FromUserInfo['nickname'] . ' 用户在 ' . $room_name.' 房间巡乐会中 ' .$gift_name.'礼物 x ' .$value['num']." 已收入背包";
//推送礼物横幅
$push = new Push(UID, $value['room_id']);
$text_list_new = [
'text' => $text,
'room_id' => $value['room_id'],
'from_type' => 3
];
$push->xunlehui($text_list_new);
}
}
}