master
ELF 3 years ago
parent 818189ba9b
commit c160f5a299

@ -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,

@ -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)

@ -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)

Loading…
Cancel
Save