1
This commit is contained in:
parent
bbf9365590
commit
10a95dff2e
@ -1,58 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import _common
|
||||
|
||||
class Wallet(object):
|
||||
|
||||
def __init__(self):
|
||||
self.apis = [
|
||||
{
|
||||
'name': 'withdrawal',
|
||||
'desc': '提现(game->token)',
|
||||
'group': 'Wallet',
|
||||
'url': 'webapp/index.php?c=Wallet&a=withdrawal',
|
||||
'params': [
|
||||
['account', 0, '钱包账号'],
|
||||
['token', '', 'token'],
|
||||
['type', 0, '货币类型 1:金币 2:钻石'],
|
||||
['amount', '', '金额'],
|
||||
['net_id', '', '网络id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['seq_id', '', '提现序号(errcode = 0的时候,根据序号客户端定时调用queryWithdrawalResult接口)查询状态'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'queryWithdrawalResult',
|
||||
'desc': '查询提现结果(game->token)',
|
||||
'group': 'Wallet',
|
||||
'url': 'webapp/index.php?c=Wallet&a=queryWithdrawalResult',
|
||||
'params': [
|
||||
['account', 0, '钱包账号'],
|
||||
['token', '', 'token'],
|
||||
['seq_id', 0, '提现序号'],
|
||||
['net_id', '', '网络id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(errcode='当errcode!=0的时候客户端不需要再调用(停止定时器)'),
|
||||
['state', 0, '0:提现序号不存在 1:提现成功 2:提现处理中 3:提现失败'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'queryRechargeResult',
|
||||
'desc': '查询充值结果(token->game)',
|
||||
'group': 'Wallet',
|
||||
'url': 'webapp/index.php?c=Wallet&a=queryRechargeResult',
|
||||
'params': [
|
||||
['account', 0, '钱包账号'],
|
||||
['token', '', 'token'],
|
||||
['txhash', 0, 'hash值'],
|
||||
['net_id', '', '网络id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['state', 0, '0:保留 1:充值成功 2:充值处理中 3:充值失败'],
|
||||
]
|
||||
},
|
||||
]
|
@ -1,121 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/Currency.php');
|
||||
require_once('mt/Hero.php');
|
||||
require_once('mt/Parameter.php');
|
||||
|
||||
require_once('models/Nft.php');
|
||||
require_once('models/Withdrawal.php');
|
||||
require_once('models/Transfer.php');
|
||||
|
||||
require_once('phpcommon/bchelper.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Nft;
|
||||
use models\Withdrawal;
|
||||
use models\Transfer;
|
||||
|
||||
class WalletController extends BaseController {
|
||||
|
||||
public function withdrawal()
|
||||
{
|
||||
myself()->_rspErr(2, 'parameter error');
|
||||
return;
|
||||
$account = strtolower(getReqVal('account', ''));
|
||||
$token = getReqVal('token', '');
|
||||
$type = getReqVal('type', '');
|
||||
$netId = getReqVal('net_id', '');
|
||||
$amount = getReqVal('amount', '');
|
||||
$times = Withdrawal::getTodayWithdrawalTimes($account);
|
||||
if ($times > 200) {
|
||||
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
|
||||
));
|
||||
}
|
||||
|
||||
public function queryWithdrawalResult()
|
||||
{
|
||||
$account = strtolower(getReqVal('account', ''));
|
||||
$seqId = getReqVal('seq_id', '');
|
||||
$row = Withdrawal::find($seqId);
|
||||
if (!$row || $row['account'] != $account) {
|
||||
myself()->_rspErr(0, 'not found');
|
||||
return;
|
||||
}
|
||||
if ($row['state'] == 1) {
|
||||
myself()->_rspData(array(
|
||||
'state' => 2
|
||||
));
|
||||
return;
|
||||
}
|
||||
if ($row['state'] == 3) {
|
||||
myself()->_rspData(array(
|
||||
'state' => 3
|
||||
));
|
||||
return;
|
||||
}
|
||||
$transferDb = Transfer::find($row['bc_txhash']);
|
||||
if (!$transferDb) {
|
||||
myself()->_rspData(array(
|
||||
'state' => 2
|
||||
));
|
||||
return;
|
||||
}
|
||||
if ($transferDb['state'] == 0) {
|
||||
myself()->_rspData(array(
|
||||
'state' => 2
|
||||
));
|
||||
return;
|
||||
} else {
|
||||
myself()->_rspData(array(
|
||||
'state' => 1
|
||||
));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function queryRechargeResult()
|
||||
{
|
||||
myself()->_rspErr(2, 'parameter error');
|
||||
return;
|
||||
$account = strtolower(getReqVal('account', ''));
|
||||
$txHash = getReqVal('txhash', '');
|
||||
$transferDb = Transfer::find($txHash);
|
||||
if (!$transferDb) {
|
||||
myself()->_rspData(array(
|
||||
'state' => 2
|
||||
));
|
||||
return;
|
||||
}
|
||||
if ($transferDb['state'] == 0) {
|
||||
myself()->_rspData(array(
|
||||
'state' => 2
|
||||
));
|
||||
return;
|
||||
} else {
|
||||
myself()->_rspData(array(
|
||||
'state' => 1
|
||||
));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user