Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@liangtengyu
Last active April 26, 2020 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liangtengyu/249b3c3142de2e907aaa8f86ac98b47a to your computer and use it in GitHub Desktop.
Save liangtengyu/249b3c3142de2e907aaa8f86ac98b47a to your computer and use it in GitHub Desktop.
@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