|
|
package com.charge.Test;
|
|
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.charge.util.SignUtils;
|
|
|
|
|
|
public class TestJingYueShangMaoChengZhaJi {
|
|
|
public static void main(String[] args) {
|
|
|
//净月商贸城
|
|
|
String url = "http://118.31.14.83:8501/vehicle/api/dowCoupon";
|
|
|
String appid = "1";//应用编号
|
|
|
String parkNo = "1";//站点编号
|
|
|
String appSecret = "ak1622a92d";//密钥
|
|
|
String charge_plate_no = "吉A888888";
|
|
|
int freeTime = 120;
|
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
jo.put("parkNo", parkNo);
|
|
|
jo.put("plate", charge_plate_no);//车牌号
|
|
|
jo.put("plate_color", 5);//车牌颜色,绿色
|
|
|
jo.put("coupon_type", 1);//1固定时长券
|
|
|
jo.put("couponName", "充电减免");
|
|
|
jo.put("coupon_value", freeTime);//卷面值 分钟 | 分
|
|
|
jo.put("appid", appid);//应用编号
|
|
|
jo.put("ts", System.currentTimeMillis() / 1000);//时间戳,10位时间戳,与别人不一样噢
|
|
|
jo.put("sign", SignUtils.paramsAnKuaiSign(jo, appSecret));//签名
|
|
|
// 发送 POST 请求并获取响应
|
|
|
String result = HttpUtil.createPost(url)
|
|
|
.body(jo.toString()) // 将 JSON 对象转换为字符串作为请求正文
|
|
|
.header("version", "1.0.0")
|
|
|
.header("Content-Type", "application/json") // 设置请求头,指明内容类型为 JSON
|
|
|
.execute().body(); // 发送请求并获取响应体
|
|
|
System.out.println(result);
|
|
|
}
|
|
|
}
|