This commit is contained in:
aozhiwei 2023-08-22 16:46:18 +08:00
parent 0182702eae
commit bd0c46d307
2 changed files with 28 additions and 4 deletions

View File

@ -320,10 +320,7 @@ class BlockChainController extends BaseAuthedController {
)) {
$rate = 10;
}
$jinDu = 18;
if ($tokenType == BlockChainService::CURRENCY_USDC) {
$jinDu = 6;
}
$jinDu = BlockChainService::getCurrencyDecimals($tokenType);
$currency = $tokenType;
$price = BlockChainService::formatCurrencyEx($num, $jinDu);

View File

@ -177,6 +177,33 @@ class BlockChainService {
return $formatedStr;
}
public static function getCurrencyDecimals($currencyName)
{
switch ($currencyName) {
case self::CURRENCY_CEG:
{
return 18;
}
break;
case self::CURRENCY_USDC:
{
return 6;
}
break;
case self::CURRENCY_USDT:
{
return 6;
}
break;
default:
{
error_log("unkonw currencyName " . $currencyName);
die();
}
break;
}
}
/*
$price 是一个小数精确到小数点后5位
*/