首页 手机话费充值 手机话费充值示例代码 查询话费订单详情[Java]

查询话费订单详情示例代码[Java]

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

查询话费订单详情

package api.jisuapi.mobilerecharge;
/**
 * 查询话费订单详情
 */
import api.util.HttpUtil;
import net.sf.json.JSONObject;

public class Orderdetail {

	public static final String APPKEY = "your_appkey_here";// 你的appkey
	public static final String URL = "https://api.jisuapi.com/mobilerecharge/orderdetail";
	public static final String orderno = "221601241155888";// 订单号
	public static final String outorderno = "77888855888";// 商家订单号,和订单号任选其一

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

		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 orderno = resultarr.getString("orderno");
				String outorderno = resultarr.getString("outorderno");
				String account = resultarr.getString("account");
				String num = resultarr.getString("num");
				String status = resultarr.getString("status");
				String rechargestatus = resultarr.getString("rechargestatus");
				String amount = resultarr.getString("amount");
				String totalfee = resultarr.getString("totalfee");
				String addtime = resultarr.getString("addtime");
				String name = resultarr.getString("name");
				String areaid = resultarr.getString("areaid");
				String company = resultarr.getString("company");
				System.out.println(orderno + " " + outorderno + " " + account + " " + num + " " + status + " "
						+ rechargestatus + " " + amount + " " + totalfee + " " + addtime + " " + name + " " + areaid
						+ " " + company);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}