From 5ddbf481ff1753a254a8724a3b616f51999e2148 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 30 Mar 2022 09:44:05 +0800 Subject: [PATCH] 1 --- sql/marketdb.sql | 2 +- webapp/controller/BcUserController.class.php | 37 ++++++++++++++++++++ webapp/controller/WalletController.class.php | 13 +++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/sql/marketdb.sql b/sql/marketdb.sql index 5c2ff748..d2ebef53 100644 --- a/sql/marketdb.sql +++ b/sql/marketdb.sql @@ -149,7 +149,7 @@ DROP TABLE IF EXISTS `t_withdrawal`; CREATE TABLE `t_withdrawal` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `account` varchar(255) NOT NULL DEFAULT '' COMMENT 'account', - `type` int(11) NOT NULL DEFAULT '0' COMMENT 'type', + `type` int(11) NOT NULL DEFAULT '0' COMMENT '货币类型 1:金币 2:钻石', `net_id` int(11) NOT NULL DEFAULT '0' COMMENT 'net_id', `amount` bigint NOT NULL DEFAULT '0' COMMENT 'amount', `state` int(11) NOT NULL DEFAULT '0' COMMENT 'state 0:等待上链 1:上链中2:上链成功 3:提现失败', diff --git a/webapp/controller/BcUserController.class.php b/webapp/controller/BcUserController.class.php index db22ca54..b0d4ff77 100644 --- a/webapp/controller/BcUserController.class.php +++ b/webapp/controller/BcUserController.class.php @@ -41,6 +41,33 @@ class BcUserController extends BaseController { array( 'account_id' => $accountId, )); + if (SERVER_ENV == _TEST) { + if (!$userRow && !$walletOfflineRow) { + SqlHelper::insert( + $conn, + 't_user_wallet_offline', + array( + 'account_id' => $accountId, + 'gold' => 10000, + 'diamond' => 10000, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ) + ); + } + $userRow = SqlHelper::ormSelectOne( + $conn, + 't_user', + array( + 'account_id' => $accountId, + )); + $walletOfflineRow = SqlHelper::ormSelectOne( + $conn, + 't_user_wallet_offline', + array( + 'account_id' => $accountId, + )); + } $gold = 0; $diamond = 0; if ($userRow) { @@ -51,6 +78,16 @@ class BcUserController extends BaseController { $gold += $walletOfflineRow['gold']; $diamond += $walletOfflineRow['diamond']; } + if (SERVER_ENV == _TEST) { + if (!$userRow && !$walletOfflineRow) { + SqlHelper::ormSelectOne( + $conn, + 't_user_wallet_offline', + array( + 'account_id' => $accountId, + )); + } + } myself()->_rspData(array( 'gold' => $gold, 'diamond' => $diamond diff --git a/webapp/controller/WalletController.class.php b/webapp/controller/WalletController.class.php index 6a4a8369..eb31a726 100644 --- a/webapp/controller/WalletController.class.php +++ b/webapp/controller/WalletController.class.php @@ -30,6 +30,19 @@ class WalletController extends BaseController { myself()->_rspErr(1, 'More withdrawals than today'); return; } + if (!in_array($type, array(1, 2))){ + myself()->_rspErr(2, 'parameter error'); + return; + } + if (strlen($amount) <= 18){ + myself()->_rspErr(4, 'parameter error'); + return; + } + $value = substr($amount, 0, -18); + if ($value < 0 || empty($value)) { + myself()->_rspErr(4, 'parameter error'); + return; + } $seqId = Withdrawal::add($account, $type, $netId, $amount); myself()->_rspData(array( 'seq_id' => $seqId