req_params($card_no, $amount, $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'] == 0) { return [true, '', false]; } else { return [false, $resp['message'], false]; } } } public function query($refill_info) { $params['masId'] = config::masId; $params['appKey'] = config::appKey; $params['time'] = time(); $params['orderNo'] = $refill_info['order_sn']; $content = "appKey={$params['appKey']}&masId={$params['masId']}&orderNo={$params['orderNo']}&time={$params['time']}"; $params['sign'] = strtoupper(md5($content)); $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'] == 0) { $data = $resp['data']; if ($data['status'] == 1) { $order_state = ORDER_STATE_SUCCESS; $save['official_sn'] = strtolower($data['oids']) == 'null' ? '' : $data['oids']; Model('refill_order')->edit($refill_info['order_id'], $save); } elseif (in_array($data['status'], [0,2])) { $order_state = ORDER_STATE_SEND; } else { return [false, $resp['message']]; } return [true, $order_state]; } else { return [false, $resp['message']]; } } } private function sign($params) { $content = "appKey={$params['appKey']}&masId={$params['masId']}¬ifyUrl={$params['notifyUrl']}&time={$params['time']}"; return strtoupper(md5($content)); } }