|
@@ -144,6 +144,8 @@ class RefillOil extends refill\IRefillOil
|
|
|
public function query($refill_info)
|
|
|
{
|
|
|
$order_sn = $refill_info['order_sn'];
|
|
|
+ $order_id = $refill_info['order_id'];
|
|
|
+
|
|
|
$params = $this->query_params($order_sn);
|
|
|
$sign = $this->sign($params);
|
|
|
$params['signature'] = $sign;
|
|
@@ -155,35 +157,63 @@ class RefillOil extends refill\IRefillOil
|
|
|
if($resp === false) {
|
|
|
return [false,'网络错误'];
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ Log::record($resp,Log::DEBUG);
|
|
|
+ $resp = json_decode($resp,true);
|
|
|
+
|
|
|
+ if($resp == false) {
|
|
|
+ return [false,'网络错误'];
|
|
|
+ }
|
|
|
+ elseif($resp['code'] == 0)
|
|
|
{
|
|
|
- Log::record($resp,Log::DEBUG);
|
|
|
- $resp = json_decode($resp,true);
|
|
|
+ $data = $resp['data'];
|
|
|
+ $status = intval($data['orderStatus']);
|
|
|
+
|
|
|
+ if ($status === 101) {
|
|
|
+ $updata['official_sn'] = $data['voucher'];
|
|
|
+ $updata['ch_trade_no'] = $data['orderNumber'];
|
|
|
+ $updata['err_msg'] = $resp['message'];
|
|
|
+ Model('refill_order')->edit($order_id, $updata);
|
|
|
|
|
|
- if($resp == false) {
|
|
|
- return [false,'网络错误'];
|
|
|
+ return [true, ORDER_STATE_SUCCESS];
|
|
|
}
|
|
|
- elseif($resp['code'] == 0)
|
|
|
- {
|
|
|
- $data = $resp['data'];
|
|
|
- $status = intval($data['orderStatus']);
|
|
|
+ elseif ($status === 102) {
|
|
|
+ $updata['official_sn'] = $data['voucher'];
|
|
|
+ $updata['ch_trade_no'] = $data['orderNumber'];
|
|
|
+ $updata['err_msg'] = $resp['message'];
|
|
|
|
|
|
- if ($status === 101) {
|
|
|
- return [true, ORDER_STATE_SUCCESS];
|
|
|
- }
|
|
|
- elseif ($status === 102) {
|
|
|
- return [true, ORDER_STATE_CANCEL];
|
|
|
- }
|
|
|
- elseif($status === 100 || $status === 106) {
|
|
|
- return [true, ORDER_STATE_SEND];
|
|
|
- }
|
|
|
- else {
|
|
|
- return [false, $resp['message']];
|
|
|
- }
|
|
|
+ Model('refill_order')->edit($order_id, $updata);
|
|
|
+ $this->onError($resp['message'],$order_id);
|
|
|
+
|
|
|
+ return [true, ORDER_STATE_CANCEL];
|
|
|
+ }
|
|
|
+ elseif($status === 100 || $status === 106) {
|
|
|
+ return [true, ORDER_STATE_SEND];
|
|
|
}
|
|
|
else {
|
|
|
- return [false,$resp['message']];
|
|
|
+ return [false, $resp['message']];
|
|
|
}
|
|
|
}
|
|
|
+ else {
|
|
|
+ return [false,$resp['message']];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function onError($msg,$order_id)
|
|
|
+ {
|
|
|
+ if(in_array($msg,config::BlackMsgs))
|
|
|
+ {
|
|
|
+ $refill = Model('refill_order');
|
|
|
+ $order = $refill->getOrderInfo(['order_id' => $order_id]);
|
|
|
+ if(empty($order)) return false;
|
|
|
+
|
|
|
+ $card_no = $order['card_no'];
|
|
|
+ if(!empty($card_no)) {
|
|
|
+ refill\util::set_black($card_no);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|