盲盒转盘错误修改
This commit is contained in:
@@ -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()))
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 计算还需要抽取的数量
|
||||
|
||||
Reference in New Issue
Block a user