new-dev
parent
38dd67f618
commit
95f98b2a21
File diff suppressed because one or more lines are too long
@ -0,0 +1,149 @@ |
||||
package com.hai.config; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hai.common.utils.HttpsUtils; |
||||
import com.hai.common.utils.MD5Util; |
||||
import org.apache.commons.codec.binary.Base64; |
||||
|
||||
import javax.crypto.Cipher; |
||||
import javax.crypto.KeyGenerator; |
||||
import javax.crypto.spec.SecretKeySpec; |
||||
import java.nio.charset.StandardCharsets; |
||||
import java.security.SecureRandom; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
|
||||
public class DianConfig { |
||||
|
||||
private static final String ALGORITHMS = "AES/ECB/PKCS5Padding"; |
||||
/** |
||||
* 静态常量 |
||||
*/ |
||||
private static final String AES = "AES"; |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name getGasInfoAll |
||||
* @Description // 获取(全量)油站信息
|
||||
* @Date 14:47 2023/10/11 |
||||
* @return com.alibaba.fastjson.JSONObject |
||||
*/ |
||||
public static JSONObject getGasInfoAll() { |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("jyzid" , "ALL"); |
||||
JSONObject paramMap = new JSONObject(); |
||||
paramMap.put("appid", CommonSysConst.getSysConfig().getDiandianwAppid()); |
||||
paramMap.put("postInfo", aesEncrypt(jsonObject.toJSONString() , CommonSysConst.getSysConfig().getDiandianwAppSecret())); |
||||
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"/otherUnit/Interface_getJyzInfoAll.html" , paramMap); |
||||
} |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name getGasInfoByGasId |
||||
* @Description // 根据油站 id 拉取最新的油站数据
|
||||
* @Date 16:40 2023/10/11 |
||||
* @Param gasId |
||||
* @return com.alibaba.fastjson.JSONObject |
||||
*/ |
||||
public static JSONObject getGasInfoByGasId(String gasId) { |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("jyzid" , gasId); |
||||
JSONObject paramMap = new JSONObject(); |
||||
paramMap.put("appid", CommonSysConst.getSysConfig().getDiandianwAppid()); |
||||
paramMap.put("postInfo", aesEncrypt(jsonObject.toJSONString() , CommonSysConst.getSysConfig().getDiandianwAppSecret())); |
||||
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"otherUnit/Interface_getJyzInfoById.html" , paramMap); |
||||
} |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name refuelingOrderPush |
||||
* @Description // 推送订单
|
||||
* @Date 15:29 2023/10/12 |
||||
* @Param object |
||||
* @return com.alibaba.fastjson.JSONObject |
||||
*/ |
||||
public static JSONObject refuelingOrderPush(JSONObject object) { |
||||
JSONObject paramMap = new JSONObject(); |
||||
paramMap.put("appid", CommonSysConst.getSysConfig().getDiandianwAppid()); |
||||
paramMap.put("postInfo", aesEncrypt(object.toJSONString() , CommonSysConst.getSysConfig().getDiandianwAppSecret())); |
||||
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"otherUnit/Interface_nl_orderPush.html" , paramMap); |
||||
} |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name queryCompanyPriceDetail |
||||
* @Description //
|
||||
* @Date 16:28 2023/10/12 |
||||
* @Param gasId |
||||
* @Param oilNo |
||||
* @return com.alibaba.fastjson.JSONObject |
||||
*/ |
||||
public static JSONObject queryCompanyPriceDetail(String gasId , String oilNo) { |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("jyzid" , gasId); |
||||
jsonObject.put("youhao" , oilNo); |
||||
JSONObject paramMap = new JSONObject(); |
||||
paramMap.put("appid", CommonSysConst.getSysConfig().getDiandianwAppid()); |
||||
paramMap.put("postInfo", aesEncrypt(jsonObject.toJSONString() , CommonSysConst.getSysConfig().getDiandianwAppSecret())); |
||||
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"otherUnit/Interface_getPriceInfoById.html" , paramMap); |
||||
} |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @ClassName DianConfig |
||||
* @Description // 5.根据订单 ID 查询订单结果
|
||||
* @Date 2023/10/16 15:25 |
||||
**/ |
||||
public static JSONObject getOrderDetail( String orderNo) { |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("orderid" , orderNo); |
||||
JSONObject paramMap = new JSONObject(); |
||||
paramMap.put("appid", CommonSysConst.getSysConfig().getDiandianwAppid()); |
||||
paramMap.put("postInfo", aesEncrypt(jsonObject.toJSONString() , CommonSysConst.getSysConfig().getDiandianwAppSecret())); |
||||
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"otherUnit/Interface_getOrderResultById.html" , paramMap); |
||||
} |
||||
|
||||
|
||||
public static JSONObject orderRefund( String orderNo) { |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("orderid" , orderNo); |
||||
JSONObject paramMap = new JSONObject(); |
||||
paramMap.put("appid", CommonSysConst.getSysConfig().getDiandianwAppid()); |
||||
paramMap.put("postInfo", aesEncrypt(jsonObject.toJSONString() , CommonSysConst.getSysConfig().getDiandianwAppSecret())); |
||||
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getDiandianwPostUrl()+"otherUnit/Interface_nl_orderRefund.html" , paramMap); |
||||
} |
||||
|
||||
|
||||
|
||||
/** |
||||
* 将字符串【AES加密】为base 64 code |
||||
* |
||||
* @param content 待加密的内容 |
||||
* @return 加密后的base 64 code |
||||
*/ |
||||
public static String aesEncrypt(String content, String key) { |
||||
try { |
||||
// 创建密码器
|
||||
// 密钥 AES加解密要求key必须要128个比特位(这里需要长度为16,否则会报错)
|
||||
KeyGenerator kgen = KeyGenerator.getInstance("AES"); |
||||
kgen.init(128); |
||||
// 初始化为加密模式的密码器
|
||||
Cipher cipher = Cipher.getInstance(ALGORITHMS); |
||||
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key.getBytes(), DianConfig.AES)); |
||||
|
||||
byte[] bytes = cipher.doFinal(content.getBytes(StandardCharsets.UTF_8)); |
||||
System.out.println(); |
||||
// 使用base64解码
|
||||
return Base64.encodeBase64String(bytes); |
||||
} catch (Exception e) { |
||||
System.err.println(e.getMessage() + e); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
|
||||
} |
||||
|
Loading…
Reference in new issue