|
|
@ -21,18 +21,6 @@ class XyyClient
|
|
|
|
'provide' => ['uri' => '/Api/Statis/sendgold', 'method' => 'post'],
|
|
|
|
'provide' => ['uri' => '/Api/Statis/sendgold', 'method' => 'post'],
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
private $messages = [
|
|
|
|
|
|
|
|
0 => '发送成功',
|
|
|
|
|
|
|
|
-1 => '参数传递不完整',
|
|
|
|
|
|
|
|
-2 => '奖金池元宝数量不足',
|
|
|
|
|
|
|
|
-3 => '奖金池绑定元宝数量不足',
|
|
|
|
|
|
|
|
-4 => '元宝发送失败,联系管理员',
|
|
|
|
|
|
|
|
-5 => '签名校验失败,检查加密串',
|
|
|
|
|
|
|
|
-6 => '请求超时,当前时间戳超过300ms',
|
|
|
|
|
|
|
|
-7 => '角色不存在',
|
|
|
|
|
|
|
|
-9 => '重复发送,同一角色重复发送时间间隔10s',
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->client = new Client([
|
|
|
|
$this->client = new Client([
|
|
|
@ -47,7 +35,7 @@ class XyyClient
|
|
|
|
if (is_null($api)) {
|
|
|
|
if (is_null($api)) {
|
|
|
|
throw new \Exception('接口不存在');
|
|
|
|
throw new \Exception('接口不存在');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$params[self::SIGN_NAME] = $this->sign($name, $params);
|
|
|
|
$params[self::SIGN_NAME] = $this->sign($params);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
return $this->request($api, $params);
|
|
|
|
return $this->request($api, $params);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
} catch (\Exception $e) {
|
|
|
@ -74,7 +62,7 @@ class XyyClient
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
$result = (string)$response->getBody();
|
|
|
|
$result = (string)$response->getBody();
|
|
|
|
Log::info('ts:XYY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
|
|
|
|
Log::info('ts:XYY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
|
|
|
|
return ['code' => $result, 'msg' => $this->messages[$result] ?? '未知错误' , 'data' => []];
|
|
|
|
return json_decode($result, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected function get($uri, array $params = [])
|
|
|
|
protected function get($uri, array $params = [])
|
|
|
@ -85,23 +73,23 @@ class XyyClient
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
$result = (string)$response->getBody();
|
|
|
|
$result = (string)$response->getBody();
|
|
|
|
Log::info('ts:XYY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
|
|
|
|
Log::info('ts:XYY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
|
|
|
|
return ['code' => $result, 'msg' => $this->messages[$result] ?? '未知错误' , 'data' => []];
|
|
|
|
return json_decode($result, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected function sign($params)
|
|
|
|
protected function sign($params)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return md5(
|
|
|
|
$signStr =
|
|
|
|
$params['actors'] .
|
|
|
|
$params['actors'] .
|
|
|
|
$params['pfrom_id'] .
|
|
|
|
$params['pfrom_id'] .
|
|
|
|
$params['server_id'] .
|
|
|
|
$params['server_id'] .
|
|
|
|
$params['sendnum_yb'] .
|
|
|
|
$params['sendnum_yb'] .
|
|
|
|
$params['sendnum_by'] .
|
|
|
|
$params['sendnum_by'] .
|
|
|
|
$params['email_title'] .
|
|
|
|
urlencode($params['email_title']) .
|
|
|
|
$params['email_content'] .
|
|
|
|
urlencode($params['email_content']) .
|
|
|
|
self::SIGN_KEY .
|
|
|
|
self::SIGN_KEY .
|
|
|
|
$params['time'].
|
|
|
|
$params['time'].
|
|
|
|
$params['type']
|
|
|
|
$params['type'];
|
|
|
|
);
|
|
|
|
return md5($signStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private function getCommonResult($result)
|
|
|
|
private function getCommonResult($result)
|
|
|
|