From bf6a11ea2334e8c5db40097443d6151b180dfac9 Mon Sep 17 00:00:00 2001 From: songliang Date: Fri, 30 Jun 2023 13:59:18 +0800 Subject: [PATCH] ... --- webapp/controller/ShopController.class.php | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 9e91ad32..3a67b171 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -483,6 +483,9 @@ class ShopController extends BaseAuthedController private function getCostItemIdByTokenType($token_type) { switch ($token_type) { + case ShopController::TOKEN_TYPE_GOLD: + return V_ITEM_GOLD; + break; case ShopController::TOKEN_TYPE_CEG: return V_ITEM_GOLD; break; @@ -783,15 +786,35 @@ class ShopController extends BaseAuthedController return; } + $maxCount = mt\Parameter::getByName('daily_selection_refresh_time')['param_value']; $count = $this->countTodayRefreshTimes($address); - if ($count >= 6) { + if ($count >= $maxCount) { $this->_rspErr(2, 'The maximum number of refreshes has been reached'); return; } + $count = $this->countTodayRefreshTimes($address); + $costs = mt\Parameter::getByName('daily_selection_refresh_cost'); + $arrCosts = explode('|', $costs['param_value']); + $cost = $arrCosts[$count]; + $costItemId = $this->getCostItemIdByTokenType(ShopController::TOKEN_TYPE_GOLD); + $costItems = $this->makeCostItems($costItemId, $cost); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(2, $this->_getLackItemErrMsg($lackItem)); + return; + } + $chk = $this->refreshDailySelectionWithMode($address, 1); if ($chk) { - $this->_rspOk(); + $this->_decItems($costItems); + $this->_rspData( + array( + 'cost' => $cost, + ) + ); + } else { + $this->_rspErr(3, 'refresh failed'); } }