From a7d754e053dc2c8212567b78445c005825161a07 Mon Sep 17 00:00:00 2001 From: elf <360197197@qq.com> Date: Tue, 27 Sep 2022 00:58:06 +0800 Subject: [PATCH 1/2] yhxxj --- .../Tool/GameResource/YhxxjClient.class.php | 196 ++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 Application/Base/Tool/GameResource/YhxxjClient.class.php diff --git a/Application/Base/Tool/GameResource/YhxxjClient.class.php b/Application/Base/Tool/GameResource/YhxxjClient.class.php new file mode 100644 index 000000000..d00032c9e --- /dev/null +++ b/Application/Base/Tool/GameResource/YhxxjClient.class.php @@ -0,0 +1,196 @@ + ['uri' => '/apip/payWM450S00/testingOrder', 'method' => 'post'], + ]; + + public function __construct($game = null) + { + $this->client = new Client([ + 'base_uri' => $this->baseUrl, + 'timeout' => 10.0, + ]); + } + + public function api($name, array $params = []) + { + $this->currentName = $name; + $api = $this->apis[$name] ?? null; + if (is_null($api)) { + throw new \Exception('接口不存在'); + } + $params[static::SIGN_NAME] = $this->sign($name, $params); + + // 发放道具接口特殊处理 + if ($name == 'send-props') { + $params = ['data' => json_encode($params)]; + } + try { + return $this->request($api, $params); + } catch (\Exception $e) { + $env = C('APP_ENV', null, 'prod'); + Log::error($this->logTag . $e->getMessage()); + return ['code' => 3, 'msg' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []]; + } + } + + public function request($api, $params) + { + if ($api['method'] == 'get') { + return $this->get($api['uri'], $params); + } else { + return $this->post($api['uri'], $params); + } + } + + protected function post($uri, array $params = []) + { + $response = $this->client->post($uri, [ + 'verify' => false, + 'form_params' => $params, + ]); + $result = (string)$response->getBody(); + Log::info($this->logTag . $uri . ' -- '. json_encode($params) . ' -- '. $result); + if ($this->currentName == 'send-testing') { + return $this->prepareResult($result); + } + return json_decode($result, true); + } + + protected function get($uri, array $params = []) + { + $response = $this->client->get($uri, [ + 'verify' => false, + 'query' => $params, + ]); + $result = (string)$response->getBody(); + Log::info($this->logTag . $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) + { + return md5( + $params['appId'] . + $params['orderNum'] . + $params['userId'] . + $params['moneyYuan'] . + $params['serviceId'] . + $params['roleId'] . + $params['time'] . + static::SIGN_KEY + ); + } + + protected function generateOrderNumber($order, $index = 0) + { + $length = 8 - strlen(strval($order['id'])); + $indexLength = 3 - strlen(strval($index)); + return date('Ymd') . str_repeat('0', $length) . $order['id'] . str_repeat('0', $indexLength) . $index; + } + + protected function getCommonResult($result, $successCode = 0) + { + if ($result['code'] == $successCode) { + return [ + 'status' => true, + 'message' => $result['msg'], + 'result' => $result + ]; + } else { + return [ + 'status' => false, + 'message' => $result['msg'], + 'result' => $result + ]; + } + } + + public function apply($order, $role) + { + $data = [ + 'appId' => static::APP_ID, + 'userId' => $role['user_id'], + 'serviceId' => $role['server_id'], + 'roleId' => $role['role_id'], + 'moneyYuan' => $order['ref_amount'], + 'orderNum' => $order['order_no'], + 'time' => time(), + ]; + + $result = $this->api('send-testing', $data); + return $this->getCommonResult($result); + } + + public function getResourceTypes($deviceType) + { + if ($deviceType == 'andriod') { + return [['id' => 1, 'name' => '通用', 'device_type' => 'andriod']]; + } elseif ($deviceType == 'ios') { + return [['id' => 2, 'name' => '通用', 'device_type' => 'ios']]; + } + } + + public function getResources($typeId, $deviceType) + { + return [ + 1 => ['ref_id' => 1, 'name' => '60元宝', 'amount' => 6], + 2 => ['ref_id' => 2, 'name' => '300元宝', 'amount' => 30], + 3 => ['ref_id' => 3, 'name' => '980元宝', 'amount' => 98], + 4 => ['ref_id' => 4, 'name' => '1280元宝', 'amount' => 128], + 5 => ['ref_id' => 5, 'name' => '1980元宝', 'amount' => 198], + 6 => ['ref_id' => 6, 'name' => '3280元宝', 'amount' => 328], + 7 => ['ref_id' => 7, 'name' => '6480元宝', 'amount' => 648], + 8 => ['ref_id' => 8, 'name' => '10000元宝', 'amount' => 1000], + 9 => ['ref_id' => 9, 'name' => '20000元宝', 'amount' => 2000], + 10 => ['ref_id' => 10, 'name' => '30000元宝', 'amount' => 3000], + 11 => ['ref_id' => 11, 'name' => '50000元宝', 'amount' => 5000], + 12 => ['ref_id' => 12, 'name' => '100000元宝', 'amount' => 10000], + 13 => ['ref_id' => 13, 'name' => '200000元宝', 'amount' => 20000], + ]; + } +} \ No newline at end of file From 554de62e19399f1f462260beb7e503d6626cadd4 Mon Sep 17 00:00:00 2001 From: ljl Date: Tue, 27 Sep 2022 14:30:19 +0800 Subject: [PATCH 2/2] yhxxj --- Application/Base/Tool/GameResource.class.php | 3 ++ .../Tool/GameResource/YhxxjClient.class.php | 39 ++----------------- 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/Application/Base/Tool/GameResource.class.php b/Application/Base/Tool/GameResource.class.php index 14aaea530..2dcf11bec 100644 --- a/Application/Base/Tool/GameResource.class.php +++ b/Application/Base/Tool/GameResource.class.php @@ -11,6 +11,7 @@ use Base\Tool\GameResource\LeyouClient; use Base\Tool\GameResource\SlzqClient; use Base\Tool\GameResource\XlqyClient; use Base\Tool\GameResource\XyyClient; +use Base\Tool\GameResource\YhxxjClient; /** * 游戏资源接口 @@ -51,6 +52,8 @@ class GameResource 308 => LeyouClient::class, // 云中如梦令(苹果版) 337 => LeyouClient::class, // 混沌天决(安卓版) 338 => LeyouClient::class, // 混沌天决(苹果版) + 363 => YhxxjClient::class, // 云海寻仙记(安卓版) + 364 => YhxxjClient::class, // 云海寻仙记(苹果版) ]; public function __construct($game) diff --git a/Application/Base/Tool/GameResource/YhxxjClient.class.php b/Application/Base/Tool/GameResource/YhxxjClient.class.php index d00032c9e..dfc122cde 100644 --- a/Application/Base/Tool/GameResource/YhxxjClient.class.php +++ b/Application/Base/Tool/GameResource/YhxxjClient.class.php @@ -12,22 +12,17 @@ use GuzzleHttp\Exception\RequestException; class YhxxjClient { const SIGN_NAME = 'sign'; - const SUCCESS = '0000'; - const APP_ID = 'FD32BDA67D6024D71'; - const SIGN_KEY = 'FzYrrm23eN8sMkomGiHM0QG2Uvk8uAPw'; - - // const APP_ID = '77A38AE4C5CAD6756'; // IOS - // const SIGN_KEY = 'rKkoznJcEhWaVPSuBnH1QnC9goDd4TcB'; // IOS + const APP_ID = 'wmtx'; + const SIGN_KEY = 'aiuh1i2349oijo3aa232423aq3215490gu34khb23'; protected $logTag = 'rebate:YHXXJ '; - protected $baseUrl = 'http://xx2api.hnputihd.com'; + protected $baseUrl = 'http://fross.jfungame.com:13996'; protected $client; - protected $currentName; protected $apis = [ - 'send-testing' => ['uri' => '/apip/payWM450S00/testingOrder', 'method' => 'post'], + 'send-testing' => ['uri' => '/oss.php?r=API/Rebate/rebate', 'method' => 'post'], ]; public function __construct($game = null) @@ -40,17 +35,12 @@ class YhxxjClient public function api($name, array $params = []) { - $this->currentName = $name; $api = $this->apis[$name] ?? null; if (is_null($api)) { throw new \Exception('接口不存在'); } $params[static::SIGN_NAME] = $this->sign($name, $params); - // 发放道具接口特殊处理 - if ($name == 'send-props') { - $params = ['data' => json_encode($params)]; - } try { return $this->request($api, $params); } catch (\Exception $e) { @@ -77,9 +67,6 @@ class YhxxjClient ]); $result = (string)$response->getBody(); Log::info($this->logTag . $uri . ' -- '. json_encode($params) . ' -- '. $result); - if ($this->currentName == 'send-testing') { - return $this->prepareResult($result); - } return json_decode($result, true); } @@ -91,26 +78,8 @@ class YhxxjClient ]); $result = (string)$response->getBody(); Log::info($this->logTag . $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) {