req_params($card_no, $amount, $input['order_sn']); $params['reqData'] = json_encode($data); $params['sign'] = config::sign($params); $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); $code = $resp['code']; if (empty($resp)) { return [false, '系统错误', true]; } elseif ($code === 1) { return [true, $resp['data']['businessOrderId'], false]; } else { return [false, $resp['msg'], false]; } } } public function query($refill_info) { $params = config::pub_params(); $data['orderId'] = $refill_info['order_sn']; $data['agentId'] = config::AGENT_ID; $data['transactionPin'] = config::transactionPin; $params['reqData'] = json_encode($data); $params['sign'] = config::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'] === 1) { $status = $resp['data']['orderStatus']; if ($status === 3) { $updata['official_sn'] = $resp['data']['ispVoucherId']; Model('refill_order')->edit($refill_info['order_id'], $updata); $order_state = ORDER_STATE_SUCCESS; } elseif ($status === 99) { $order_state = ORDER_STATE_CANCEL; } elseif ($status === 1 || $status === 2) { $order_state = ORDER_STATE_SEND; } else { return [false, $status]; } return [true, $order_state]; } else { return [false, $resp['msg']]; } } } public function balance() { $params = config::pub_params(); $data['agentId'] = config::AGENT_ID; $data['transactionPin'] = config::transactionPin; $params['reqData'] = json_encode($data); $params['sign'] = config::sign($params); $params = json_encode($params); $resp = http_post_data(config::BALANCE_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'] === 1) { return [true, $resp['data']['currentBalance']]; } else { return [false, $resp['msg']]; } } } }