|
|
@ -6,30 +6,28 @@ use Base\Tool\PlatformLog;
|
|
|
|
use GuzzleHttp\Client;
|
|
|
|
use GuzzleHttp\Client;
|
|
|
|
use Think\Log;
|
|
|
|
use Think\Log;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
abstract class JhBaseClient
|
|
|
|
* 天之禁2-测试资源接口
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
class TzjClient
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const SIGN_NAME = 'sign';
|
|
|
|
const SIGN_NAME = 'sign';
|
|
|
|
const SUCCESS = 1;
|
|
|
|
const SUCCESS = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected $baseUri;
|
|
|
|
protected $key;
|
|
|
|
protected $key;
|
|
|
|
protected $brAppId;
|
|
|
|
protected $brAppId;
|
|
|
|
protected $brPCode;
|
|
|
|
protected $brPCode;
|
|
|
|
|
|
|
|
|
|
|
|
protected $client;
|
|
|
|
protected $client;
|
|
|
|
|
|
|
|
|
|
|
|
private $apis = [
|
|
|
|
protected $apis = [
|
|
|
|
'mail' => ['url' => '/wf/m/mail/brRom/1/brPCode/{brPCode}/brAppId/{brAppId}', 'method' => 'post'],
|
|
|
|
'mail' => ['url' => '/wf/m/mail/brRom/1/brPCode/{brPCode}/brAppId/{brAppId}', 'method' => 'post'],
|
|
|
|
'prop' => ['url' => '/wf/m/prop/brRom/1/brPCode/{brPCode}/brAppId/{brAppId}', 'method' => 'post'],
|
|
|
|
'prop' => ['url' => '/wf/m/prop/brRom/1/brPCode/{brPCode}/brAppId/{brAppId}', 'method' => 'post'],
|
|
|
|
'pay' => ['url' => '/wf/m/pay/brRom/1/brPCode/{brPCode}/brAppId/{brAppId}', 'method' => 'post'],
|
|
|
|
'pay' => ['url' => '/wf/m/pay/brRom/1/brPCode/{brPCode}/brAppId/{brAppId}', 'method' => 'post'],
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct($game = null)
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->client = new Client([
|
|
|
|
$this->client = new Client([
|
|
|
|
'base_uri' => 'http://club.game.267zf.com',
|
|
|
|
'base_uri' => $this->baseUri,
|
|
|
|
'timeout' => 10.0,
|
|
|
|
'timeout' => 10.0,
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -112,25 +110,70 @@ class TzjClient
|
|
|
|
|
|
|
|
|
|
|
|
public function apply($order, $role)
|
|
|
|
public function apply($order, $role)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
$data = [
|
|
|
|
'userId' => $role['user_id'],
|
|
|
|
'userId' => $role['user_id'],
|
|
|
|
'roleId' => $role['role_id'],
|
|
|
|
'roleId' => $role['role_id'],
|
|
|
|
'serverId' => $role['server_id'],
|
|
|
|
'serverId' => $role['server_id'],
|
|
|
|
'orderNum' => $order['order_no'],
|
|
|
|
'orderNum' => $this->generateOrderNumber($order),
|
|
|
|
|
|
|
|
'moneyFen' => $order['amount'],
|
|
|
|
|
|
|
|
'time' => time(),
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function sendProps($order)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$props = [];
|
|
|
|
|
|
|
|
$order['props'] = json_decode($order['props'], true);
|
|
|
|
|
|
|
|
foreach ($order['props'] as $prop) {
|
|
|
|
|
|
|
|
$props[] = [
|
|
|
|
|
|
|
|
'propId' => $prop['ref_id'],
|
|
|
|
|
|
|
|
'count' => $prop['num'],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
|
|
|
|
'userId' => $order['user_id'],
|
|
|
|
|
|
|
|
'roleId' => $order['role_id'],
|
|
|
|
|
|
|
|
'serverId' => $order['server_id'],
|
|
|
|
|
|
|
|
'orderNum' => $this->generateOrderNumber($order),
|
|
|
|
|
|
|
|
'propData' => $props,
|
|
|
|
'time' => time(),
|
|
|
|
'time' => time(),
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
$result = $this->api('prop', $data);
|
|
|
|
|
|
|
|
return $this->getCommonResult($result, 200);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$refId = $order['ref_id'];
|
|
|
|
public function sendGold($gold, $order)
|
|
|
|
$api = '';
|
|
|
|
{
|
|
|
|
if ($api == 'mail') {
|
|
|
|
$data = [
|
|
|
|
$data['mailData'] = $refId;
|
|
|
|
'userId' => $order['user_id'],
|
|
|
|
} elseif ($api == 'prop') {
|
|
|
|
'roleId' => $order['role_id'],
|
|
|
|
$data['propData'] = $refId;
|
|
|
|
'serverId' => $order['server_id'],
|
|
|
|
} elseif ($api == 'pay') {
|
|
|
|
'orderNum' => $this->generateOrderNumber($order),
|
|
|
|
$data['moneyFen'] = intval($order['ref_amount'] * 100);
|
|
|
|
'moneyFen' => $gold,
|
|
|
|
|
|
|
|
'time' => time(),
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->api('pay', $data);
|
|
|
|
|
|
|
|
return $this->getCommonResult($result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->api($api, $data);
|
|
|
|
public function sendEmail($giftItem, $order)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
|
|
|
|
'userId' => $order['user_id'],
|
|
|
|
|
|
|
|
'roleId' => $order['role_id'],
|
|
|
|
|
|
|
|
'serverId' => $order['server_id'],
|
|
|
|
|
|
|
|
'orderNum' => $this->generateOrderNumber($order, $giftItem['index']),
|
|
|
|
|
|
|
|
'mailData' => [$giftItem['id']],
|
|
|
|
|
|
|
|
'time' => time(),
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->api('mail', $data);
|
|
|
|
|
|
|
|
return $this->getCommonResult($result);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function getCommonResult($result) {
|
|
|
|
if ($result == self::SUCCESS) {
|
|
|
|
if ($result == self::SUCCESS) {
|
|
|
|
return [
|
|
|
|
return [
|
|
|
|
'status' => true,
|
|
|
|
'status' => true,
|
|
|
@ -146,47 +189,24 @@ class TzjClient
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getResourceTypes($deviceType)
|
|
|
|
protected function generateOrderNumber($order, $index = 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ($deviceType == 'andriod') {
|
|
|
|
$length = 8 - strlen(strval($order['id']));
|
|
|
|
return [
|
|
|
|
$indexLength = 3 - strlen(strval($index));
|
|
|
|
['id' => 1, 'name' => '邮件', 'device_type' => 'andriod'],
|
|
|
|
return date('Ymd') . str_repeat('0', $length) . $order['id'] . str_repeat('0', $indexLength) . $index;
|
|
|
|
['id' => 2, 'name' => '道具', 'device_type' => 'andriod'],
|
|
|
|
|
|
|
|
['id' => 3, 'name' => '元宝', 'device_type' => 'andriod'],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
} elseif ($deviceType == 'ios') {
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
|
|
|
['id' => 1, 'name' => '邮件', 'device_type' => 'andriod'],
|
|
|
|
|
|
|
|
['id' => 2, 'name' => '道具', 'device_type' => 'andriod'],
|
|
|
|
|
|
|
|
['id' => 3, 'name' => '元宝', 'device_type' => 'andriod'],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getResourceTypes($deviceType)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getResources($typeId, $deviceType)
|
|
|
|
public function getResources($typeId, $deviceType)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ($typeId == 3) {
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
|
|
|
1 => ['ref_id' => 1, 'name' => '6元宝', 'amount' => 6],
|
|
|
|
|
|
|
|
2 => ['ref_id' => 2, 'name' => '30元宝', 'amount' => 30],
|
|
|
|
|
|
|
|
3 => ['ref_id' => 3, 'name' => '98元宝', 'amount' => 98],
|
|
|
|
|
|
|
|
// 4 => ['ref_id' => 4, 'name' => '128元宝', 'amount' => 128],
|
|
|
|
|
|
|
|
5 => ['ref_id' => 5, 'name' => '198元宝', 'amount' => 198],
|
|
|
|
|
|
|
|
6 => ['ref_id' => 6, 'name' => '328元宝', 'amount' => 328],
|
|
|
|
|
|
|
|
7 => ['ref_id' => 7, 'name' => '648元宝', 'amount' => 648],
|
|
|
|
|
|
|
|
8 => ['ref_id' => 8, 'name' => '1000元宝', 'amount' => 1000],
|
|
|
|
|
|
|
|
9 => ['ref_id' => 9, 'name' => '2000元宝', 'amount' => 2000],
|
|
|
|
|
|
|
|
// 10 => ['ref_id' => 10, 'name' => '3000元宝', 'amount' => 3000],
|
|
|
|
|
|
|
|
11 => ['ref_id' => 11, 'name' => '5000元宝', 'amount' => 5000],
|
|
|
|
|
|
|
|
// 12 => ['ref_id' => 12, 'name' => '10000元宝', 'amount' => 10000],
|
|
|
|
|
|
|
|
// 13 => ['ref_id' => 13, 'name' => '20000元宝', 'amount' => 20000],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return [];
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function log($message, $level = Log::INFO) {
|
|
|
|
protected function log($message, $level = Log::INFO) {
|
|
|
|
PlatformLog::write($message, 'game_api/tzj', $level);
|
|
|
|
PlatformLog::write($message, 'game_api/jh_base', $level);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|