master
ELF 3 years ago
parent 4e537c34a8
commit 75e49fcc49

@ -61,8 +61,11 @@ class GameRebateService
}
$sendResult .= ($result['message'] ?? '') . ';';
}
$index = 1;
$giftItems = json_decode($gift['gifts'], true);
foreach ($giftItems as $giftItem) {
$giftItem['index'] = $index;
$index ++;
if (!$this->isGiftItemSend($order, $giftItem)) {
continue;
}

@ -23,13 +23,14 @@ class XlqyClient
protected $client;
private $apis = [
'send-email' => ['uri' => '', 'method' => 'post'],
'send-email' => ['uri' => '/emRebate', 'method' => 'post'],
'send-testing' => ['uri' => '/testingOrder', 'method' => 'post'],
];
public function __construct()
{
$this->client = new Client([
'base_uri' => 'http://xx2api.hnputihd.com/apip/payWM450S00/emRebate',
'base_uri' => 'http://xx2api.hnputihd.com/apip/payWM450S00',
'timeout' => 10.0,
]);
}
@ -94,6 +95,17 @@ class XlqyClient
$params['time'] .
self::SIGN_KEY
);
} elseif ($name == 'send-testing') {
return md5(
$params['appId'] .
$params['orderNum'] .
$params['userId'] .
$params['MoneyYuan'] .
$params['serviceId'] .
$params['roleId'] .
$params['time'] .
self::SIGN_KEY
);
} else {
return '';
}
@ -107,7 +119,7 @@ class XlqyClient
'serviceId' => $order['server_id'],
'roleId' => $order['role_id'],
'mailId' => $giftItem['id'],
'orderNum' => $this->generateOrderNumber($order),
'orderNum' => $this->generateOrderNumber($order, $giftItem['index']),
'time' => time(),
];
@ -115,10 +127,11 @@ class XlqyClient
return $this->getCommonResult($result);
}
private function generateOrderNumber($order)
private function generateOrderNumber($order, $index = 0)
{
$length = 8 - strlen(strval($order['id']));
return date('Ymd') . str_repeat('0', $length) . $order['id'];
$indexLength = 3 - strlen(strval($index));
return date('Ymd') . str_repeat('0', $length) . $order['id'] . str_repeat('0', $indexLength) . $index;
}
private function getCommonResult($result)
@ -138,12 +151,32 @@ class XlqyClient
}
}
/**
* @todo 暂时没有测试资源
*/
public function apply($order, $role)
{
return $this->sendEmail($order['ref_amount'], $role);
$data = [
'appId' => self::APP_ID,
'userId' => $role['user_id'],
'serviceId' => $role['server_id'],
'roleId' => $role['role_id'],
'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]
];
}
}
public function getResourceTypes($deviceType)

Loading…
Cancel
Save