1
This commit is contained in:
parent
a25cdeccbc
commit
3c5463a0af
@ -203,12 +203,13 @@ class BlockChainService {
|
||||
}
|
||||
}
|
||||
|
||||
public static function parseCurrencyVal($currencyName, $val, &$intPart, &$floatPart)
|
||||
public static function parseCurrencyVal($currencyName, $val, &$intPart, &$floatPart, &$maxFloatPart)
|
||||
{
|
||||
$decimals = self::getCurrencyDecimals($currencyName);
|
||||
if ($decimals === false) {
|
||||
return false;
|
||||
}
|
||||
$maxFloatPart = pow(10, $decimals);
|
||||
$intPart = '0';
|
||||
$floatPart = '0';
|
||||
if (strlen($val) <= $decimals) {
|
||||
|
@ -14,11 +14,17 @@ class EventService {
|
||||
{
|
||||
$intPart = 0;
|
||||
$floatPart = 0;
|
||||
if (BlockChainService::parseCurrencyVal($currencyName, $val, $intPart, $floatPart)) {
|
||||
$maxFloatPart = 0;
|
||||
if (BlockChainService::parseCurrencyVal($currencyName, $val, $intPart, $floatPart, $maxFloatPart)) {
|
||||
$oldIntPart = DynData::GetVEx($accountId, TN_TOTAL_CEG_CONSUME, 0);
|
||||
$oldFloatPart = DynData::GetVEx($accountId, TN_TOTAL_CEG_CONSUME, 1);
|
||||
$newIntPart = $oldIntPart + $intPart;
|
||||
$newFloatPart = $oldFloatPart;
|
||||
$newFloatPart = $oldFloatPart + $floatPart;
|
||||
if ($newFloatPart > $maxFloatPart) {
|
||||
++$newIntPart;
|
||||
$newFloatPart = min($maxFloatPart, $newFloatPart - $maxFloatPart);
|
||||
$newFloatPart = max($newFloatPart, 0);
|
||||
}
|
||||
|
||||
DynData::setVEx($accountId, TN_TOTAL_CEG_CONSUME, 0, $newIntPart);
|
||||
DynData::setVEx($accountId, TN_TOTAL_CEG_CONSUME, 1, $newFloatPart);
|
||||
|
Loading…
x
Reference in New Issue
Block a user