...
This commit is contained in:
parent
6b0187869b
commit
daf07c16e1
@ -1164,6 +1164,7 @@ class ShopController extends BaseAuthedController
|
|||||||
$this->_rspErr(2, 'id is invalid');
|
$this->_rspErr(2, 'id is invalid');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$cost = $shop['price'] * $num;
|
||||||
$isFreeBuy = false;
|
$isFreeBuy = false;
|
||||||
if (!empty($shop['free_type'])) {
|
if (!empty($shop['free_type'])) {
|
||||||
$count = $this->countFreeBuyTimes($shop);
|
$count = $this->countFreeBuyTimes($shop);
|
||||||
@ -1171,21 +1172,22 @@ class ShopController extends BaseAuthedController
|
|||||||
$isFreeBuy = true;
|
$isFreeBuy = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$cost = $shop['price'] * $num;
|
|
||||||
if ($isFreeBuy) {
|
|
||||||
$cost = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$recommend = $shop['recommend'];
|
|
||||||
|
|
||||||
$itemStore = mt\ShopChest::getRandomItemListByChestType($recommend);
|
|
||||||
if ($isFreeBuy) {
|
if ($isFreeBuy) {
|
||||||
if ($num != 1) {
|
if ($num != 1) {
|
||||||
$this->_rspErr(2, 'num is invalid');
|
$this->_rspErr(2, 'num is invalid');
|
||||||
return;
|
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();
|
$result = array();
|
||||||
for ($i = 0; $i < $num; $i++) {
|
for ($i = 0; $i < $num; $i++) {
|
||||||
$record = array();
|
$record = array();
|
||||||
@ -1203,7 +1205,7 @@ class ShopController extends BaseAuthedController
|
|||||||
$record[$key] = array("item_id" => $item['item_id'], "item_num" => $item['num']);
|
$record[$key] = array("item_id" => $item['item_id'], "item_num" => $item['num']);
|
||||||
array_push($result, $record[$key]);
|
array_push($result, $record[$key]);
|
||||||
}
|
}
|
||||||
if ($isFreeBuy && $num == 1) {
|
if ($isFreeBuy) {
|
||||||
$this->addFreeBuyRecord($shop);
|
$this->addFreeBuyRecord($shop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1211,6 +1213,10 @@ class ShopController extends BaseAuthedController
|
|||||||
error_log("buyBlindBox start " . json_encode(
|
error_log("buyBlindBox start " . json_encode(
|
||||||
array(
|
array(
|
||||||
'account' => $account,
|
'account' => $account,
|
||||||
|
'id' => $id,
|
||||||
|
'num' => $num,
|
||||||
|
'cost' => $cost,
|
||||||
|
'freeBuy' => $isFreeBuy,
|
||||||
'itemListStore' => $result,
|
'itemListStore' => $result,
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user