This commit is contained in:
aozhiwei 2022-04-03 09:56:24 +08:00
parent 22ef1be25b
commit b5eee37b0a
2 changed files with 18 additions and 24 deletions

View File

@ -1,9 +1,6 @@
<?php <?php
require_once('mt/MarketGoods.php');
require_once('mt/MarketBatch.php');
require_once('mt/Item.php'); require_once('mt/Item.php');
require_once('mt/WhiteList.php');
require_once('mt/Currency.php'); require_once('mt/Currency.php');
require_once('mt/Hero.php'); require_once('mt/Hero.php');
require_once('mt/Parameter.php'); require_once('mt/Parameter.php');
@ -19,16 +16,8 @@ use models\BoxOrder;
use models\Nft; use models\Nft;
use models\BuyRecord; use models\BuyRecord;
const CURRENCY_DECIMALS = 8;
const PRICE_PAD = '0000000000';
class BcShopController extends BaseController { class BcShopController extends BaseController {
private function isTestMode()
{
return isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443 && SERVER_ENV == _TEST;
}
public function search() public function search()
{ {

View File

@ -63,8 +63,8 @@ class MarketController extends BaseController {
$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) {
$currencyMeta = mt\Currency::get($meta['currency_id']); $saleBox = $this->fillPresaleBox($currBatchMeta, $meta);
if ($currencyMeta) { if ($saleBox) {
++$pageInfo['total']; ++$pageInfo['total'];
if ($pageInfo['total'] > $startPos && if ($pageInfo['total'] > $startPos &&
count($rows) < $pageInfo['per_page']) { count($rows) < $pageInfo['per_page']) {
@ -368,20 +368,24 @@ class MarketController extends BaseController {
MarketService::auth($account, $tips, $nonce, $signature); MarketService::auth($account, $tips, $nonce, $signature);
} }
private function fillPresaleBox() private function fillPresaleBox($batchMeta, $goodsMeta)
{ {
$boxId = phpcommon\genBoxId($currBatchMeta['id'], $currencyMeta = mt\Currency::get($goodsMeta['currency_id']);
$meta['id'], if (!$currencyMeta) {
$meta['item_id']); return null;
}
$boxId = phpcommon\genBoxId($batchMeta['id'],
$goodsMeta['id'],
$goodsMeta['item_id']);
$itemMeta = mt\Item::get($meta['item_id']); $itemMeta = mt\Item::get($goodsMeta['item_id']);
$heroMeta = mt\Hero::get($meta['item_id']); $heroMeta = mt\Hero::get($goodsMeta['item_id']);
$originalPrice = $meta['price'] * pow(10, MarketService::CURRENCY_DECIMALS); $originalPrice = $goodsMeta['price'] * pow(10, MarketService::CURRENCY_DECIMALS);
$discountPrice = $meta['discount'] * 100 > 0 ? $discountPrice = $goodsMeta['discount'] * 100 > 0 ?
$originalPrice * $meta['discount'] : $originalPrice; $originalPrice * $goodsMeta['discount'] : $originalPrice;
$saleBox = array( $saleBox = array(
'box_id' => $boxId, 'box_id' => $boxId,
'item_id' => $meta['item_id'], 'item_id' => $goodsMeta['item_id'],
'name' => emptyReplace($heroMeta['name'], 'Hill'), 'name' => emptyReplace($heroMeta['name'], 'Hill'),
'job' => emptyReplace($heroMeta['herotype'], '1'), 'job' => emptyReplace($heroMeta['herotype'], '1'),
//'avatar_url' => 'https://www.cebg.games/res/avatars/' . $itemMeta['nft_image_id'] . '.png', //'avatar_url' => 'https://www.cebg.games/res/avatars/' . $itemMeta['nft_image_id'] . '.png',
@ -390,11 +394,12 @@ class MarketController extends BaseController {
'name' => $currencyMeta['name'], 'name' => $currencyMeta['name'],
'original_price' => $originalPrice, 'original_price' => $originalPrice,
'discount_price' => $discountPrice, 'discount_price' => $discountPrice,
'discount_rate' => $meta['discount'], 'discount_rate' => $goodsMeta['discount'],
'decimals' => MarketService::CURRENCY_DECIMALS, 'decimals' => MarketService::CURRENCY_DECIMALS,
'contract_address' => $currencyMeta['address'], 'contract_address' => $currencyMeta['address'],
) )
)); ));
return $saleBox;
} }
} }