req_params($card_no, $amount, $params['order_sn']); $sign = $this->sign($params); $params['chargeSign'] = $sign; $params = json_encode($params); $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders); if ($resp === false) { return [false, '系统错误', true]; } else { Log::record($resp, Log::DEBUG); $resp = json_decode($resp, true); if ($resp['code'] == 0000) { return [true, '', false]; } else { return [false, $resp['desc'], false]; } } } public function query($refill_info) { $params['orderid'] = $refill_info['order_sn']; $params['userid'] = config::USER_ID; $params['timestamp'] = date("YmdHis"); $content = $params['userid'] . $params['orderid'] . $params['timestamp'] . config::KEY; $params['sign'] = md5($content); $params = json_encode($params); $resp = http_post_data(config::QUERY_URL, $params , config::ExtHeaders); if ($resp === false) { return [false, '系统错误']; } else { Log::record($resp, Log::DEBUG); $resp = json_decode($resp, true); $order_state = -1; if ($resp['code'] == 0000) { $order_state = ORDER_STATE_SUCCESS; } elseif ($resp['code'] == 0004) { $order_state = ORDER_STATE_CANCEL; } elseif ($resp['code'] == 0002 || $resp['code'] == 0003) { $order_state = ORDER_STATE_SEND; } if ($order_state == -1) { return [false, $resp['desc']]; } return [true, $order_state]; } } private function sign($params) { $content = $params['userid'] . $params['orderid'] . config::KEY . $params['echo'] . $params['timestamp']; return md5($content); } }