From c160f5a299247e01c68f393a75afd30eeefed91e Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Thu, 23 Sep 2021 10:34:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/GameApiController.class.php | 17 ++++++++ Application/Base/Tool/GameResource.class.php | 3 ++ .../Tool/GameResource/XlqyClient.class.php | 41 ++++++++++++------- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/Application/Admin/Controller/GameApiController.class.php b/Application/Admin/Controller/GameApiController.class.php index 56a4bc6b1..b5f5f153f 100644 --- a/Application/Admin/Controller/GameApiController.class.php +++ b/Application/Admin/Controller/GameApiController.class.php @@ -66,6 +66,23 @@ class GameApiController extends Think { public function send() { + $game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => 291])->find(); + $role = [ + 'role_id' => '829403', + 'user_id' => '1194396', + 'server_id' => '744', + 'sdk_version' => 1, + ]; + $order = [ + 'ref_amount' => 1, + 'remark' => '测试', + 'order_no' => date('YmdHis') . rand(1000, 9999) . '_1', + ]; + $gameResource = new GameResource($game); + // $result = $gameResource->getResources(); + $result = $gameResource->apply($order, $role); + var_dump($result); + return; $giftItem = [ 'id' => 240, 'num' => 1, diff --git a/Application/Base/Tool/GameResource.class.php b/Application/Base/Tool/GameResource.class.php index 793bf0b87..d61643907 100644 --- a/Application/Base/Tool/GameResource.class.php +++ b/Application/Base/Tool/GameResource.class.php @@ -8,6 +8,7 @@ use GuzzleHttp\Exception\RequestException; use Base\Tool\GameResource\YzchzbClient; use Base\Tool\GameResource\LsxxClient; use Base\Tool\GameResource\LeyouClient; +use Base\Tool\GameResource\XlqyClient; /** * 游戏资源接口 @@ -34,6 +35,8 @@ class GameResource 281 => LeyouClient::class, // 万剑八荒(苹果版) 279 => LeyouClient::class, // 烈火长歌行(苹果版) 286 => LeyouClient::class, // 烈火长歌行(安卓版) + 291 => XlqyClient::class, // 玄灵契约(安卓版) + 292 => XlqyClient::class, // 玄灵契约(苹果版) ]; public function __construct($game) diff --git a/Application/Base/Tool/GameResource/XlqyClient.class.php b/Application/Base/Tool/GameResource/XlqyClient.class.php index fefef7322..cf6f50bce 100644 --- a/Application/Base/Tool/GameResource/XlqyClient.class.php +++ b/Application/Base/Tool/GameResource/XlqyClient.class.php @@ -21,6 +21,7 @@ class XlqyClient // const SIGN_KEY = 'rKkoznJcEhWaVPSuBnH1QnC9goDd4TcB'; // IOS protected $client; + protected $currentName; private $apis = [ 'send-email' => ['uri' => '/apip/payWM450S00/emRebate', 'method' => 'post'], @@ -37,6 +38,7 @@ class XlqyClient public function api($name, array $params = []) { + $this->currentName = $name; $api = $this->apis[$name] ?? null; if (is_null($api)) { throw new \Exception('接口不存在'); @@ -68,6 +70,9 @@ class XlqyClient ]); $result = (string)$response->getBody(); Log::info('rebate:XLQY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result); + if ($this->currentName == 'send-testing') { + return $this->prepareResult($result); + } return json_decode($result, true); } @@ -79,8 +84,26 @@ class XlqyClient ]); $result = (string)$response->getBody(); Log::info('rebate:XLQY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result); + if ($this->currentName == 'send-testing') { + return $this->prepareResult($result); + } return json_decode($result, true); } + + protected function prepareResult($result) + { + if ($result == 'SUCCESS') { + return [ + 'code' => 0, + 'msg' => $result, + ]; + } else { + return [ + 'code' => 1, + 'msg' => $result, + ]; + } + } protected function sign($name, $params) { @@ -100,7 +123,7 @@ class XlqyClient $params['appId'] . $params['orderNum'] . $params['userId'] . - $params['MoneyYuan'] . + $params['moneyYuan'] . $params['serviceId'] . $params['roleId'] . $params['time'] . @@ -158,25 +181,13 @@ class XlqyClient 'userId' => $role['user_id'], 'serviceId' => $role['server_id'], 'roleId' => $role['role_id'], - 'MoneyYuan' => $order['ref_amount'], + 'moneyYuan' => $order['ref_amount'], 'orderNum' => $order['order_no'], 'time' => time(), ]; $result = $this->api('send-testing', $data); - if ($result == 'SUCCESS') { - return [ - 'status' => true, - 'message' => $result, - 'result' => ['result' => $result] - ]; - } else { - return [ - 'status' => false, - 'message' => $result, - 'result' => ['result' => $result] - ]; - } + return $this->getCommonResult($result); } public function getResourceTypes($deviceType)