master
elf 2 years ago
parent 5e54a94e47
commit 670dd8f057

@ -1,15 +1,7 @@
<?php <?php
namespace Base\Service; namespace Base\Service;
use Base\Tool\GameResource\MhxlClient; use Base\Tool\GameResource\ZzylClient;
use Base\Tool\GameResource\SbcqClient;
use Base\Tool\GameResource\SlzqClient;
use Base\Tool\GameResource\XlqyClient;
use Base\Tool\GameResource\XyyXmjsClient;
use Base\Tool\GameResource\YjzxClient;
use Base\Tool\GameResource\ZxjClient;
use Exception;
use GuzzleHttp\Client;
use Think\Model; use Think\Model;
class GameRebateService class GameRebateService
@ -55,7 +47,7 @@ class GameRebateService
'K' => 'openSevenDay', 'K' => 'openSevenDay',
]; ];
public $rebateBaseGameIds = [70, 73, 75, 79, 81, 84, 91]; public $rebateBaseGameIds = [11];
public function isGiftItemSend($order, $item) public function isGiftItemSend($order, $item)
{ {
@ -120,29 +112,8 @@ class GameRebateService
{ {
$client = null; $client = null;
switch ($baseGameId) { switch ($baseGameId) {
case 70: case 11:
$client = new XyyXmjsClient(); $client = new ZzylClient();
break;
case 73:
$client = new SbcqClient();
break;
case 75:
$client = new XlqyClient();
break;
case 79:
$client = new ZxjClient();
break;
case 81:
$client = new SlzqClient();
break;
case 9:
$client = new XlqyClient();
break;
case 84:
$client = new YjzxClient();
break;
case 91:
$client = new MhxlClient();
break; break;
default: default:
throw new \Exception('客户端未实现'); throw new \Exception('客户端未实现');

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

@ -0,0 +1,19 @@
<?php
namespace Base\Tool\GameResource;
use Base\Tool\PlatformLog;
use Think\Log;
class ZzylClient extends JhBaseClient
{
protected $baseUri = 'http://club.game.hnkongm.com';
protected $key = '2176603bebdd82c0137514ee94f601d2';
protected $brAppId = '4aa797a685e69e2497257e128e250b2c';
protected $brPCode = 'brchengfeng';
protected function log($message, $level = Log::INFO) {
PlatformLog::write($message, 'game_api/zzyl', $level);
}
}
Loading…
Cancel
Save