public class MeidaUrlUtil {
private static Logger logger = Logger.getLogger(MeidaUrlUtil.class);
private static String recEncoding = "UTF-8";
//商家确认订单
public static String mdOrderConfirm(Map params) throws Exception{
String url = Commons.MEIDA_URL+"/order/confirm";
params=commonOrderArgs(params);
return HttpRequestProxy.doPost(url,params,getRecEncoding());
}
//商家取消订单(非美团配送)
public static String mdOrderCancel(Map params) throws Exception{
String url = Commons.MEIDA_URL+"/order/cancel";
params=commonOrderArgs(params);
return HttpRequestProxy.doPost(url,params,getRecEncoding());
}
//商家配送订单(非美团配送)
public static String mdOrderDelivering(Map params) throws Exception{
String url = Commons.MEIDA_URL+"/order/delivering";
params=commonOrderArgs(params);
return HttpRequestProxy.doPost(url,params,getRecEncoding());
}
//商家取消订单(美团配送)
public static String mdLogisticsOrderCancel(Map params) throws Exception{
String url = Commons.MEIDA_URL+"order/cancelDispatch";
params=commonOrderArgs(params);
return HttpRequestProxy.doPost(url,params,getRecEncoding());
}
//商家配送订单(美团配送)
public static String mdLogisticsOrderDelivering(Map params) throws Exception{
String url = Commons.MEIDA_URL+"/order/dispatchShip";
params=commonOrderArgs(params);
return HttpRequestProxy.doPost(url,params,getRecEncoding());
}
//订单已送达
public static String mdOrderArrived(Map params) throws Exception{
String url = Commons.MEIDA_URL+"/order/delivered";
params=commonOrderArgs(params);
return HttpRequestProxy.doPost(url,params,getRecEncoding());
}
//订单同意退款请求
public static String mdOrderRefundAgree(Map params) throws Exception{
String url = Commons.MEIDA_URL+"/order/agreeRefund";
params=commonOrderArgs(params);
return HttpRequestProxy.doPost(url,params,getRecEncoding());
}
//订单驳回退款请求
public static String mdOrderRefundReject(Map params) throws Exception{
String url = Commons.MEIDA_URL+"/order/rejectRefund";
params=commonOrderArgs(params);
return HttpRequestProxy.doPost(url,params,getRecEncoding());
}
//查询订单id查询订单
public static String mdOrderByIdFromMd(Map params) throws Exception{
String url = Commons.MEIDA_URL+"/order/queryById";
params=commonOrderArgs(params);
return HttpRequestProxy.doGet(url,params,getRecEncoding());
}
//查询订单流水号查询订单
public static String mdOrderByDaySeqFromMd(Map params) throws Exception{
String url = Commons.MEIDA_URL+"/order/queryByDaySeq";
params=commonOrderArgs(params);
return HttpRequestProxy.doGet(url,params,getRecEncoding());
}
//心跳上报
public static String mdHeartJump(Map params) throws Exception{
String url = "http://heartbeat.meituan.com/pos/heartbeat";
params=commonOrderArgs(params);
return HttpRequestProxy.doPost(url,params,getRecEncoding());
}
public static String getRecEncoding() {
return recEncoding;
}
public static void setRecEncoding(String recEncoding) {
MeidaUrlUtil.recEncoding = recEncoding;
}
private static Map commonOrderArgs(Map params){
Long currentTimeMillis = MeidaUrlUtil.getCurrentTimeMillis()/1000;
params.put("charset","utf-8");
params.put("timestamp", currentTimeMillis.intValue());
String signature = orderEncrypt(params);
params.put("sign", signature);
return params;
}
private static String orderEncrypt(Map map){
String signature = "";
try {
String result="";
String meituanSort = meiTuanSort(map);
String signkey=Commons.MEIDA_SIGNKEY;
result=signkey+meituanSort;
signature = Sha1Util.getSha1(result);
} catch (Exception e) {
logger.error("获取美大token异常", e);
}
return signature;
}
public static long getCurrentTimeMillis(){
return System.currentTimeMillis();
}
private static String meiTuanSort(Map mapv){
//将appid,timestamp,还有参数这三个进行字母排序
Map map = mapv;
Collection keySet = map.keySet();
List list = new ArrayList(keySet);
Collections.sort(list);
String result = "";
for(int i = 0;i
result+=list.get(i)+map.get(list.get(i));
}
return result;
}
}