req_params($card_no, $amount, $card_type, $params['order_sn']); $sign = $this->sign($params); $params['sign'] = $sign; $params = json_encode($params); $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders , $net_errno); if (empty($resp)) { return [false, '系统错误', true]; } else { Log::record($resp, Log::DEBUG); $resp = json_decode($resp, true); if (empty($resp)) { return [false, '系统错误', true]; } elseif ($resp['code'] === 200) { return [true, $resp['data']['orderId'], false]; } else { return [false, $resp['msg'], false]; } } } public function query($refill_info) { $params['supplierId'] = config::USER_ID; $params['orderNo'] = $refill_info['order_sn']; $params['phoneNo'] = $refill_info['card_no']; $params['company'] = config::operator[$refill_info['card_type']]; $params['sign'] = $this->sign($params); $params = json_encode($params); $resp = http_post_data(config::QUERY_URL, $params , config::ExtHeaders); if (empty($resp)) { return [false, '系统错误']; } else { Log::record($resp, Log::DEBUG); $resp = json_decode($resp, true); if (empty($resp)) { return [false, '系统错误']; } elseif ($resp['code'] == 200) { $status = intval($resp['data']['status']); if ($status === 2) { $updata['official_sn'] = $resp['data']['ticketNo']; Model('refill_order')->edit($refill_info['order_id'], $updata); $order_state = ORDER_STATE_SUCCESS; } elseif ($status === 3) { $order_state = ORDER_STATE_CANCEL; } elseif (in_array($status, [0,1])) { $order_state = ORDER_STATE_SEND; } else { return [false, $resp['msg']]; } return [true, $order_state]; } else { return [false, $resp['msg']]; } } } private function sign($data) { $str = ""; ksort($data); foreach($data as $k => $v){ if($this->check_empty($v) === false){ $str .= $v; } } return md5($str.config::KEY); } }