This commit is contained in:
aozhiwei 2022-04-03 09:28:46 +08:00
parent 4fec316ae0
commit 22ef1be25b
2 changed files with 44 additions and 43 deletions

View File

@ -56,51 +56,21 @@ class MarketController extends BaseController {
'current_page' => $page, 'current_page' => $page,
'total_pages' => 0 'total_pages' => 0
); );
$startPos= $pageInfo['per_page'] * ($pageInfo['current_page'] - 1);
$currBatchMeta = mt\MarketBatch::getCurrentBatch(); $currBatchMeta = mt\MarketBatch::getCurrentBatch();
if (!$currBatchMeta) { if ($currBatchMeta) {
myself()->_rspData(array( $batchMetas = mt\MarketGoods::getBatchMetas($currBatchMeta['batch_id']);
'rows' => $rows, if ($batchMetas) {
'page' => $pageInfo, foreach ($batchMetas as $meta) {
)); $currencyMeta = mt\Currency::get($meta['currency_id']);
return; if ($currencyMeta) {
} ++$pageInfo['total'];
if ($pageInfo['total'] > $startPos &&
$batchMetas = mt\MarketGoods::getBatchMetas($currBatchMeta['batch_id']); count($rows) < $pageInfo['per_page']) {
if ($batchMetas) { array_push($rows, $saleBox);
foreach ($batchMetas as $meta) { }
$heroMeta = mt\Hero::get($meta['item_id']); }
$itemMeta = mt\Item::get($meta['item_id']);
$boxId = phpcommon\genBoxId($currBatchMeta['id'], $meta['id'], $meta['item_id']);
$currencyMeta = mt\Currency::get($meta['currency_id']);
if (!$currencyMeta) {
myself()->_rspErr(500, 'server internal error');
return;
}
$originalPrice = $meta['price'] * pow(10, MarketService::CURRENCY_DECIMALS);
$discountPrice = $meta['discount'] * 100 > 0 ?
$originalPrice * $meta['discount'] : $originalPrice;
$saleBox = array(
'box_id' => $boxId,
'item_id' => $meta['item_id'],
'name' => emptyReplace($heroMeta['name'], 'Hill'),
'job' => emptyReplace($heroMeta['herotype'], '1'),
//'avatar_url' => 'https://www.cebg.games/res/avatars/' . $itemMeta['nft_image_id'] . '.png',
'currency_list' => array(
array(
'name' => $currencyMeta['name'],
'original_price' => $originalPrice,
'discount_price' => $discountPrice,
'discount_rate' => $meta['discount'],
'decimals' => MarketService::CURRENCY_DECIMALS,
'contract_address' => $currencyMeta['address'],
)
)
);
++$pageInfo['total'];
if ($pageInfo['total'] > $pageInfo['per_page'] * ($pageInfo['current_page'] - 1) &&
count($rows) < $pageInfo['per_page']) {
array_push($rows, $saleBox);
} }
} }
} }
@ -398,4 +368,33 @@ class MarketController extends BaseController {
MarketService::auth($account, $tips, $nonce, $signature); MarketService::auth($account, $tips, $nonce, $signature);
} }
private function fillPresaleBox()
{
$boxId = phpcommon\genBoxId($currBatchMeta['id'],
$meta['id'],
$meta['item_id']);
$itemMeta = mt\Item::get($meta['item_id']);
$heroMeta = mt\Hero::get($meta['item_id']);
$originalPrice = $meta['price'] * pow(10, MarketService::CURRENCY_DECIMALS);
$discountPrice = $meta['discount'] * 100 > 0 ?
$originalPrice * $meta['discount'] : $originalPrice;
$saleBox = array(
'box_id' => $boxId,
'item_id' => $meta['item_id'],
'name' => emptyReplace($heroMeta['name'], 'Hill'),
'job' => emptyReplace($heroMeta['herotype'], '1'),
//'avatar_url' => 'https://www.cebg.games/res/avatars/' . $itemMeta['nft_image_id'] . '.png',
'currency_list' => array(
array(
'name' => $currencyMeta['name'],
'original_price' => $originalPrice,
'discount_price' => $discountPrice,
'discount_rate' => $meta['discount'],
'decimals' => MarketService::CURRENCY_DECIMALS,
'contract_address' => $currencyMeta['address'],
)
));
}
} }

View File

@ -258,4 +258,6 @@ class MarketService extends BaseService {
return str_replace("\n", '\n', $str); return str_replace("\n", '\n', $str);
} }
} }