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