From 354dfb34d0f29837507622df88315fb03c2fd437 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 28 Mar 2022 17:44:54 +0800 Subject: [PATCH] 1 --- webapp/controller/BcUserController.class.php | 6 ++--- .../controller/CallbackController.class.php | 22 +++++++++++-------- webapp/models/UserWalletRecord.php | 4 ++-- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/webapp/controller/BcUserController.class.php b/webapp/controller/BcUserController.class.php index 194a76a4..db22ca54 100644 --- a/webapp/controller/BcUserController.class.php +++ b/webapp/controller/BcUserController.class.php @@ -28,14 +28,14 @@ class BcUserController extends BaseController { $gameId = 2006; $channel = BC_CHANNEL; $accountId = phpcommon\createAccountId($channel, $gameId, $account); - $conn = myself()->_getMysql($accontId); - $userRow = SqlHelper::ormSelect( + $conn = myself()->_getMysql($accountId); + $userRow = SqlHelper::ormSelectOne( $conn, 't_user', array( 'account_id' => $accountId, )); - $walletOfflineRow = SqlHelper::ormSelect( + $walletOfflineRow = SqlHelper::ormSelectOne( $conn, 't_user_wallet_offline', array( diff --git a/webapp/controller/CallbackController.class.php b/webapp/controller/CallbackController.class.php index bf498214..84f86f40 100644 --- a/webapp/controller/CallbackController.class.php +++ b/webapp/controller/CallbackController.class.php @@ -18,7 +18,7 @@ use models\Withdrawal; use models\Transfer; use models\UserWalletRecord; -class Callback extends BaseController { +class CallbackController extends BaseController { private function isTestMode() { @@ -31,13 +31,13 @@ class Callback extends BaseController { $account = strtolower(getReqVal('account', '')); $txHash = getReqVal('txhash', ''); $type = getReqVal('type', ''); - $value = getReqVal('value', ''); + $value = getReqVal('value', '0'); $gameId = 2006; $channel = BC_CHANNEL; $accountId = phpcommon\createAccountId($channel, $gameId, $account); - $conn = myself()->_getMysql($accontId); + $conn = myself()->_getMysql($accountId); if (UserWalletRecord::find($conn, $txHash)) { myself()->_rspOk(); return; @@ -52,10 +52,14 @@ class Callback extends BaseController { myself()->_rspErr(2, ''); return; } + if ($value < 0) { + myself()->_rspErr(3, ''); + return; + } $gold = 0; $diamond = 0; - if ($type == 0) { + if ($type == 1) { $gold = $value; } else { $diamond = $value; @@ -80,10 +84,10 @@ class Callback extends BaseController { ), array( 'gold' => function() use($gold) { - return 'max(0, gold + ${gold})'; + return "CASE WHEN gold + ${gold} < 0 THEN 0 ELSE gold + ${gold} END"; }, 'diamond' => function() use($diamond) { - return 'max(0, diamond + ${diamond}'; + return "CASE WHEN diamond + ${diamond} < 0 THEN 0 ELSE diamond + ${diamond} END"; }, )); } else { @@ -95,10 +99,10 @@ class Callback extends BaseController { ), array( 'gold' => function() use($gold) { - return 'max(0, gold + ${gold})'; + return "CASE WHEN gold + ${gold} < 0 THEN 0 ELSE gold + ${gold} END"; }, 'diamond' => function() use($diamond) { - return 'max(0, diamond + ${diamond})'; + return "CASE WHEN diamond + ${diamond} < 0 THEN 0 ELSE diamond + ${diamond} END"; }, 'modifytime' => myself()->_getNowTime() ), @@ -111,7 +115,7 @@ class Callback extends BaseController { )); } - UserWalletRecord::add($txHash, $dir, $accontId, $type, $value); + UserWalletRecord::add($conn, $txHash, $dir, $account, $type, $value); if ($this->isTestMode()) { } diff --git a/webapp/models/UserWalletRecord.php b/webapp/models/UserWalletRecord.php index 2999eb69..e0ca1339 100644 --- a/webapp/models/UserWalletRecord.php +++ b/webapp/models/UserWalletRecord.php @@ -13,13 +13,13 @@ class UserWalletRecord extends BaseModel { $conn, 't_user_wallet_record', array( - 'txHash' => $txHash, + 'txhash' => $txHash, ) ); return $row; } - public static function add($txHash, $dir, $accountId, $type, $value) + public static function add($conn, $txHash, $dir, $accountId, $type, $value) { SqlHelper::insert( $conn,