200) { myself()->_rspErr(1, 'More withdrawals than today'); return; } $seqId = Withdrawal::add($account, $type, $netId, $amount); myself()->_rspData(array( 'seq_id' => $seqId )); if ($this->isTestMode()) { Withdrawal::testOk($seqId, $account, $type, $netId, $amount); $this->notifyGame(0, $seqId, $account, $type, $netId, $amount); } } 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() { $account = strtolower(getReqVal('account', '')); $txHash = getReqVal('txhash', ''); $transferDb = Transfer::find($txHash); if (!$transferDb) { myself()->_rspData(array( 'state' => 2 )); if ($this->isTestMode()) { Withdrawal::testOk($txHash, $account, 1, 1, 1000); $this->notifyGame(0, $txHash, $account, 1, 1, 1000); } return; } if ($transferDb['state'] == 0) { myself()->_rspData(array( 'state' => 2 )); return; } else { myself()->_rspData(array( 'state' => 1 )); return; } } 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; } } }