diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 429b66d9..b6b85992 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -1164,10 +1164,27 @@ class ShopController extends BaseAuthedController $this->_rspErr(2, 'id is invalid'); return; } + $isFreeBuy = false; + if (!empty($shop['free_type'])) { + $count = $this->countFreeBuyTimes($shop); + if ($count < $shop['free_num']) { + $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; + } + } $result = array(); for ($i = 0; $i < $num; $i++) { @@ -1186,6 +1203,9 @@ 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) { + $this->addFreeBuyRecord($shop); + } } error_log("buyBlindBox start " . json_encode(