1
This commit is contained in:
parent
4fec316ae0
commit
22ef1be25b
@ -56,54 +56,24 @@ 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(
|
|
||||||
'rows' => $rows,
|
|
||||||
'page' => $pageInfo,
|
|
||||||
));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$batchMetas = mt\MarketGoods::getBatchMetas($currBatchMeta['batch_id']);
|
$batchMetas = mt\MarketGoods::getBatchMetas($currBatchMeta['batch_id']);
|
||||||
if ($batchMetas) {
|
if ($batchMetas) {
|
||||||
foreach ($batchMetas as $meta) {
|
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']);
|
$currencyMeta = mt\Currency::get($meta['currency_id']);
|
||||||
if (!$currencyMeta) {
|
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'];
|
++$pageInfo['total'];
|
||||||
if ($pageInfo['total'] > $pageInfo['per_page'] * ($pageInfo['current_page'] - 1) &&
|
if ($pageInfo['total'] > $startPos &&
|
||||||
count($rows) < $pageInfo['per_page']) {
|
count($rows) < $pageInfo['per_page']) {
|
||||||
array_push($rows, $saleBox);
|
array_push($rows, $saleBox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$pageInfo['count'] = count($rows);
|
$pageInfo['count'] = count($rows);
|
||||||
$pageInfo['total_pages'] = ceil($pageInfo['total'] / $pageInfo['per_page']);
|
$pageInfo['total_pages'] = ceil($pageInfo['total'] / $pageInfo['per_page']);
|
||||||
@ -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'],
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -258,4 +258,6 @@ class MarketService extends BaseService {
|
|||||||
return str_replace("\n", '\n', $str);
|
return str_replace("\n", '\n', $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user