|
|
@ -12,22 +12,17 @@ use GuzzleHttp\Exception\RequestException;
|
|
|
|
class YhxxjClient
|
|
|
|
class YhxxjClient
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const SIGN_NAME = 'sign';
|
|
|
|
const SIGN_NAME = 'sign';
|
|
|
|
const SUCCESS = '0000';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const APP_ID = 'FD32BDA67D6024D71';
|
|
|
|
const APP_ID = 'wmtx';
|
|
|
|
const SIGN_KEY = 'FzYrrm23eN8sMkomGiHM0QG2Uvk8uAPw';
|
|
|
|
const SIGN_KEY = 'aiuh1i2349oijo3aa232423aq3215490gu34khb23';
|
|
|
|
|
|
|
|
|
|
|
|
// const APP_ID = '77A38AE4C5CAD6756'; // IOS
|
|
|
|
|
|
|
|
// const SIGN_KEY = 'rKkoznJcEhWaVPSuBnH1QnC9goDd4TcB'; // IOS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected $logTag = 'rebate:YHXXJ ';
|
|
|
|
protected $logTag = 'rebate:YHXXJ ';
|
|
|
|
|
|
|
|
|
|
|
|
protected $baseUrl = 'http://xx2api.hnputihd.com';
|
|
|
|
protected $baseUrl = 'http://fross.jfungame.com:13996';
|
|
|
|
protected $client;
|
|
|
|
protected $client;
|
|
|
|
protected $currentName;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected $apis = [
|
|
|
|
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)
|
|
|
|
public function __construct($game = null)
|
|
|
@ -40,17 +35,12 @@ class YhxxjClient
|
|
|
|
|
|
|
|
|
|
|
|
public function api($name, array $params = [])
|
|
|
|
public function api($name, array $params = [])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->currentName = $name;
|
|
|
|
|
|
|
|
$api = $this->apis[$name] ?? null;
|
|
|
|
$api = $this->apis[$name] ?? null;
|
|
|
|
if (is_null($api)) {
|
|
|
|
if (is_null($api)) {
|
|
|
|
throw new \Exception('接口不存在');
|
|
|
|
throw new \Exception('接口不存在');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$params[static::SIGN_NAME] = $this->sign($name, $params);
|
|
|
|
$params[static::SIGN_NAME] = $this->sign($name, $params);
|
|
|
|
|
|
|
|
|
|
|
|
// 发放道具接口特殊处理
|
|
|
|
|
|
|
|
if ($name == 'send-props') {
|
|
|
|
|
|
|
|
$params = ['data' => json_encode($params)];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
return $this->request($api, $params);
|
|
|
|
return $this->request($api, $params);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
} catch (\Exception $e) {
|
|
|
@ -77,9 +67,6 @@ class YhxxjClient
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
$result = (string)$response->getBody();
|
|
|
|
$result = (string)$response->getBody();
|
|
|
|
Log::info($this->logTag . $uri . ' -- '. json_encode($params) . ' -- '. $result);
|
|
|
|
Log::info($this->logTag . $uri . ' -- '. json_encode($params) . ' -- '. $result);
|
|
|
|
if ($this->currentName == 'send-testing') {
|
|
|
|
|
|
|
|
return $this->prepareResult($result);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return json_decode($result, true);
|
|
|
|
return json_decode($result, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -91,27 +78,9 @@ class YhxxjClient
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
$result = (string)$response->getBody();
|
|
|
|
$result = (string)$response->getBody();
|
|
|
|
Log::info($this->logTag . $uri . ' -- '. json_encode($params) . ' -- '. $result);
|
|
|
|
Log::info($this->logTag . $uri . ' -- '. json_encode($params) . ' -- '. $result);
|
|
|
|
if ($this->currentName == 'send-testing') {
|
|
|
|
|
|
|
|
return $this->prepareResult($result);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return json_decode($result, true);
|
|
|
|
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)
|
|
|
|
protected function sign($name, $params)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return md5(
|
|
|
|
return md5(
|
|
|
|