This commit is contained in:
aozhiwei 2022-01-29 15:43:31 +08:00
parent 71eea66d01
commit 605c92b2b1
2 changed files with 9 additions and 3 deletions

View File

@ -54,6 +54,7 @@ class SystemCurrency(object):
['original_price', 0, '原价'],
['discount_price', 0, '折后价'],
['discount_rate', 0, '折扣百分比0-100'],
['decimals', 0, '小数位数'],
['contract_address', 0, '合约地址'],
]

View File

@ -18,6 +18,8 @@ use models\BoxOrder;
use models\Nft;
use models\BuyRecord;
const CURRENCY_DECIMALS = 8;
class MarketController extends BaseController {
private function isTestMode()
@ -93,6 +95,9 @@ class MarketController extends BaseController {
myself()->_rspErr(500, 'server internal error');
return;
}
$originalPrice = $meta['price'] * pow(10, CURRENCY_DECIMALS);
$discountPrice = $meta['discount'] * 100 > 0 ?
$originalPrice * $meta['discount'] : $meta['price'];
$saleBox = array(
'box_id' => $boxId,
'item_id' => $meta['item_id'],
@ -101,10 +106,10 @@ class MarketController extends BaseController {
'currency_list' => array(
array(
'name' => $currencyMeta['name'],
'original_price' => $meta['price'],
'discount_price' => $meta['discount'] * 100 > 0 ?
$meta['price'] * $meta['discount'] : $meta['price'],
'original_price' => $originalPrice,
'discount_price' => $discountPrice,
'discount_rate' => $meta['discount'],
'decimals' => CURRENCY_DECIMALS,
'contract_address' => $currencyMeta['address'],
)
)