From 38c7acc21525637cea42383d0bba34d9b89d7ec1 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 28 Mar 2022 16:20:28 +0800 Subject: [PATCH] 1 --- .../controller/CallbackController.class.php | 18 ++++++--- webapp/models/UserWalletRecord.php | 38 +++++++++++++++++++ 2 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 webapp/models/UserWalletRecord.php diff --git a/webapp/controller/CallbackController.class.php b/webapp/controller/CallbackController.class.php index 95b9f111..24398075 100644 --- a/webapp/controller/CallbackController.class.php +++ b/webapp/controller/CallbackController.class.php @@ -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()) { } diff --git a/webapp/models/UserWalletRecord.php b/webapp/models/UserWalletRecord.php new file mode 100644 index 00000000..2999eb69 --- /dev/null +++ b/webapp/models/UserWalletRecord.php @@ -0,0 +1,38 @@ + $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() + )); + } + +}