提交代码

dev-discount
胡锐 2 years ago
parent f7167bf25d
commit 4a81bfeab2
  1. 116
      hai-service/src/main/java/com/hai/config/ShellGroupService.java

@ -1,42 +1,131 @@
package com.hai.config; package com.hai.config;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.MD5Util; import com.hai.common.utils.MD5Util;
import org.apache.commons.lang3.StringUtils; import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays; import java.math.BigDecimal;
import java.util.HashMap; import java.util.*;
import java.util.Map;
import java.util.Set;
/** /**
* 壳牌接口服务 * 壳牌接口服务
*/ */
public class ShellGroupService { public class ShellGroupService {
private static Logger log = LoggerFactory.getLogger(ShellGroupService.class);
/** /**
* 查询全量加油站 * 查询全量加油站
* @param pageNum 当前页码 * @param pageNum 当前页码
* @param pageSize 每页数据量最大值50 * @param pageSize 每页数据量最大值50
* @return * @return
*/ */
public static JSONObject gasPageQueryAllStation(Integer pageNum,Integer pageSize) { public static JSONObject gasPageQueryAllStation(Integer pageNum,Integer pageSize) throws Exception {
Map<String, Object> param = new HashMap<>();
param.put("platMerchantId", CommonSysConst.getSysConfig().getShellPlatMerchantId());
param.put("pageNo", pageNum);
param.put("pageSize", pageSize);
return request("gasPageQueryAllStation", param);
}
/**
* 查询单个油站全量信息
* @param stationCode 油站编码
* @return
*/
public static JSONObject gasStationQueryDetail(String stationCode) {
try {
Map<String, Object> param = new HashMap<>();
param.put("platMerchantId", CommonSysConst.getSysConfig().getShellPlatMerchantId());
param.put("stationCode", stationCode);
return request("gasPageQueryAllStation", param);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 同步油站付款
* @param stationCode 油站编码
* @return
*/
public static JSONObject gasSyncPayment(String stationCode,
Date finishTime,
BigDecimal amount,
String code,
String oilGun,
BigDecimal channelSettlementAmount) {
try {
Map<String, Object> param = new HashMap<>();
param.put("platMerchantId", CommonSysConst.getSysConfig().getShellPlatMerchantId());
param.put("stationCode", stationCode);
param.put("orderType", "OIL");
param.put("finishTime", DateUtil.date2String(finishTime, "yyyy-MM-dd HH:mm:ss"));
Map<String, Object> tradeOilOrder = new HashMap<>();
tradeOilOrder.put("amount", amount);
tradeOilOrder.put("code", code);
tradeOilOrder.put("oilGun", oilGun);
tradeOilOrder.put("channelSettlementAmount", channelSettlementAmount);
param.put("tradeOilOrder", tradeOilOrder);
return request("gas_sync_payment_notify", param);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 同步油站退款
* @param finishTime 业务完成时间
* @param tradeNo 交易流水号
* @return
*/
public static JSONObject gasSyncRefund(Date finishTime,String tradeNo) {
try { try {
Map<String, Object> param = new HashMap<>();
param.put("platMerchantId", CommonSysConst.getSysConfig().getShellPlatMerchantId());
param.put("finishTime", DateUtil.date2String(finishTime, "yyyy-MM-dd HH:mm:ss"));
param.put("tradeNo", tradeNo);
param.put("sign", MD5Util.encode(generateSignature(param, CommonSysConst.getSysConfig().getShellPlatMerchantKey()).getBytes()));
// 请求接口
return request("gas_sync_refund_notify", param);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 接口请求
* @param map
* @return
* @throws Exception
*/
private static JSONObject request(String service,Map<String,Object> map) throws Exception {
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
param.put("merchantOrderNo", System.currentTimeMillis()); param.put("merchantOrderNo", System.currentTimeMillis());
param.put("partnerId", CommonSysConst.getSysConfig().getShellGroupPartnerId()); param.put("partnerId", CommonSysConst.getSysConfig().getShellGroupPartnerId());
param.put("service", "gasPageQueryAllStation"); param.put("service", service);
param.put("version", "1.0.0"); param.put("version", "1.0.0");
param.put("signType", "MD5"); param.put("signType", "MD5");
param.put("platMerchantId", CommonSysConst.getSysConfig().getShellPlatMerchantId());
param.put("pageNo", pageNum); for (Map.Entry<String, Object> entry : map.entrySet()) {
param.put("pageSize", pageSize); param.put(entry.getKey(), entry.getValue());
}
param.put("sign", MD5Util.encode(generateSignature(param, CommonSysConst.getSysConfig().getShellPlatMerchantKey()).getBytes())); param.put("sign", MD5Util.encode(generateSignature(param, CommonSysConst.getSysConfig().getShellPlatMerchantKey()).getBytes()));
// 请求接口 // 请求接口
@ -45,12 +134,7 @@ public class ShellGroupService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, object == null?"请求失败":object.getString("message")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, object == null?"请求失败":object.getString("message"));
} }
return object; return object;
} catch (Exception e) {
e.printStackTrace();
} }
return null;
}
/** /**
* 生成签名 * 生成签名

Loading…
Cancel
Save