1
This commit is contained in:
parent
3861df2ea9
commit
38c7acc215
@ -8,6 +8,7 @@ require_once('mt/Parameter.php');
|
||||
require_once('models/Nft.php');
|
||||
require_once('models/Withdrawal.php');
|
||||
require_once('models/Transfer.php');
|
||||
require_once('models/UserWalletRecord.php');
|
||||
|
||||
require_once('phpcommon/bchelper.php');
|
||||
|
||||
@ -15,6 +16,7 @@ use phpcommon\SqlHelper;
|
||||
use models\Nft;
|
||||
use models\Withdrawal;
|
||||
use models\Transfer;
|
||||
use models\UserWalletRecord;
|
||||
|
||||
class Callback extends BaseController {
|
||||
|
||||
@ -39,6 +41,11 @@ class Callback extends BaseController {
|
||||
$diamond = 0;
|
||||
|
||||
$conn = myself()->_getMysql($accontId);
|
||||
if (UserWalletRecord::find($conn, $txHash)) {
|
||||
myself()->_rspOk();
|
||||
return;
|
||||
}
|
||||
|
||||
$userRow = SqlHelper::ormSelect(
|
||||
$conn,
|
||||
't_user',
|
||||
@ -53,12 +60,12 @@ class Callback extends BaseController {
|
||||
'account_id' => $accountId,
|
||||
),
|
||||
array(
|
||||
'gold' => function() {
|
||||
|
||||
'gold' => function() use($gold) {
|
||||
return 'max(0, gold + ${gold})';
|
||||
},
|
||||
'diamond' => function() use($diamond) {
|
||||
return 'max(0, diamond + ${diamond}';
|
||||
},
|
||||
'diamond' => function() {
|
||||
|
||||
}
|
||||
));
|
||||
} else {
|
||||
SqlHelper::upsert(
|
||||
@ -85,6 +92,7 @@ class Callback extends BaseController {
|
||||
));
|
||||
}
|
||||
|
||||
UserWalletRecord::add($txHash, $dir, $accontId, $type, $value);
|
||||
if ($this->isTestMode()) {
|
||||
|
||||
}
|
||||
|
38
webapp/models/UserWalletRecord.php
Normal file
38
webapp/models/UserWalletRecord.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace models;
|
||||
|
||||
use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
class UserWalletRecord extends BaseModel {
|
||||
|
||||
public static function find($conn, $txHash)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
$conn,
|
||||
't_user_wallet_record',
|
||||
array(
|
||||
'txHash' => $txHash,
|
||||
)
|
||||
);
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function add($txHash, $dir, $accountId, $type, $value)
|
||||
{
|
||||
SqlHelper::insert(
|
||||
$conn,
|
||||
't_user_wallet_record',
|
||||
array(
|
||||
'txhash' => $txHash,
|
||||
'dir' => $dir,
|
||||
'account_id' => $accountId,
|
||||
'type' => $type,
|
||||
'value' => $value,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
));
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user