master
elf 3 years ago
parent 8443f20710
commit efce5e7aa8

@ -14,6 +14,7 @@ use think\Db;
use Base\Tool\GameResource;
use Base\Tool\GameResource\SbcqClient;
use Base\Tool\GameResource\XlqyClient;
use Base\Tool\GameResource\XyyClient;
class GameApiController extends Think {
@ -65,6 +66,18 @@ class GameApiController extends Think {
public function send()
{
$role = [
'role_id' => '93323379',
'server_id' => '89',
];
$order = [
'ref_amount' => 10,
];
$client = new XyyClient();
$result = $client->apply($order, $role);
var_dump($result);
return;
$game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => 291])->find();
$role = [
'role_id' => '829403',

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

Loading…
Cancel
Save