|
|
|
@ -20,17 +20,32 @@ import java.util.*; |
|
|
|
|
* @createTime 18:33 2023/11/13 |
|
|
|
|
**/ |
|
|
|
|
@Component |
|
|
|
|
public class ScPetroConfig { |
|
|
|
|
public class PetroConfig { |
|
|
|
|
|
|
|
|
|
private static final String reqUrl = CommonSysConst.getSysConfig().getScPetroUrl(); |
|
|
|
|
private static final String ScPetroAppKey = CommonSysConst.getSysConfig().getScPetroAppKey(); |
|
|
|
|
private static final String ScPetroAppid = CommonSysConst.getSysConfig().getScPetroAppid(); |
|
|
|
|
private static final String ScPetroAesKey = CommonSysConst.getSysConfig().getScPetroAesKey(); |
|
|
|
|
private static String reqUrl; |
|
|
|
|
private static String petroAppKey; |
|
|
|
|
private static String petroAppid; |
|
|
|
|
private static String petroAesKey; |
|
|
|
|
|
|
|
|
|
private static final String version = "1.0"; |
|
|
|
|
|
|
|
|
|
private final static String charset = "UTF-8"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void init(Integer type) { |
|
|
|
|
if (type == 1) { |
|
|
|
|
reqUrl = CommonSysConst.getSysConfig().getScPetroUrl(); |
|
|
|
|
petroAppKey = CommonSysConst.getSysConfig().getScPetroAppKey(); |
|
|
|
|
petroAppid = CommonSysConst.getSysConfig().getScPetroAppid(); |
|
|
|
|
petroAesKey = CommonSysConst.getSysConfig().getScPetroAesKey(); |
|
|
|
|
} else { |
|
|
|
|
reqUrl = CommonSysConst.getSysConfig().getGzPetroUrl(); |
|
|
|
|
petroAppKey = CommonSysConst.getSysConfig().getGzPetroAppKey(); |
|
|
|
|
petroAppid = CommonSysConst.getSysConfig().getGzPetroAppid(); |
|
|
|
|
petroAesKey = CommonSysConst.getSysConfig().getGzPetroAesKey(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Author Sum1Dream |
|
|
|
|
* @Name synCouponRule |
|
|
|
@ -42,7 +57,7 @@ public class ScPetroConfig { |
|
|
|
|
public static JSONObject synCouponRule() throws Exception{ |
|
|
|
|
Map<String, Object> req = new HashMap<>(); |
|
|
|
|
req.put("version", version); |
|
|
|
|
req.put("appid", ScPetroAppid); |
|
|
|
|
req.put("appid", petroAppid); |
|
|
|
|
req.put("signtype", "MD5"); |
|
|
|
|
req.put("timestamp", DateUtil.date2String(new Date(), DateUtil.Y_M_D_HMS)); |
|
|
|
|
|
|
|
|
@ -52,12 +67,12 @@ public class ScPetroConfig { |
|
|
|
|
|
|
|
|
|
//业务内容加密
|
|
|
|
|
String bizContent = JSONObject.toJSONString(billBizContent); |
|
|
|
|
bizContent = encrypt(bizContent, ScPetroAesKey); |
|
|
|
|
bizContent = encrypt(bizContent, petroAesKey); |
|
|
|
|
|
|
|
|
|
//加密的内容放到参数中
|
|
|
|
|
req.put("biz_content", bizContent); |
|
|
|
|
//生成签名
|
|
|
|
|
String sign = createSign(req, ScPetroAppKey); |
|
|
|
|
String sign = createSign(req, petroAppKey); |
|
|
|
|
//签名放到参数中
|
|
|
|
|
req.put("sign", sign); |
|
|
|
|
// 请求接口
|
|
|
|
@ -76,9 +91,10 @@ public class ScPetroConfig { |
|
|
|
|
* @return com.alibaba.fastjson.JSONObject |
|
|
|
|
*/ |
|
|
|
|
public static JSONObject getCoupon(String code , String phone , String orderNo) throws Exception{ |
|
|
|
|
|
|
|
|
|
Map<String, Object> req = new HashMap<>(); |
|
|
|
|
req.put("version", version); |
|
|
|
|
req.put("appid", ScPetroAppid); |
|
|
|
|
req.put("appid", petroAppid); |
|
|
|
|
req.put("signtype", "MD5"); |
|
|
|
|
req.put("timestamp", DateUtil.date2String(new Date(), DateUtil.Y_M_D_HMS)); |
|
|
|
|
|
|
|
|
@ -90,12 +106,12 @@ public class ScPetroConfig { |
|
|
|
|
|
|
|
|
|
//业务内容加密
|
|
|
|
|
String bizContent = JSONObject.toJSONString(billBizContent); |
|
|
|
|
bizContent = encrypt(bizContent, ScPetroAesKey); |
|
|
|
|
bizContent = encrypt(bizContent, petroAesKey); |
|
|
|
|
|
|
|
|
|
//加密的内容放到参数中
|
|
|
|
|
req.put("biz_content", bizContent); |
|
|
|
|
//生成签名
|
|
|
|
|
String sign = createSign(req, ScPetroAppKey); |
|
|
|
|
String sign = createSign(req, petroAppKey); |
|
|
|
|
//签名放到参数中
|
|
|
|
|
req.put("sign", sign); |
|
|
|
|
// 请求接口
|
|
|
|
@ -113,7 +129,7 @@ public class ScPetroConfig { |
|
|
|
|
public static JSONObject couponDetail(String ticketNum) throws Exception{ |
|
|
|
|
Map<String, Object> req = new HashMap<>(); |
|
|
|
|
req.put("version", version); |
|
|
|
|
req.put("appid", ScPetroAppid); |
|
|
|
|
req.put("appid", petroAppid); |
|
|
|
|
req.put("signtype", "MD5"); |
|
|
|
|
req.put("timestamp", DateUtil.date2String(new Date(), DateUtil.Y_M_D_HMS)); |
|
|
|
|
|
|
|
|
@ -124,12 +140,12 @@ public class ScPetroConfig { |
|
|
|
|
|
|
|
|
|
//业务内容加密
|
|
|
|
|
String bizContent = JSONObject.toJSONString(billBizContent); |
|
|
|
|
bizContent = encrypt(bizContent, ScPetroAesKey); |
|
|
|
|
bizContent = encrypt(bizContent, petroAesKey); |
|
|
|
|
|
|
|
|
|
//加密的内容放到参数中
|
|
|
|
|
req.put("biz_content", bizContent); |
|
|
|
|
//生成签名
|
|
|
|
|
String sign = createSign(req, ScPetroAppKey); |
|
|
|
|
String sign = createSign(req, petroAppKey); |
|
|
|
|
//签名放到参数中
|
|
|
|
|
req.put("sign", sign); |
|
|
|
|
// 请求接口
|
|
|
|
@ -147,7 +163,7 @@ public class ScPetroConfig { |
|
|
|
|
public static JSONObject cancelCoupon(String ticketNum) throws Exception{ |
|
|
|
|
Map<String, Object> req = new HashMap<>(); |
|
|
|
|
req.put("version", version); |
|
|
|
|
req.put("appid", ScPetroAppid); |
|
|
|
|
req.put("appid", petroAppid); |
|
|
|
|
req.put("signtype", "MD5"); |
|
|
|
|
req.put("timestamp", DateUtil.date2String(new Date(), DateUtil.Y_M_D_HMS)); |
|
|
|
|
|
|
|
|
@ -158,12 +174,12 @@ public class ScPetroConfig { |
|
|
|
|
|
|
|
|
|
//业务内容加密
|
|
|
|
|
String bizContent = JSONObject.toJSONString(billBizContent); |
|
|
|
|
bizContent = encrypt(bizContent, ScPetroAesKey); |
|
|
|
|
bizContent = encrypt(bizContent, petroAesKey); |
|
|
|
|
|
|
|
|
|
//加密的内容放到参数中
|
|
|
|
|
req.put("biz_content", bizContent); |
|
|
|
|
//生成签名
|
|
|
|
|
String sign = createSign(req, ScPetroAppKey); |
|
|
|
|
String sign = createSign(req, petroAppKey); |
|
|
|
|
//签名放到参数中
|
|
|
|
|
req.put("sign", sign); |
|
|
|
|
// 请求接口
|
|
|
|
@ -245,7 +261,7 @@ public class ScPetroConfig { |
|
|
|
|
*/ |
|
|
|
|
public static String decrypt(final String content) { |
|
|
|
|
try { |
|
|
|
|
byte[] raw = ScPetroAesKey.getBytes("UTF-8"); |
|
|
|
|
byte[] raw = petroAesKey.getBytes("UTF-8"); |
|
|
|
|
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); |
|
|
|
|
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); |
|
|
|
|
cipher.init(2, skeySpec); |