盲盒转盘优化-重构-调试-再加日志
This commit is contained in:
@@ -225,6 +225,11 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
$selectedGift = $this->selectGiftWithAliasMethod($aliasTableForNew);
|
||||
}
|
||||
if ($selectedGift) {
|
||||
$giftBagDetailCached = $this->getCachedGiftBagDetailItem($gift_bag_id, $selectedGift['id']);
|
||||
if($giftBagDetailCached['remaining_number']<=0){
|
||||
$aliasTableForNew = $this->buildAliasTable($availableGifts);
|
||||
$selectedGift = $this->selectGiftWithAliasMethod($aliasTableForNew);
|
||||
}
|
||||
$gift = $giftInfoMap[$selectedGift['foreign_id']]??[];
|
||||
$precomputedResults[] = [
|
||||
'gift_user_id' => $giftUserId,
|
||||
@@ -507,7 +512,9 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
if ($gift_bag_detail_data) {
|
||||
foreach ($gift_bag_detail_data as &$item) {
|
||||
if ($item['id'] == $detail_id) {
|
||||
$item['remaining_number'] -= $decrement;
|
||||
if( $item['remaining_number'] >= $decrement){
|
||||
$item['remaining_number'] -= $decrement;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -745,6 +752,9 @@ class BlindBoxTurntableGiftDrawWorldNew extends Model
|
||||
}else{
|
||||
$upRemainingNumber = $giftBagDetailCached['remaining_number'];
|
||||
}
|
||||
if($upRemainingNumber < 0){
|
||||
throw new \Exception('礼物数量不足');
|
||||
}
|
||||
$ret = db::name("vs_gift_bag_detail")->where('id',$giftId)->update([
|
||||
'remaining_number' => $upRemainingNumber
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user