1
This commit is contained in:
parent
f4a7878200
commit
a25cdeccbc
@ -87,6 +87,31 @@ class DynData extends BaseModel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function setVEx($accountId, $x, $y, $val)
|
||||||
|
{
|
||||||
|
SqlHelper::upsert
|
||||||
|
(myself()->_getMysql($accountId),
|
||||||
|
't_dyndata',
|
||||||
|
array(
|
||||||
|
'account_id' => $accountId,
|
||||||
|
'x' => $x,
|
||||||
|
'y' => $y
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'val' => $val,
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => $accountId,
|
||||||
|
'x' => $x,
|
||||||
|
'y' => $y,
|
||||||
|
'val' => $val,
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static function decV($x, $y, $val)
|
public static function decV($x, $y, $val)
|
||||||
{
|
{
|
||||||
self::incV($x, $y, 0 - $val);
|
self::incV($x, $y, 0 - $val);
|
||||||
|
@ -203,19 +203,19 @@ class BlockChainService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function parseCurrencyVal($currencyName, $val, &$intVal, &$floatVal)
|
public static function parseCurrencyVal($currencyName, $val, &$intPart, &$floatPart)
|
||||||
{
|
{
|
||||||
$decimals = self::getCurrencyDecimals($currencyName);
|
$decimals = self::getCurrencyDecimals($currencyName);
|
||||||
if ($decimals === false) {
|
if ($decimals === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$intVal = '0';
|
$intPart = '0';
|
||||||
$floatVal = '0';
|
$floatPart = '0';
|
||||||
if (strlen($val) <= $decimals) {
|
if (strlen($val) <= $decimals) {
|
||||||
$floatVal = $val;
|
$floatPart = $val;
|
||||||
} else {
|
} else {
|
||||||
$intVal = substr($val, 0, $decimals);
|
$intPart = substr($val, 0, $decimals);
|
||||||
$floatVal = substr($val, $decimals);
|
$floatPart = substr($val, $decimals);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once('models/DynData.php');
|
||||||
|
|
||||||
|
require_once('services/BlockChainService.php');
|
||||||
|
|
||||||
|
use models\DynData;
|
||||||
|
|
||||||
|
use services\BlockChainService;
|
||||||
|
|
||||||
class EventService {
|
class EventService {
|
||||||
|
|
||||||
public static function mallConsume($accountId, $currencyName, $val)
|
public static function mallConsume($accountId, $currencyName, $val)
|
||||||
{
|
{
|
||||||
|
$intPart = 0;
|
||||||
|
$floatPart = 0;
|
||||||
|
if (BlockChainService::parseCurrencyVal($currencyName, $val, $intPart, $floatPart)) {
|
||||||
|
$oldIntPart = DynData::GetVEx($accountId, TN_TOTAL_CEG_CONSUME, 0);
|
||||||
|
$oldFloatPart = DynData::GetVEx($accountId, TN_TOTAL_CEG_CONSUME, 1);
|
||||||
|
$newIntPart = $oldIntPart + $intPart;
|
||||||
|
$newFloatPart = $oldFloatPart;
|
||||||
|
|
||||||
|
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