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

View File

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