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