首页 加油卡充值 加油卡充值示例代码 查询加油卡订单列表[Java]

查询加油卡订单列表示例代码[Java]

作者:xiezhongpian 阅读数:1495 上传时间:2017-05-09

查询加油卡订单列表

package api.jisuapi.fuelcardrecharge;

import api.util.HttpUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class Orderlist {

	public static final String APPKEY = "your_appkey_here";// 你的appkey
	public static final String URL = "https://api.jisuapi.com/fuelcardrecharge/orderlist";
	public static final int pagenum = 1;// 当前页
	public static final int pagesize = 20;// 每页数量,最大20

	public static void Get() {
		String result = null;
		String url = URL + "?appkey=" + APPKEY + "&pagenum=" + pagenum + "&pagesize=" + pagesize;

		try {
			result = HttpUtil.sendGet(url, "utf-8");
			JSONObject json = JSONObject.fromObject(result);
			if (json.getInt("status") != 0) {
				System.out.println(json.getString("msg"));
			} else {
				JSONObject resultarr = (JSONObject) json.opt("result");
				String total = resultarr.getString("total");
				String pagenum = resultarr.getString("pagenum");
				String pagesize = resultarr.getString("pagesize");
				System.out.println(total + " " + pagenum + " " + pagesize);
				JSONArray list = resultarr.optJSONArray("list");
				for (int i = 0; i < list.size(); i++) {
					JSONObject obj = (JSONObject) list.opt(i);
					String type = obj.getString("type");
					String orderno = obj.getString("orderno");
					String outorderno = obj.getString("outorderno");
					String account = obj.getString("account");
					String num = obj.getString("num");
					String status = obj.getString("status");
					String rechargestatus = obj.getString("rechargestatus");
					String amount = obj.getString("amount");
					String totalfee = obj.getString("totalfee");
					String addtime = obj.getString("addtime");
					System.out.println(type + " " + orderno + " " + outorderno + " " + account + " " + num + " "
							+ status + " " + rechargestatus + " " + amount + " " + totalfee + " " + addtime);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}