This commit is contained in:
aozhiwei 2022-03-30 08:11:25 +08:00
parent a2b691f090
commit 86055a89f9
5 changed files with 45 additions and 44 deletions

View File

@ -89,7 +89,8 @@ CREATE TABLE `t_user_wallet_record` (
`dir` int(11) NOT NULL DEFAULT '0' COMMENT 'dir', `dir` int(11) NOT NULL DEFAULT '0' COMMENT 'dir',
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
`type` int(11) NOT NULL DEFAULT '0' COMMENT 'type', `type` int(11) NOT NULL DEFAULT '0' COMMENT 'type',
`value` bigint NOT NULL DEFAULT '0' COMMENT 'value', `value` varchar(100) NOT NULL DEFAULT '' COMMENT 'value',
`state` int(11) NOT NULL DEFAULT '0' COMMENT 'state',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`), PRIMARY KEY (`idx`),

View File

@ -19,6 +19,22 @@ CREATE TABLE `version` (
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `t_parameter`
--
DROP TABLE IF EXISTS `t_parameter`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_parameter` (
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name',
`value` mediumblob COMMENT 'value',
PRIMARY KEY (`idx`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- Table structure for table `t_box_order` -- Table structure for table `t_box_order`
-- --
@ -158,11 +174,13 @@ DROP TABLE IF EXISTS `t_transfer`;
CREATE TABLE `t_transfer` ( CREATE TABLE `t_transfer` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`txhash` varchar(255) NOT NULL DEFAULT '' COMMENT 'txhash', `txhash` varchar(255) NOT NULL DEFAULT '' COMMENT 'txhash',
`block_number` varchar(60) NOT NULL DEFAULT '' COMMENT '块id',
`type` int(11) NOT NULL DEFAULT '0' COMMENT 'type', `type` int(11) NOT NULL DEFAULT '0' COMMENT 'type',
`_from` varchar(255) NOT NULL DEFAULT '' COMMENT '_from', `_from` varchar(255) NOT NULL DEFAULT '' COMMENT '_from',
`_to` varchar(255) NOT NULL DEFAULT '' COMMENT '_to', `_to` varchar(255) NOT NULL DEFAULT '' COMMENT '_to',
`value` bigint NOT NULL DEFAULT '0' COMMENT 'value', `value` varchar(255) NOT NULL DEFAULT '' COMMENT 'value',
`state` int(11) NOT NULL DEFAULT '0' COMMENT '0:未同步 1:同步成功', `state` int(11) NOT NULL DEFAULT '0' COMMENT '0:未同步 1:同步成功 2:失败',
`reason` mediumblob COMMENT 'reason',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`), PRIMARY KEY (`idx`),

View File

@ -42,6 +42,7 @@ class CallbackController extends BaseController {
myself()->_rspOk(); myself()->_rspOk();
return; return;
} }
UserWalletRecord::add($conn, $txHash, $dir, $account, $type, $value);
if (!in_array($dir, array(0, 1))){ if (!in_array($dir, array(0, 1))){
myself()->_rspErr(1, ''); myself()->_rspErr(1, '');
@ -52,6 +53,11 @@ class CallbackController extends BaseController {
myself()->_rspErr(2, ''); myself()->_rspErr(2, '');
return; return;
} }
if (strlen($value) <= 18){
myself()->_rspErr(4, '');
return;
}
$value = substr($value, 0, -18);
if ($value < 0 || empty($value)) { if ($value < 0 || empty($value)) {
myself()->_rspErr(3, ''); myself()->_rspErr(3, '');
return; return;
@ -114,11 +120,13 @@ class CallbackController extends BaseController {
'modifytime' => myself()->_getNowTime() 'modifytime' => myself()->_getNowTime()
)); ));
} }
UserWalletRecord::update($conn,
$txHash,
array(
'state' => 1,
'modifytime' => myself()->_getNowTime()
));
UserWalletRecord::add($conn, $txHash, $dir, $account, $type, $value);
if ($this->isTestMode()) {
}
myself()->_rspOk(); myself()->_rspOk();
} }

View File

@ -18,11 +18,6 @@ use models\Transfer;
class WalletController extends BaseController { class WalletController extends BaseController {
private function isTestMode()
{
return isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443 && SERVER_ENV == _TEST;
}
public function withdrawal() public function withdrawal()
{ {
$account = strtolower(getReqVal('account', '')); $account = strtolower(getReqVal('account', ''));
@ -39,10 +34,6 @@ class WalletController extends BaseController {
myself()->_rspData(array( myself()->_rspData(array(
'seq_id' => $seqId 'seq_id' => $seqId
)); ));
if ($this->isTestMode()) {
Withdrawal::testOk($seqId, $account, $type, $netId, $amount);
$this->notifyGame(0, $seqId, $account, $type, $netId, $amount);
}
} }
public function queryWithdrawalResult() public function queryWithdrawalResult()
@ -95,10 +86,6 @@ class WalletController extends BaseController {
myself()->_rspData(array( myself()->_rspData(array(
'state' => 2 'state' => 2
)); ));
if ($this->isTestMode()) {
Withdrawal::testOk($txHash, $account, 1, 1, 1000);
$this->notifyGame(0, $txHash, $account, 1, 1, 1000);
}
return; return;
} }
if ($transferDb['state'] == 0) { if ($transferDb['state'] == 0) {
@ -114,28 +101,4 @@ class WalletController extends BaseController {
} }
} }
private function notifyGame($dir, $txhash, $account, $type, $netId, $value)
{
$apiUrl = "https://game2006api-test.kingsome.cn";
$params = array(
'c' => 'Callback',
'a' => 'transfer',
'dir' => $dir,
'txhash' => $txhash,
'account' => $account,
'type' => $type,
'value' => $value
);
$url = $apiUrl . '/webapp/index.php';
$response = '';
if (!phpcommon\HttpClient::get
($url,
$params,
$response)) {
phpcommon\sendError(500, 'server internal error');
die();
return;
}
}
} }

View File

@ -35,4 +35,15 @@ class UserWalletRecord extends BaseModel {
)); ));
} }
public static function update($conn, $txHash, $fieldKv)
{
SqlHelper::update(
$conn,
't_user_wallet_record',
array(
'txhash' => $txHash,
),
$fieldKv);
}
} }