|
@@ -71,6 +71,9 @@ class RefillPhone extends refill\IRefillPhone
|
|
|
$order_sn = $params['order_sn'];
|
|
|
$goods_id = intval($params['goods_id']);
|
|
|
$product_code = $this->getProductCode($goods_id,$params['product_code']);
|
|
|
+
|
|
|
+ Model('thrid_refill')->refill_third_edit($params['order_id'], ['chcode' => $product_code]);
|
|
|
+
|
|
|
$quantity = intval($params['quantity']);
|
|
|
|
|
|
$params = $this->req_params($order_sn,$product_code,$quantity);
|
|
@@ -105,6 +108,9 @@ class RefillPhone extends refill\IRefillPhone
|
|
|
$order_sn = $params['order_sn'];
|
|
|
$goods_id = intval($params['goods_id']);
|
|
|
$product_code = $this->getProductCode($goods_id,$params['product_code']);
|
|
|
+
|
|
|
+ Model('thrid_refill')->refill_third_edit($params['order_id'], ['chcode' => $product_code]);
|
|
|
+
|
|
|
$quantity = intval($params['quantity']);
|
|
|
|
|
|
$params = $this->req_params($order_sn,$product_code,$quantity);
|
|
@@ -146,14 +152,14 @@ class RefillPhone extends refill\IRefillPhone
|
|
|
$resp = http_request(config::QUERY_URL, $params);
|
|
|
|
|
|
if (empty($resp)) {
|
|
|
- return [false, '网络错误', []];
|
|
|
+ return [false, '网络错误'];
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Log::record($resp, Log::DEBUG);
|
|
|
$resp = json_decode($resp, true);
|
|
|
if (empty($resp)) {
|
|
|
- return [false, '网络错误', []];
|
|
|
+ return [false, '网络错误'];
|
|
|
}
|
|
|
elseif ($resp['Code'] == 999)
|
|
|
{
|
|
@@ -161,12 +167,15 @@ class RefillPhone extends refill\IRefillPhone
|
|
|
$result = [];
|
|
|
if ($status === 2) {
|
|
|
if(!empty($resp['Data']['CardData'])) {
|
|
|
- $cards = $this->rsa_decode($resp['Data']['CardData']);
|
|
|
- $cards = json_decode($cards, true);
|
|
|
- foreach ($cards as $card) {
|
|
|
- $result[] = $card;
|
|
|
+ $result = $this->rsa_decode($resp['Data']['CardData']);
|
|
|
+ if (empty($result)) {
|
|
|
+ $data['ret_state'] = 2;
|
|
|
+ $data['card_info'] = '查询接口,解密失败';
|
|
|
+ } else {
|
|
|
+ $data['ret_state'] = 1;
|
|
|
+ $data['card_info'] = $result;
|
|
|
}
|
|
|
- //需返回卡密信息
|
|
|
+ Model('refill_order')->refill_third_edit($refill_info['order_id'], $data);
|
|
|
}
|
|
|
$order_state = ORDER_STATE_SUCCESS;
|
|
|
} elseif ($status === 3) {
|
|
@@ -176,21 +185,26 @@ class RefillPhone extends refill\IRefillPhone
|
|
|
} else {
|
|
|
return [false, $resp['Message'], $result];
|
|
|
}
|
|
|
- return [true, $order_state, $result];
|
|
|
+ return [true, $order_state];
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- return [false, $resp['Message'], []];
|
|
|
+ return [false, $resp['Message']];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private function rsa_decode($encrypted)
|
|
|
{
|
|
|
- $private_key = config::PRIVATE_KEY;
|
|
|
- //使用私钥解密数据
|
|
|
- openssl_private_decrypt(base64_decode($encrypted), $decrypted,$private_key);
|
|
|
- return $decrypted;
|
|
|
+ $ret = openssl_private_decrypt(base64_decode($encrypted), $decrypted, config::PRIVATE_KEY);
|
|
|
+ if ($ret) {
|
|
|
+ $result = json_decode($decrypted, true);
|
|
|
+ return $result;
|
|
|
+ } else {
|
|
|
+ $err = openssl_error_string();
|
|
|
+ Log::record("sctongqian callback openssl_private_decrypt error={$err}", Log::ERR);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private function sign($params)
|