Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@Data
public class QueryCarRequestInfo {
public TreeMap getTreeMap(){
return this.treeMap;
}
//有参构造函数
QueryCarRequestInfo(TreeMap data) throws Exception {
this.data=data;
this.appId=Constant.appId;
this.timestamp= System.currentTimeMillis();
TreeMap<String, Object> treeMap = new TreeMap<>();
treeMap.put("appId",this.appId);
treeMap.put("data", this.data);
treeMap.put("timestamp", this.timestamp);
String mapString = JSON.toJSONString(treeMap);
String sign = HMacMD5.encodeMac(mapString, Constant.KEY);
this.signature=sign;
treeMap.put("signature", this.signature);
this.treeMap = treeMap;
}
}
子类
public class RefundInfo extends QueryCarRequestInfo {
public RefundInfo(TreeMap data) throws Exception {
super(data);
}
}
以上是这个类 下面是调用:
@Override
public String refund(String plateNum, final String OrderId, Integer amount) throws Exception {
TreeMap<String, Object> treeMap = new TreeMap<>(); //新建空的 treemap
treeMap.put("refundId", System.currentTimeMillis() + "refund"); //组织参数
treeMap.put("plateNumber", plateNum);//组织参数
treeMap.put("refundAmount", amount);//组织参数
treeMap.put("orderId", OrderId);//组织参数
RefundInfo carOutRequestInfo = new RefundInfo(treeMap);
String post = UrlConnectUtil.post( Constant.baseUrl + "/refund/bill", carOutRequestInfo.getTreeMap());
//对response做处理
if (StringUtils.isNotBlank(post)) {
xxx
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment