37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace services;
|
|
|
|
require_once('models/DynData.php');
|
|
|
|
require_once('services/BlockChainService.php');
|
|
|
|
use models\DynData;
|
|
|
|
use services\BlockChainService;
|
|
|
|
class EventService {
|
|
|
|
public static function mallConsume($accountId, $currencyName, $val)
|
|
{
|
|
$intPart = 0;
|
|
$floatPart = 0;
|
|
$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 + $floatPart;
|
|
if ($newFloatPart > $maxFloatPart) {
|
|
++$newIntPart;
|
|
$newFloatPart = min($maxFloatPart - 1, $newFloatPart - $maxFloatPart);
|
|
$newFloatPart = max($newFloatPart, 0);
|
|
}
|
|
|
|
DynData::setVEx($accountId, TN_TOTAL_CEG_CONSUME, 0, $newIntPart);
|
|
DynData::setVEx($accountId, TN_TOTAL_CEG_CONSUME, 1, $newFloatPart);
|
|
}
|
|
}
|
|
|
|
}
|