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.
78 lines
2.7 KiB
78 lines
2.7 KiB
package com.hai.config;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.hai.common.exception.ErrorCode;
|
|
import com.hai.common.exception.ErrorHelp;
|
|
import com.hai.common.exception.SysCode;
|
|
import com.hai.common.pay.util.sdk.WXPayConstants;
|
|
import com.hai.common.utils.HttpsUtils;
|
|
import com.hai.common.utils.MD5Util;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
/**
|
|
* 壳牌接口服务
|
|
*/
|
|
public class ShellGroupService {
|
|
|
|
/**
|
|
* 查询全量加油站
|
|
* @param pageNum 当前页码
|
|
* @param pageSize 每页数据量。最大值50
|
|
* @return
|
|
*/
|
|
public static JSONObject gasPageQueryAllStation(Integer pageNum,Integer pageSize) {
|
|
try {
|
|
Map<String, Object> param = new HashMap<>();
|
|
param.put("merchantOrderNo", System.currentTimeMillis());
|
|
param.put("partnerId", CommonSysConst.getSysConfig().getShellGroupPartnerId());
|
|
param.put("service", "gasPageQueryAllStation");
|
|
param.put("version", "1.0.0");
|
|
param.put("signType", "MD5");
|
|
param.put("platMerchantId", CommonSysConst.getSysConfig().getShellPlatMerchantId());
|
|
param.put("pageNo", pageNum);
|
|
param.put("pageSize", pageSize);
|
|
param.put("sign", MD5Util.encode(generateSignature(param, CommonSysConst.getSysConfig().getShellPlatMerchantKey()).getBytes()));
|
|
|
|
// 请求接口
|
|
JSONObject object = HttpsUtils.doPost(CommonSysConst.getSysConfig().getShellGroupUrl(), param);
|
|
if (object == null || !object.getString("status").equals("SUCCESS")) {
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, object == null?"请求失败":object.getString("message"));
|
|
}
|
|
return object;
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
|
|
/**
|
|
* 生成签名
|
|
* @param data 数据
|
|
* @param key 秘钥app_secret
|
|
* @return 加密结果
|
|
*/
|
|
public static String generateSignature(final Map<String, Object> data, String key){
|
|
Set<String> keySet = data.keySet();
|
|
String[] keyArray = keySet.toArray(new String[keySet.size()]);
|
|
Arrays.sort(keyArray);
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(key);
|
|
for (String k : keyArray) {
|
|
if (k.equals(WXPayConstants.FIELD_SIGN)) {
|
|
continue;
|
|
}
|
|
if (data.get(k) != null) // 参数值为空,则不参与签名
|
|
sb.append(k).append(data.get(k));
|
|
}
|
|
sb.append(key);
|
|
return sb.toString();
|
|
}
|
|
|
|
}
|
|
|