|
|
|
@ -20,10 +20,12 @@ class XlqyClient
|
|
|
|
|
// const APP_ID = '77A38AE4C5CAD6756'; // IOS
|
|
|
|
|
// const SIGN_KEY = 'rKkoznJcEhWaVPSuBnH1QnC9goDd4TcB'; // IOS
|
|
|
|
|
|
|
|
|
|
protected $logTag = 'rebate:XLQY ';
|
|
|
|
|
|
|
|
|
|
protected $client;
|
|
|
|
|
protected $currentName;
|
|
|
|
|
|
|
|
|
|
private $apis = [
|
|
|
|
|
protected $apis = [
|
|
|
|
|
'send-email' => ['uri' => '/apip/payWM450S00/emRebate', 'method' => 'post'],
|
|
|
|
|
'send-testing' => ['uri' => '/apip/payWM450S00/testingOrder', 'method' => 'post'],
|
|
|
|
|
'send-props' => ['uri' => '/apip/payWM450S00/buyProp', 'method' => 'post'],
|
|
|
|
@ -44,7 +46,7 @@ class XlqyClient
|
|
|
|
|
if (is_null($api)) {
|
|
|
|
|
throw new \Exception('接口不存在');
|
|
|
|
|
}
|
|
|
|
|
$params[self::SIGN_NAME] = $this->sign($name, $params);
|
|
|
|
|
$params[static::SIGN_NAME] = $this->sign($name, $params);
|
|
|
|
|
|
|
|
|
|
// 发放道具接口特殊处理
|
|
|
|
|
if ($name == 'send-props') {
|
|
|
|
@ -54,7 +56,7 @@ class XlqyClient
|
|
|
|
|
return $this->request($api, $params);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
$env = C('APP_ENV', null, 'prod');
|
|
|
|
|
Log::error('rebate:XLQY ' . $e->getMessage());
|
|
|
|
|
Log::error($this->logTag . $e->getMessage());
|
|
|
|
|
return ['code' => 3, 'msg' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -75,7 +77,7 @@ class XlqyClient
|
|
|
|
|
'form_params' => $params,
|
|
|
|
|
]);
|
|
|
|
|
$result = (string)$response->getBody();
|
|
|
|
|
Log::info('rebate:XLQY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
|
|
|
|
|
Log::info($this->logTag . $uri . ' -- '. json_encode($params) . ' -- '. $result);
|
|
|
|
|
if ($this->currentName == 'send-testing') {
|
|
|
|
|
return $this->prepareResult($result);
|
|
|
|
|
}
|
|
|
|
@ -89,7 +91,7 @@ class XlqyClient
|
|
|
|
|
'query' => $params,
|
|
|
|
|
]);
|
|
|
|
|
$result = (string)$response->getBody();
|
|
|
|
|
Log::info('rebate:XLQY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
|
|
|
|
|
Log::info($this->logTag . $uri . ' -- '. json_encode($params) . ' -- '. $result);
|
|
|
|
|
if ($this->currentName == 'send-testing') {
|
|
|
|
|
return $this->prepareResult($result);
|
|
|
|
|
}
|
|
|
|
@ -122,7 +124,7 @@ class XlqyClient
|
|
|
|
|
$params['serviceId'] .
|
|
|
|
|
$params['roleId'] .
|
|
|
|
|
$params['time'] .
|
|
|
|
|
self::SIGN_KEY
|
|
|
|
|
static::SIGN_KEY
|
|
|
|
|
);
|
|
|
|
|
} elseif ($name == 'send-testing') {
|
|
|
|
|
return md5(
|
|
|
|
@ -133,7 +135,7 @@ class XlqyClient
|
|
|
|
|
$params['serviceId'] .
|
|
|
|
|
$params['roleId'] .
|
|
|
|
|
$params['time'] .
|
|
|
|
|
self::SIGN_KEY
|
|
|
|
|
static::SIGN_KEY
|
|
|
|
|
);
|
|
|
|
|
} elseif ($name == 'send-props') {
|
|
|
|
|
$signStr = '';
|
|
|
|
@ -144,7 +146,7 @@ class XlqyClient
|
|
|
|
|
}
|
|
|
|
|
$signStr .= $key . '='. trim(urlencode($value)) . '&';
|
|
|
|
|
}
|
|
|
|
|
$signStr .= 'key=' . self::SIGN_KEY;
|
|
|
|
|
$signStr .= 'key=' . static::SIGN_KEY;
|
|
|
|
|
$signStr = md5($signStr);
|
|
|
|
|
return $signStr;
|
|
|
|
|
} else {
|
|
|
|
@ -155,7 +157,7 @@ class XlqyClient
|
|
|
|
|
public function sendEmail($giftItem, $order)
|
|
|
|
|
{
|
|
|
|
|
$data = [
|
|
|
|
|
'appId' => self::APP_ID,
|
|
|
|
|
'appId' => static::APP_ID,
|
|
|
|
|
'userId' => $order['user_id'],
|
|
|
|
|
'serviceId' => $order['server_id'],
|
|
|
|
|
'roleId' => $order['role_id'],
|
|
|
|
@ -186,7 +188,7 @@ class XlqyClient
|
|
|
|
|
'time' => date('Y-m-d H:i:s'),
|
|
|
|
|
'role_id' => $order['role_id'],
|
|
|
|
|
'orderNum' => $this->generateOrderNumber($order),
|
|
|
|
|
'appId' => self::APP_ID,
|
|
|
|
|
'appId' => static::APP_ID,
|
|
|
|
|
'totalprice' => $order['amount'],
|
|
|
|
|
'prop' => $props
|
|
|
|
|
];
|
|
|
|
@ -221,7 +223,7 @@ class XlqyClient
|
|
|
|
|
public function apply($order, $role)
|
|
|
|
|
{
|
|
|
|
|
$data = [
|
|
|
|
|
'appId' => self::APP_ID,
|
|
|
|
|
'appId' => static::APP_ID,
|
|
|
|
|
'userId' => $role['user_id'],
|
|
|
|
|
'serviceId' => $role['server_id'],
|
|
|
|
|
'roleId' => $role['role_id'],
|
|
|
|
|