From d1f5dbf5e9a15f42632b8c418318f53e1cbb7dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=92=8A?= Date: Wed, 7 Jan 2026 12:28:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B2=E7=9B=92=E8=BD=AC=E7=9B=98=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/model/AdminLog.php | 3 ++- .../BlindBoxTurntableGiftDrawWorldNew.php | 27 +++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/application/admin/model/AdminLog.php b/application/admin/model/AdminLog.php index 07e33036..7a9a887f 100644 --- a/application/admin/model/AdminLog.php +++ b/application/admin/model/AdminLog.php @@ -77,6 +77,7 @@ class AdminLog extends Model } $title = implode(' / ', $title); } + $login_ip = request()->server('HTTP_X_REAL_IP') ?: request()->server('HTTP_X_FORWARDED_FOR') ?: request()->ip(); self::create([ 'title' => $title, 'content' => !is_scalar($content) ? json_encode($content, JSON_UNESCAPED_UNICODE) : $content, @@ -84,7 +85,7 @@ class AdminLog extends Model 'admin_id' => $admin_id, 'username' => $username, 'useragent' => substr(request()->server('HTTP_USER_AGENT'), 0, 255), - 'ip' => xss_clean(strip_tags(request()->ip())) + 'ip' => $login_ip//xss_clean(strip_tags(request()->ip())) ]); } diff --git a/application/api/model/BlindBoxTurntableGiftDrawWorldNew.php b/application/api/model/BlindBoxTurntableGiftDrawWorldNew.php index 00ea8921..631d2176 100644 --- a/application/api/model/BlindBoxTurntableGiftDrawWorldNew.php +++ b/application/api/model/BlindBoxTurntableGiftDrawWorldNew.php @@ -1649,9 +1649,24 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model // 先处理上期剩余的礼物 if (!empty($remaining_gifts)) { foreach ($remaining_gifts as $remaining_gift) { - $gift_id = $remaining_gift['foreign_id']; - $drawn_gifts[$gift_id] = ($drawn_gifts[$gift_id] ?? 0) + 1; + $gift_id = $remaining_gift['foreign_id'];//礼物ID + //查询上把这个礼物抽取数量---------------- + $count_num = Db::name('vs_gift_bag_receive_pan_log')->where(['gift_bag_id' => $gift_bag_id,'gift_id' => $gift_id,'periods'=>$periods-1])->count(); + $error_gifts[$gift_id] =[ + //上期抽中数量 + 'count_num'=>$count_num, + 'quantity'=>$remaining_gift['quantity'], + ]; + //查询这个礼物上期数量 +// $this_gift_quantity = Db::name('vs_gift_bag_detail')->where(['gift_bag_id' => $gift_bag_id,'foreign_id' => $gift_id])->value('quantity'); + //上期这个礼物抽走数量与礼物上限数量相同剔除这个礼物 + if ($count_num >= $remaining_gift['quantity']){ + //剔除该礼物 + continue; + } + //查询上把这个礼物抽取数量------防止并发多出容错---------- + $drawn_gifts[$gift_id] = ($drawn_gifts[$gift_id] ?? 0) + 1; $precomputed_results[] = [ 'gift_id' => $gift_id, 'gift_detail_id' => $remaining_gift['id'], @@ -1661,6 +1676,14 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model 'periods' => $periods, ]; } + //防止上把数据错误 + foreach ($drawn_gifts as $gift_id => $count){ + //正常数量 + $normal_num = $error_gifts[$gift_id]['quantity'] - $error_gifts[$gift_id]['count_num']; + if($count > $normal_num){ + $drawn_gifts[$gift_id] = $normal_num; + } + } } // 计算还需要抽取的数量