From 56979d8e7dcf525bdc4affc91318d379480cb1de Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 27 Oct 2022 17:31:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/controller/BagController.class.php | 69 +++++++++++++---------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index 91faca50..774325aa 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -104,40 +104,51 @@ class BagController extends BaseAuthedController { { $itemDto = Bag::findByType(mt\Item::FUNC_TYPE, mt\Item::FUNC_RENAME_CARD_SUBTYPE); $userInfo = $this->_getOrmUserInfo(); - if (!$itemDto || $itemDto['item_num'] < 0) { - if (mt\Parameter::getVal('rename_diamond_cost', 0) <= 0) { - $this->_rspErr(1, 'config error'); + if ($userInfo['rename_count'] == 0){ + $errCode = 0; + $errMsg = ''; + $this->internalRename(getReqVal('name', ''), getReqVal('name_sign', ''), $errCode, $errMsg); + if ($errCode) { + $this->_rspErr($errCode, $errMsg); return; } - if ($userInfo['diamond'] < mt\Parameter::getVal('rename_diamond_cost', 0)) { - $this->_rspErr(1, 'Not enough item'); + }else{ + if (!$itemDto || $itemDto['item_num'] < 0) { + if (mt\Parameter::getVal('rename_diamond_cost', 0) <= 0) { + $this->_rspErr(1, 'config error'); + return; + } + if ($userInfo['diamond'] < mt\Parameter::getVal('rename_diamond_cost', 0)) { + $this->_rspErr(1, 'Not enough item'); + return; + } + } + $errCode = 0; + $errMsg = ''; + $this->internalRename(getReqVal('name', ''), getReqVal('name_sign', ''), $errCode, $errMsg); + if ($errCode) { + $this->_rspErr($errCode, $errMsg); return; } + if (!$itemDto || $itemDto['item_num'] <= 0) { + $this->_decItems(array( + array( + 'item_id' => V_ITEM_DIAMOND, + 'item_num' => mt\Parameter::getVal('rename_diamond_cost', 0) + ) + )); + $this->propertyChgService->addUserChg(); + } else { + $this->_decItems(array( + array( + 'item_id' => $itemDto['item_id'], + 'item_num' => 1 + ) + )); + $this->propertyChgService->addBagChg(); + } } - $errCode = 0; - $errMsg = ''; - $this->internalRename(getReqVal('name', ''), getReqVal('name_sign', ''), $errCode, $errMsg); - if ($errCode) { - $this->_rspErr($errCode, $errMsg); - return; - } - if (!$itemDto || $itemDto['item_num'] <= 0) { - $this->_decItems(array( - array( - 'item_id' => V_ITEM_DIAMOND, - 'item_num' => mt\Parameter::getVal('rename_diamond_cost', 0) - ) - )); - $this->propertyChgService->addUserChg(); - } else { - $this->_decItems(array( - array( - 'item_id' => $itemDto['item_id'], - 'item_num' => 1 - ) - )); - $this->propertyChgService->addBagChg(); - } + $this->propertyChgService->addUserChg(); $this->_rspData(array( 'property_chg' => $this->propertyChgService->toDto(),