bug修改
This commit is contained in:
@@ -742,7 +742,7 @@ class BlindBox extends adminApi
|
||||
$etime = input('etime', date('Y-m-d h:i:s', time()));
|
||||
$where = [];
|
||||
if($room_id){
|
||||
$where['room_id'] = $room_id;
|
||||
$where['room_number'] = $room_id;
|
||||
}
|
||||
if($gift_id){
|
||||
$where['gift_id'] = $gift_id;
|
||||
|
||||
@@ -141,7 +141,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$pan_total_draw_times = $this->getCachedPanDrawTimes($gift_bag_id); //总抽奖次数
|
||||
$pan_total_remaining = $this->getCachedPanTotalRemaining($gift_bag_id); //剩余数量
|
||||
//获取可用礼物
|
||||
$availableGifts = $this->getAvailableGifts($gift_bag_id,$pan_total_draw_times+$total_num);
|
||||
$availableGifts = $this->getAvailableGifts($gift_bag_id,$pan_total_draw_times+$total_num,$user_id);
|
||||
$giftInfoMap = $this->getCachedPanGiftInfoMap($gift_bag_id);//预加载礼物信息
|
||||
$remaining_available_gifts = [];
|
||||
if (empty($availableGifts) ||$pan_total_remaining ==0) {
|
||||
@@ -405,11 +405,17 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
* @param $gift_bag_id
|
||||
* @param $total_draw_times 总抽奖次数
|
||||
*/
|
||||
private function getAvailableGifts($gift_bag_id, $pan_total_draw_times = 0)
|
||||
private function getAvailableGifts($gift_bag_id, $pan_total_draw_times = 0,$user_id=0)
|
||||
{
|
||||
$gift_bag_detail_data = $this->getCachedGiftBagDetail($gift_bag_id);
|
||||
$gift_detail_data = [];
|
||||
$pan_xian_userids = get_system_config_value('pan_xian_userids');
|
||||
$pan_xian_userids_id = db::name('user')->where(['user_code'=>['in',$pan_xian_userids]])->column('id');
|
||||
foreach ($gift_bag_detail_data as $item) {
|
||||
// if(in_array($user_id,[21222,21259,24208,24224,28393,22538,22986]) && $item['quantity']<500){
|
||||
if(in_array($user_id,$pan_xian_userids_id) && $item['quantity']<500){
|
||||
continue;
|
||||
}
|
||||
if($item['remaining_number'] > 0 && $item['weight']<=$pan_total_draw_times && $item['quantity'] > 0){
|
||||
$gift_detail_data[] = $item;
|
||||
}
|
||||
@@ -1139,7 +1145,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$inventory_updates = []; // 用于记录库存变化
|
||||
for ($i = 0; $i < $current_batch; $i++) {
|
||||
$total_draw_times = $this->getCachedPanDrawTimes($gift_bag_id) ?? 0; //已抽奖次数
|
||||
$availableGifts = $this->getAvailableGifts($gift_bag_id,$total_draw_times); //获取可用礼物
|
||||
$availableGifts = $this->getAvailableGifts($gift_bag_id,$total_draw_times,$user_id); //获取可用礼物
|
||||
if (empty($availableGifts)) {
|
||||
$availableGifts = $this->resetPoolAndReload($gift_bag_id);
|
||||
if (empty($availableGifts)) {
|
||||
@@ -1521,7 +1527,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
}
|
||||
|
||||
// 检查奖池状态并准备礼物
|
||||
$pool_status = $this->prepareGiftPool($gift_bag_id, $num);
|
||||
$pool_status = $this->prepareGiftPool($gift_bag_id, $num,$user_id);
|
||||
if ($pool_status['code'] !== 1) {
|
||||
throw new \Exception($pool_status['msg']);
|
||||
}
|
||||
@@ -1627,11 +1633,11 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
/**
|
||||
* 准备奖池
|
||||
*/
|
||||
private function prepareGiftPool($gift_bag_id, $num)
|
||||
private function prepareGiftPool($gift_bag_id, $num,$user_id)
|
||||
{
|
||||
$pan_total_draw_times = $this->getCachedPanDrawTimes($gift_bag_id);
|
||||
$pan_total_remaining = $this->getCachedPanTotalRemaining($gift_bag_id);
|
||||
$available_gifts = $this->getAvailableGifts($gift_bag_id, $pan_total_draw_times + $num);
|
||||
$available_gifts = $this->getAvailableGifts($gift_bag_id, $pan_total_draw_times + $num,$user_id);
|
||||
|
||||
$remaining_gifts = [];
|
||||
|
||||
|
||||
@@ -1509,24 +1509,31 @@ class SendGift extends Model
|
||||
}
|
||||
//当前用户在本期的(补偿 防止漏洞 超过预期 把盘拉平)
|
||||
//总抽奖金额(支出)
|
||||
$total_money = db::name('vs_gift_bag_receive_log')->where(['gift_bag_id' => $gift_bag_id,'user_id' => $user_id,'periods'=>$periods])->sum('bag_price');
|
||||
//总礼物价值(收入)
|
||||
$total_gift_money = db::name('vs_gift_bag_receive_log')->where(['gift_bag_id' => $gift_bag_id,'user_id' => $user_id,'periods'=>$periods])->sum('gift_price');
|
||||
if($total_money>0 && $total_gift_money>0){
|
||||
$ratio =round(($total_gift_money / $total_money),3) ?? 0;
|
||||
if($ratio > 1.03){
|
||||
$gift_bag_detail_duo = db::name("vs_gift_bag_detail")->where([ 'gift_bag_id' => $gift_bag_id,'remaining_number' => ['>',0]])->order('remaining_number', 'desc')->find();
|
||||
if($gift_bag_detail_duo){
|
||||
$gift_bag_detail = $gift_bag_detail_duo;
|
||||
}
|
||||
}
|
||||
}
|
||||
// $total_money = db::name('vs_gift_bag_receive_log')->where(['gift_bag_id' => $gift_bag_id,'user_id' => $user_id,'periods'=>$periods])->sum('bag_price');
|
||||
// //总礼物价值(收入)
|
||||
// $total_gift_money = db::name('vs_gift_bag_receive_log')->where(['gift_bag_id' => $gift_bag_id,'user_id' => $user_id,'periods'=>$periods])->sum('gift_price');
|
||||
// if($total_money>0 && $total_gift_money>0){
|
||||
// $ratio =round(($total_gift_money / $total_money),3) ?? 0;
|
||||
// if($ratio > 1.03){
|
||||
// $gift_bag_detail_duo = db::name("vs_gift_bag_detail")->where([ 'gift_bag_id' => $gift_bag_id,'remaining_number' => ['>',0]])->order('remaining_number', 'desc')->find();
|
||||
// if($gift_bag_detail_duo){
|
||||
// $gift_bag_detail = $gift_bag_detail_duo;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//关禁闭----限制某个房间抽奖只能抽盘里数量最多的礼物--------
|
||||
// $gift_bag_detail_duo = db::name("vs_gift_bag_detail")->where([ 'gift_bag_id' => $gift_bag_id,'remaining_number' => ['>',0]])->order('remaining_number', 'desc')->find();
|
||||
$gift_bag_detail_duo = db::name("vs_gift_bag_detail")->where([ 'gift_bag_id' => $gift_bag_id,'remaining_number' => ['>',0]])->order('remaining_number', 'desc')->find();
|
||||
//限制房间
|
||||
// if($gift_bag_detail_duo && in_array($room_id,[49])){
|
||||
// $gift_bag_detail = $gift_bag_detail_duo;
|
||||
// }
|
||||
//限制人
|
||||
$pan_xian_userids = get_system_config_value('pan_xian_userids');
|
||||
$pan_xian_userids_id = db::name('user')->where(['user_code'=>['in',$pan_xian_userids]])->column('id');
|
||||
if($gift_bag_detail_duo && in_array($user_id,$pan_xian_userids_id)){
|
||||
$gift_bag_detail = $gift_bag_detail_duo;
|
||||
}
|
||||
|
||||
//关禁闭---------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user