This commit is contained in:
songliang 2023-06-28 17:56:42 +08:00
parent 0b5a86dd32
commit ad420b180e

View File

@ -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(