diff --git a/application/adminapi/controller/SysSet.php b/application/adminapi/controller/SysSet.php index 36702b1..c1d9437 100644 --- a/application/adminapi/controller/SysSet.php +++ b/application/adminapi/controller/SysSet.php @@ -35,6 +35,9 @@ class SysSet extends adminApi '10' => '邀请奖励', '11' => '二级密码', ]; + public $noAdminConfigType = [ + '1' => '基础设置', + ]; public function _initialize() { @@ -45,14 +48,18 @@ class SysSet extends adminApi * 类型列表 */ public function type_list(){ - $configType = $this->configType; + if($this->auth->isSuperAdmin()){ + $configType = $this->configType; + }else{ + $configType = $this->noAdminConfigType; + } $list = []; $i=0; - foreach ($configType as $k=>$v){ - $list[$i]['id'] = $k; - $list[$i]['name'] = $v; - $i++; - } + foreach ($configType as $k=>$v){ + $list[$i]['id'] = $k; + $list[$i]['name'] = $v; + $i++; + } return V(1,"成功", $list); } diff --git a/application/api/model/BlindBoxTurntableGiftDrawWorld.php b/application/api/model/BlindBoxTurntableGiftDrawWorld.php index 67330bf..f2a462c 100644 --- a/application/api/model/BlindBoxTurntableGiftDrawWorld.php +++ b/application/api/model/BlindBoxTurntableGiftDrawWorld.php @@ -379,6 +379,24 @@ class BlindBoxTurntableGiftDrawWorld extends Model for ($i = 0; $i < $userNewAllocation; $i++) { $selectedGift = $this->selectGiftWithAliasMethod($aliasTableForNew); if ($selectedGift) { + // 检查实际库存是否足够 + if ($selectedGift['remaining_number'] <= 0) { + // 如果库存不足,重新构建 Alias 表 + $aliasTableForNew = $this->buildAliasTable($availableGifts); + $selectedGift = $this->selectGiftWithAliasMethod($aliasTableForNew); + } + // 更新内存中的礼物库存 + foreach ($availableGifts as &$gift) { + if ($gift['id'] == $selectedGift['id']) { + $gift['remaining_number']--; + break; + } + } + unset($gift); // 清除引用 + + // 更新 Alias 表 + $this->updateAliasTable($aliasTableForNew, $selectedGift['id']); + $giftInfoMap = $this->preloadGiftInfo($availableGifts); $gift = $giftInfoMap[$selectedGift['foreign_id']]; if($gift){ @@ -1249,6 +1267,10 @@ class BlindBoxTurntableGiftDrawWorld extends Model // 批量更新库存 ksort($inventory_updates); // 按ID排序 foreach ($inventory_updates as $detail_id => $count) { + $bag_detail = db::name("vs_gift_bag_detail")->field('remaining_number') ->where('id',$detail_id)->find(); + if($bag_detail['remaining_number'] < $count){ + throw new \Exception('库存不足'); + } db::name("vs_gift_bag_detail")->where('id',$detail_id)->setDec('remaining_number', $count); }