From ac4897f0ac75198beea5685054d16350916192ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=92=8A?= Date: Wed, 7 Jan 2026 15:15:14 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/library/Auth.php | 2 +- .../BlindBoxTurntableGiftDrawWorldNew.php | 31 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/application/admin/library/Auth.php b/application/admin/library/Auth.php index f326159e..ce07f35a 100644 --- a/application/admin/library/Auth.php +++ b/application/admin/library/Auth.php @@ -60,7 +60,7 @@ class Auth extends \fast\Auth } $admin->loginfailure = 0; $admin->logintime = time(); - $admin->loginip = request()->ip(); + $admin->loginip = request()->server('HTTP_X_REAL_IP') ?: request()->server('HTTP_X_FORWARDED_FOR') ?: request()->ip(); $admin->token = Random::uuid(); $admin->save(); Session::set("admin", $admin->toArray()); diff --git a/application/api/model/BlindBoxTurntableGiftDrawWorldNew.php b/application/api/model/BlindBoxTurntableGiftDrawWorldNew.php index 631d2176..e0e64447 100644 --- a/application/api/model/BlindBoxTurntableGiftDrawWorldNew.php +++ b/application/api/model/BlindBoxTurntableGiftDrawWorldNew.php @@ -1645,6 +1645,7 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model $precomputed_results = []; $available_giftss = []; $inventory_updates = []; + $old_gift_num = 0; // 先处理上期剩余的礼物 if (!empty($remaining_gifts)) { @@ -1662,6 +1663,18 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model // $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']){ + //错误日志记录-------- + $key = 'blind_box_draw_shengyu1_errors_' . date('Y-m-d-H-i-s'); + $errorData=[ + 'gift_bag_id' => $gift_bag_id, + 'available_gifts' => $available_gifts, + 'remaining_gifts' => $remaining_gifts, + 'num' => $num, + 'gift_id' => $gift_id, + 'periods' => $periods, + ]; + $this->redis->setex($key, 86400 * 7, "礼物数量超出限制 ".json_encode($errorData)); + //错误日志记录--------end //剔除该礼物 continue; } @@ -1675,19 +1688,34 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model 'gift_user_id' => 0, 'periods' => $periods, ]; + $old_gift_num++; } //防止上把数据错误 foreach ($drawn_gifts as $gift_id => $count){ //正常数量 $normal_num = $error_gifts[$gift_id]['quantity'] - $error_gifts[$gift_id]['count_num']; if($count > $normal_num){ + //错误日志记录-------- + $key = 'blind_box_draw_shengyu2_errors_' . date('Y-m-d-H-i-s'); + $errorData=[ + 'gift_bag_id' => $gift_bag_id, + 'available_gifts' => $available_gifts, + 'remaining_gifts' => $remaining_gifts, + 'num' => $num, + 'gift_id' => $gift_id, + 'periods' => $periods, + 'error_gifts'=>$error_gifts, + 'normal_num'=>$normal_num + ]; + $this->redis->setex($key, 86400 * 7, "礼物数量超出限制 ".json_encode($errorData)); + //错误日志记录--------end $drawn_gifts[$gift_id] = $normal_num; } } } // 计算还需要抽取的数量 - $remaining_count = $num - count($remaining_gifts); + $remaining_count = $num - $old_gift_num; // 抽取新礼物 for ($i = 0; $i < $remaining_count; $i++) { @@ -1718,7 +1746,6 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model 'gift_user_id' => 0, 'periods' => $periods, ]; - $available_giftss[] = $result_entry; $precomputed_results[] = $result_entry;