You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.6 KiB

11 months ago
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);//应用编号
11 months ago
jo.put("ts", System.currentTimeMillis() / 1000);//时间戳,10位时间戳与别人不一样噢
11 months ago
jo.put("sign", SignUtils.paramsAnKuaiSign(jo, appSecret));//签名
11 months ago
// 发送 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);
}
}