From d6bae02a9c430a4b49efc7d5d64bcfdbb07a81bd Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 15 Aug 2023 11:44:55 +0800 Subject: [PATCH] 1 --- webapp/controller/ToolsController.class.php | 77 +++++++++++++++++++++ webapp/models/OutAppOrder.php | 8 +-- webapp/services/callback/OutAppPurchase.php | 3 +- 3 files changed, 83 insertions(+), 5 deletions(-) diff --git a/webapp/controller/ToolsController.class.php b/webapp/controller/ToolsController.class.php index b52334c8..942a9b0a 100644 --- a/webapp/controller/ToolsController.class.php +++ b/webapp/controller/ToolsController.class.php @@ -137,6 +137,83 @@ class ToolsController extends BaseController { )); } + public function outappRecharge() + { + $orderInfo = null; + { + $params = array( + 'c' => 'Shop', + 'a' => 'outappPurchase', + 'account_id' => getReqVal('account_id', ''), + 'session_id' => getReqVal('session_id', ''), + 'goods_id' => getReqVal('goods_id', ''), + 'goods_num' => getReqVal('goods_num', ''), + 'platform' => getReqVal('platform', ''), + 'network' => getReqVal('network', ''), + 'crypto' => getReqVal('crypto', ''), + 'fiat' => getReqVal('fiat', ''), + 'fiatAmount' => getReqVal('fiatAmount', ''), + 'payWayCode' => getReqVal('payWayCode', ''), + 'country' => getReqVal('country', ''), + ); + $url = "https://game2006api-test.kingsome.cn/webapp/index.php?"; + $response = ''; + if (!phpcommon\HttpClient::get + ($url, + $params, + $response)) { + error_log($response); + myself()->_rspErr(500, 'server internal error 3, url:' . $url); + die(); + return; + } + $orderInfo = json_decode($response, true); + //echo $response; + } + { + $params = array( + 'c' => 'Callback', + 'a' => 'dispatch', + 'action' => 'outappPurchase', + 'account_id' => getReqVal('account_id', ''), + 'order_id' => $orderInfo['order_id'], + 'status' => 99, + 'id' => 1, + 'txhash' => '', + ); + { + $signArr = array( + 'account_id' => $params['account_id'], + 'order_id' => $params['order_id'], + 'status' => $params['status'], + 'id' => $params['id'], + 'txhash' => $params['txhash'] + ); + ksort($signArr); + $arrSign = array(); + foreach($signArr as $key => $val){ + array_push($arrSign, $key . '=' . $val); + } + $signStr = implode('&', $arrSign); + $sign = hash_hmac('sha256', $signStr, BUY_SERVER_PKEY); + error_log($signStr . BUY_SERVER_PKEY . '|!' . $sign); + $params['sign'] = $sign; + } + $url = "https://game2006api-test.kingsome.cn/webapp/index.php?"; + $response = ''; + if (!phpcommon\HttpClient::get + ($url, + $params, + $response)) { + error_log($response); + myself()->_rspErr(500, 'server internal error 3, url:' . $url); + die(); + return; + } + echo $response; + } + } + private function writeToFile($fileName, $data) { $fp = fopen($fileName, 'w'); diff --git a/webapp/models/OutAppOrder.php b/webapp/models/OutAppOrder.php index 9c6b7474..cb8b5701 100644 --- a/webapp/models/OutAppOrder.php +++ b/webapp/models/OutAppOrder.php @@ -44,13 +44,13 @@ class OutAppOrder extends BaseModel { public static function markFinished($orderId) { SqlHelper::update( - myself()->_get(), + myself()->_getMysql(''), 't_outapp_order', array( 'order_id' => $orderId, ), array( - 'state' => self::FINISHED_STATE, + 'status' => self::FINISHED_STATE, ) ); } @@ -58,13 +58,13 @@ class OutAppOrder extends BaseModel { public static function markFailed($orderId) { SqlHelper::update( - myself()->_get(), + myself()->_getMysql(''), 't_outapp_order', array( 'order_id' => $orderId, ), array( - 'state' => self::FAILED_STATE, + 'status' => self::FAILED_STATE, ) ); } diff --git a/webapp/services/callback/OutAppPurchase.php b/webapp/services/callback/OutAppPurchase.php index 7e24c54b..a7ba29c1 100644 --- a/webapp/services/callback/OutAppPurchase.php +++ b/webapp/services/callback/OutAppPurchase.php @@ -14,6 +14,7 @@ require_once("ShopAddItemService.php"); use phpcommon\SqlHelper; +use mt; use models\ShopBuyRecord; use models\OutAppOrder; use models\FirstTopup; @@ -98,7 +99,7 @@ class OutAppPurchase { } } - $this->_rspOk(); + myself()->_rspOk(); } private function verifySign()