1
This commit is contained in:
parent
164b3199e9
commit
e5f072223c
@ -207,7 +207,7 @@ class PassController extends BaseAuthedController
|
||||
return;
|
||||
}
|
||||
$response = services\BlockChainService::gameItemMallBuy(
|
||||
Transaction::BUY_PASS_ACTION_TYPE, $price * pow(10,18), V_ITEM_PASS, 1);
|
||||
Transaction::BUY_PASS_ACTION_TYPE, services\BlockChainService::formatCurrency($price), V_ITEM_PASS, 1);
|
||||
|
||||
$this->_setV(TN_DAILY_BUY_PASS_STATE, 0, 1);
|
||||
BcOrder::upsert($response['trans_id'], array(
|
||||
@ -237,7 +237,7 @@ class PassController extends BaseAuthedController
|
||||
return;
|
||||
}
|
||||
$response = services\BlockChainService::gameItemMallBuy(
|
||||
Transaction::BUY_EXP_ACTION_TYPE, $price * pow(10,18), V_ITEM_EXP, $passMeta['total_exp'] - $this->userInfo['exp']);
|
||||
Transaction::BUY_EXP_ACTION_TYPE, services\BlockChainService::formatCurrency($price), V_ITEM_EXP, $passMeta['total_exp'] - $this->userInfo['exp']);
|
||||
$this->_setV(TN_DAILY_BUY_LEVEL_STATE, 0, 1);
|
||||
BcOrder::upsert($response['trans_id'], array(
|
||||
'item_id' => V_ITEM_EXP,
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace services;
|
||||
|
||||
require_once('models/Transaction.php');
|
||||
require_once('phpcommon/bignumber.php');
|
||||
|
||||
use models\Transaction;
|
||||
use phpcommon;
|
||||
@ -82,6 +83,17 @@ class BlockChainService {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
$price 是一个小数精确到小数点后5位
|
||||
*/
|
||||
public static function formatCurrency($price)
|
||||
{
|
||||
$xiShu = 10000;
|
||||
$intPrice = $price * $xiShu;
|
||||
$formatedStr = phpcommon\bnDiv(phpcommon\bnMul_s($intPrice, phpcommon\bnPow_s(10, 18)), $xiShu);
|
||||
return $formatedStr;
|
||||
}
|
||||
|
||||
private static function getWeb3ServiceUrl()
|
||||
{
|
||||
if (SERVER_ENV == _TEST) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user