diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index b6b85992..ff0041f5 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -1164,6 +1164,7 @@ class ShopController extends BaseAuthedController $this->_rspErr(2, 'id is invalid'); return; } + $cost = $shop['price'] * $num; $isFreeBuy = false; if (!empty($shop['free_type'])) { $count = $this->countFreeBuyTimes($shop); @@ -1171,21 +1172,22 @@ class ShopController extends BaseAuthedController $isFreeBuy = true; } } - $cost = $shop['price'] * $num; - if ($isFreeBuy) { - $cost = 0; - } - - $recommend = $shop['recommend']; - - $itemStore = mt\ShopChest::getRandomItemListByChestType($recommend); if ($isFreeBuy) { if ($num != 1) { $this->_rspErr(2, 'num is invalid'); return; } + } else { + $gold = 500; + if ($gold < $cost) { + $this->_rspErr(2, 'gold is not enough'); + return; + } + $gold -= $cost; } + $recommend = $shop['recommend']; + $itemStore = mt\ShopChest::getRandomItemListByChestType($recommend); $result = array(); for ($i = 0; $i < $num; $i++) { $record = array(); @@ -1203,7 +1205,7 @@ class ShopController extends BaseAuthedController $record[$key] = array("item_id" => $item['item_id'], "item_num" => $item['num']); array_push($result, $record[$key]); } - if ($isFreeBuy && $num == 1) { + if ($isFreeBuy) { $this->addFreeBuyRecord($shop); } } @@ -1211,6 +1213,10 @@ class ShopController extends BaseAuthedController error_log("buyBlindBox start " . json_encode( array( 'account' => $account, + 'id' => $id, + 'num' => $num, + 'cost' => $cost, + 'freeBuy' => $isFreeBuy, 'itemListStore' => $result, ) ));