|
@@ -49,73 +49,6 @@ class Bridge implements IBridge
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function order_sending($refill_info)
|
|
|
- {
|
|
|
- $userID = config::USER_ID;
|
|
|
- $params['OrderNo'] = $refill_info['mch_order'];
|
|
|
- $params['Status'] = 0;
|
|
|
-
|
|
|
- $header = [
|
|
|
- 'Content-Type: application/json',
|
|
|
- "OrderNo: {$refill_info['mch_order']}",
|
|
|
- "UserID: {$userID}",
|
|
|
- ];
|
|
|
- $params = json_encode($params);
|
|
|
- $resp = http_post_data(config::ORDER_SEND_URL, $params, $header, $net_errno);
|
|
|
- if (empty($resp)) {
|
|
|
- return [false, '系统错误'];
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Log::record($resp, Log::DEBUG);
|
|
|
- $resp = $this->aes_decrypt($resp);
|
|
|
- if (empty($resp)) {
|
|
|
- return [false, '解密失败'];
|
|
|
- } elseif ($resp['code'] === '200' && $resp['data'] === true) {
|
|
|
- return [true, $resp['message']];
|
|
|
- } else {
|
|
|
- return [false, $resp['message']];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public function order_complete($refill_info)
|
|
|
- {
|
|
|
- $userID = config::USER_ID;
|
|
|
- $params['OrderNo'] = $refill_info['mch_order'];
|
|
|
- $params['Status'] = config::ORDER_STATUS[$refill_info['order_state']];
|
|
|
- if(empty($params['Status']))
|
|
|
- {
|
|
|
- return [false, '订单状态错误'];
|
|
|
- }
|
|
|
- if($params['Status'] === 1) {
|
|
|
- $params['OperatorSerialNumber'] = $refill_info['official_sn'];
|
|
|
- }
|
|
|
-
|
|
|
- $header = [
|
|
|
- 'Content-Type: application/json',
|
|
|
- "OrderNo: {$refill_info['mch_order']}",
|
|
|
- "UserID: {$userID}",
|
|
|
- ];
|
|
|
- $params = json_encode($params);
|
|
|
- $resp = http_post_data(config::ORDER_SEND_URL, $params, $header, $net_errno);
|
|
|
- if (empty($resp)) {
|
|
|
- return [false, '系统错误'];
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Log::record($resp, Log::DEBUG);
|
|
|
- $resp = $this->aes_decrypt($resp);
|
|
|
- if (empty($resp)) {
|
|
|
- return [false, '解密失败'];
|
|
|
- } elseif ($resp['code'] === '200' && $resp['data'] === true) {
|
|
|
- return [true, $resp['message']];
|
|
|
- } else {
|
|
|
- return [false, $resp['message']];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public function notify($params)
|
|
|
{
|
|
|
$proxy = new refill_proxy(config::MCH_KEY);
|
|
@@ -123,29 +56,22 @@ class Bridge implements IBridge
|
|
|
$mchid = config::MCHID;
|
|
|
|
|
|
if ($verify) {
|
|
|
- $mch_ordersn = $params['order_sn'];
|
|
|
+ $mch_ordersn = $data['order_sn'];
|
|
|
+ $body = $this->notify_body($data);
|
|
|
|
|
|
$userID = config::USER_ID;
|
|
|
- $params['OrderNo'] = $mch_ordersn;
|
|
|
-
|
|
|
- $success = $data['state'] == 'SUCCESS';
|
|
|
- $params['Status'] = $success ? 1 : 2;
|
|
|
- if(empty($params['Status']))
|
|
|
- {
|
|
|
- Log::record("内部订单状态错误 mchid = {$mchid}", Log::ERR);
|
|
|
- return false;
|
|
|
- }
|
|
|
- if($params['Status'] === 1) {
|
|
|
- $params['OperatorSerialNumber'] = $data['official_sn'];
|
|
|
- }
|
|
|
-
|
|
|
$header = [
|
|
|
'Content-Type: application/json',
|
|
|
"OrderNo: {$mch_ordersn}",
|
|
|
"UserID: {$userID}",
|
|
|
];
|
|
|
- $params = json_encode($params);
|
|
|
- $resp = http_post_data(config::ORDER_SEND_URL, $params, $header, $net_errno);
|
|
|
+
|
|
|
+ $body = json_encode($body, JSON_UNESCAPED_UNICODE);
|
|
|
+ $body = $this->aes_encrypt($body);
|
|
|
+ $reqData['PostData'] = $body;
|
|
|
+ $reqData = json_encode($reqData, JSON_UNESCAPED_UNICODE);
|
|
|
+
|
|
|
+ $resp = http_post_data(config::ORDER_COMPLETE_URL, $reqData, $header, $net_errno);
|
|
|
if (empty($resp)) {
|
|
|
Log::record("回调下游,请求超时 mchid = {$mchid} mch_order = {$mch_ordersn}", Log::ERR);
|
|
|
return false;
|
|
@@ -153,9 +79,9 @@ class Bridge implements IBridge
|
|
|
else
|
|
|
{
|
|
|
Log::record($resp, Log::DEBUG);
|
|
|
- $resp = $this->aes_decrypt($resp);
|
|
|
+ $resp = json_decode($resp, true);
|
|
|
if (empty($resp)) {
|
|
|
- Log::record("回调下游,返回数据加密失败 mchid = {$mchid} mch_order = {$mch_ordersn}", Log::ERR);
|
|
|
+ Log::record("回调下游,返回数据格式有误 mchid = {$mchid} mch_order = {$mch_ordersn}", Log::ERR);
|
|
|
return false;
|
|
|
} elseif ($resp['code'] === '200' && $resp['data'] === true) {
|
|
|
return true;
|
|
@@ -171,6 +97,27 @@ class Bridge implements IBridge
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private function notify_body($params)
|
|
|
+ {
|
|
|
+ $success = $params['state'] == 'SUCCESS';
|
|
|
+ $body = [
|
|
|
+ "OrderNo" => $params['order_sn'],
|
|
|
+ "Status" => $success ? 1 : 2,
|
|
|
+ "Description" => '充值失败',
|
|
|
+ "RealCost" => "",
|
|
|
+ "SubstituteAccount" => "",
|
|
|
+ "ChannelAccountId" => "",
|
|
|
+ "InventoryId" => "",
|
|
|
+ "OperatorSerialNumber" => ""
|
|
|
+ ];
|
|
|
+
|
|
|
+ if($body['Status'] === 1) {
|
|
|
+ $body['OperatorSerialNumber'] = $params['official_sn'];
|
|
|
+ }
|
|
|
+
|
|
|
+ return $body;
|
|
|
+ }
|
|
|
+
|
|
|
private function aes_encrypt($data) {
|
|
|
$str_padded = $data;
|
|
|
if (strlen($str_padded) % 16) {
|