@ -1,21 +1,20 @@
package com.hai.config ;
import com.alibaba.fastjson.JSON ;
import com.alibaba.fastjson.JSONArray ;
import com.alibaba.fastjson.JSONObject ;
import com.hai.common.pay.util.sdk.WXPayConstants ;
import com.hai.common.utils.HttpsUtils ;
import com.hai.common.utils.MD5Util ;
import com.hai.common.utils.WxUtils ;
import com.hai.dao.HighGasOrderPushMapper ;
import com.hai.entity.HighGasOrderPush ;
import org.apache.commons.collections4.MapUtils ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.context.annotation.Configuration ;
import sun.misc.BASE64Decoder ;
import sun.misc.BASE64Encoder ;
import javax.annotation.Resource ;
import javax.crypto.Cipher ;
import javax.crypto.spec.SecretKeySpec ;
import java.io.UnsupportedEncodingException ;
import java.net.URLDecoder ;
import java.net.URLEncoder ;
import java.security.MessageDigest ;
import java.util.* ;
@ -28,7 +27,6 @@ import java.util.*;
* @date 2021 / 7 / 5 14 : 18
* /
public class HuiLianTongConfig {
/ * *
* 获取token
* @return
@ -36,62 +34,67 @@ public class HuiLianTongConfig {
* /
public static JSONObject getToken ( ) throws Exception {
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( "appNo" , "guizhouhltcs" ) ;
map . put ( "appKey" , MD5Util . encode ( "g%2BNnjR54YSUWM2iKg%2Fd82A9x9hg2kYV7" . getBytes ( ) ) ) ;
return HttpsUtils . doPost ( "https://gzapitest.deepermobile.com.cn:441 /api/api/auth/getAccessToken", JSON . toJSONString ( map ) ) ;
map . put ( "appNo" , CommonSysConst . getSysConfig ( ) . getHuiliantongAppNo ( ) ) ;
map . put ( "appKey" , MD5Util . encode ( CommonSysConst . getSysConfig ( ) . getHuiliantongAppkey ( ) . getBytes ( ) ) ) ;
return HttpsUtils . doPost ( CommonSysConst . getSysConfig ( ) . getHuiliantongUrl ( ) + " /api/api/auth/getAccessToken", JSON . toJSONString ( map ) ) ;
}
public static JSONObject getCorpCouTypes ( ) throws Exception {
/ * *
* 获取电子券类型列表
* @param token
* @return
* @throws Exception
* /
public static JSONObject getCorpCouTypes ( String token ) {
Map < String , Object > param = new HashMap < > ( ) ;
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( "token" , "a::57D9BBA185484EAD82737168B28EDA62" ) ;
map . put ( "jsonData" , get3DESEncryptECB ( JSON . toJSONString ( param ) , "FA28E95ACABFA4B2B8E25857437B07F1" ) ) ;
map . put ( "token" , token ) ;
/ * map . put ( "jsonData" , get3DESEncryptECB ( JSON . toJSONString ( param ) , CommonSysConst . getSysConfig ( ) . getHuiliantongAppsecret ( ) ) ) ;
StringJoiner urlParamStr = new StringJoiner ( "&" ) ;
urlParamStr . add ( String . format ( "jsonData=%s" , param ) ) ;
urlParamStr . add ( String . format ( "secretKey=%s" , "FA28E95ACABFA4B2B8E25857437B07F1" ) ) ;
map . put ( "sign" , md5Capital ( urlParamStr . toString ( ) ) ) ;
return HttpsUtils . doPost ( "https://gzapitest.deepermobile.com.cn:441 /coupon/api/coupon_corp/getCorpCouTypes", JSON . toJSONString ( map ) ) ;
urlParamStr . add ( String . format ( "secretKey=%s" , CommonSysConst . getSysConfig ( ) . getHuiliantongAppsecret ( ) ) ) ;
map . put ( "sign" , md5Capital ( urlParamStr . toString ( ) ) ) ; * /
return HttpsUtils . doPost ( CommonSysConst . getSysConfig ( ) . getHuiliantongUrl ( ) + " /coupon/api/coupon_corp/getCorpCouTypes", JSON . toJSONString ( map ) ) ;
}
public static JSONObject couJointDist ( ) throws Exception {
/ * *
* 商户派发电子券
* @param token
* @param couTypeCode 电子卡券类型
* @param distCouCount 分配数量
* @param userPhone 用户手机号
* @param thirdUserId 用户编号
* @return
* @throws Exception
* /
public static JSONObject couJointDist ( String token , String couTypeCode , Integer distCouCount , String userPhone , String thirdUserId ) throws Exception {
// 券列表
List < Map < String , Object > > objectList = new ArrayList < > ( ) ;
Map < String , Object > object = new HashMap < > ( ) ;
object . put ( "couTypeCode" , "20JY000251" ) ;
object . put ( "distCouCount" , 1 ) ;
object . put ( "couTypeCode" , couTypeCode ) ;
object . put ( "distCouCount" , distCouCount ) ;
objectList . add ( object ) ;
// 参数
Map < String , Object > param = new HashMap < > ( ) ;
param . put ( "coupons" , objectList ) ;
param . put ( "phone" , "17726395120" ) ;
param . put ( "thirdUserId" , "oArhO6XxKSvjI9wLP3cTK-iSG8yY" ) ;
param . put ( "phone" , userPhone ) ;
param . put ( "thirdUserId" , thirdUserId ) ;
param . put ( "orderNo" , "HF" + new Date ( ) . getTime ( ) ) ;
param . put ( "distOuCode" , "guizhouhltcs" ) ;
String appKey = "g%2BNnjR54YSUWM2iKg%2Fd82A9x9hg2kYV7" ;
String appSecret = "FA28E95ACABFA4B2B8E25857437B07F1" ;
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( "token" , "a::57D9BBA185484EAD82737168B28EDA62" ) ;
map . put ( "jsonData" , get3DESEncryptECB ( JSON . toJSONString ( param ) , appKey ) ) ;
map . put ( "token" , token ) ;
map . put ( "jsonData" , get3DESEncryptECB ( JSON . toJSONString ( param ) , CommonSysConst . getSysConfig ( ) . getHuiliantongAppkey ( ) ) ) ;
StringJoiner joiner = new StringJoiner ( "&" ) ;
joiner . add ( "jsonData=" + JSON . toJSONString ( param ) ) ;
joiner . add ( "secretKey=" + app Secret) ;
joiner . add ( "secretKey=" + CommonSysConst . get SysConfig ( ) . getHuiliantongApps ecret( ) ) ;
map . put ( "sign" , md5Capital ( joiner . toString ( ) ) ) ;
Map < String , Object > map1 = new HashMap < > ( ) ;
String fromStr = "token=" + MapUtils . getString ( map , "token" ) + "&sign=" + MapUtils . getString ( map , "sign" ) + "&jsonData=" + URLEncoder . encode ( MapUtils . getString ( map , "jsonData" ) , "UTF-8" ) ;
map1 . put ( "from" , "" ) ;
return HttpsUtils . doSmsPost ( "https://gzapitest.deepermobile.com.cn:441/coupon/api/coupon_corp/couJointDist?" + fromStr , map1 , new HashMap < > ( ) ) ;
String paramStr = "token=" + MapUtils . getString ( map , "token" ) + "&sign=" + MapUtils . getString ( map , "sign" ) + "&jsonData=" + URLEncoder . encode ( MapUtils . getString ( map , "jsonData" ) , "UTF-8" ) ;
return HttpsUtils . doHuiLianTongPost ( CommonSysConst . getSysConfig ( ) . getHuiliantongUrl ( ) + "/coupon/api/coupon_corp/couJointDist?" + paramStr ) ;
}
public static void main ( String [ ] args ) throws UnsupportedEncodingException {
String decode = URLDecoder . decode ( "jkE2O4ZKfL6F2IWQyf01oNXbCY%252FM1xZ7OP1%252BJVeXCfpWZgaFjIjZaVTPdJHkxRUlPJikskS6rQs1OMbMiu9ZgKaHftjA%252BJ7f%252BSFzsOPDPpnACegOBBR%252BjN5ZxOH%252FDPe9pOoGA53gBbAIEuqkDlqirxJyNR%252FJHip%252BoAQ2%252FN00pD1pIyvBqGsks%252Bx0w2w7GzYGcacU7iQrVHPhcFdyGFJUhWOaBMhRgNi0lJw9Pjt8xuY5IXwAjgk0EQ%253D%253D" , "UTF-8" ) ;
System . out . println ( decode ) ;
System . out . println ( get3DESDecryptECB ( decode , "FA28E95ACABFA4B2B8E25857437B07F1" ) ) ;
}
public static String get3DESEncryptECB ( String src , String secretKey ) {
try {