1
This commit is contained in:
parent
20165d5e3b
commit
3ea18cc645
@ -309,11 +309,25 @@ class BlockChainController extends BaseAuthedController {
|
||||
myself()->_rspErr(1, "token_type error");
|
||||
return;
|
||||
}
|
||||
$rate = 1;
|
||||
if (in_array(
|
||||
$tokenType,
|
||||
array(
|
||||
'USDC',
|
||||
'USDT'
|
||||
)
|
||||
)) {
|
||||
$rate = 10;
|
||||
}
|
||||
$jinDu = 18;
|
||||
if ($tokenType == BlockChainService::CURRENCY_USDC) {
|
||||
$jinDu = 6;
|
||||
}
|
||||
$currency = $tokenType;
|
||||
$price = BlockChainService::formatCurrency($num);
|
||||
$price = BlockChainService::formatCurrencyEx($num, $jinDu);
|
||||
|
||||
$itemId = V_ITEM_DIAMOND;
|
||||
$itemCount = $num;
|
||||
$itemCount = $num * $rate;
|
||||
|
||||
$rspObj = BlockChainService::gameItemMallBuy(
|
||||
Transaction::BUY_GOODS_ACTION_TYPE,
|
||||
|
@ -11,6 +11,8 @@ use phpcommon;
|
||||
class BlockChainService {
|
||||
|
||||
const CURRENCY_CEG = 'CEG';
|
||||
const CURRENCY_USDC = 'USDC';
|
||||
const CURRENCY_USDT = 'USDT';
|
||||
|
||||
/*
|
||||
注意!!!:
|
||||
@ -173,6 +175,17 @@ class BlockChainService {
|
||||
return $formatedStr;
|
||||
}
|
||||
|
||||
/*
|
||||
$price 是一个小数精确到小数点后5位
|
||||
*/
|
||||
public static function formatCurrencyEx($price, $jinDu)
|
||||
{
|
||||
$xiShu = 10000;
|
||||
$intPrice = $price * $xiShu;
|
||||
$formatedStr = phpcommon\bnDiv_s(phpcommon\bnMul_s($intPrice, phpcommon\bnPow_s(10, $jinDu)), $xiShu);
|
||||
return $formatedStr;
|
||||
}
|
||||
|
||||
private static function getWeb3ServiceUrl()
|
||||
{
|
||||
if (SERVER_ENV == _DEBUG) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user