sign($params); $params['signature'] = $sign; $resp = http_request(config::QUERY_URL,$params); if (empty($resp)) { return [false,'系统错误']; } else { Log::record($resp,Log::DEBUG); $resp = json_decode($resp,true); if (empty($resp)) { return [false, '返回值错误']; } $code = intval($resp['code']); $status = intval($resp['data']['status']); if ($code != 1) { return [false, $resp['info']]; } elseif ($status == 2) { $order_state = ORDER_STATE_SUCCESS; $data['official_sn'] = strtolower($params['vnum']) == 'null' ? '' : $params['vnum']; Model('refill_order')->edit($refill_info['order_id'], $data); } elseif ($status == 3) { $order_state = ORDER_STATE_CANCEL; } else { $order_state = ORDER_STATE_SEND; } return [true, $order_state]; } } public function balance() { $params['appid'] = config::APPID; $sign = $this->sign($params); $params['signature'] = $sign; $resp = http_request(config::BALANCE_URL,$params); if($resp === false) { 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']['account']]; } else { return [false, $resp['info']]; } } } private function sign($input) { $key = config::APPKEY; $body = config::body($input); $body .= "&token={$key}"; return strtolower(md5($body)); } }