From b5eb7f50a54ebd86076eb7cdb4b047de7c5a428e Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Mon, 19 Jul 2021 00:19:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bweb/controller/TelApiController.java | 18 +++++++++ .../java/com/hai/common/utils/MD5Util.java | 20 +++++++++- .../java/com/hai/config/CommonSysConfig.java | 37 +++++++++++++++++++ .../main/java/com/hai/config/TelConfig.java | 35 ++++++++++++++++++ .../java/com/hai/service/TelApiService.java | 1 + .../hai/service/impl/TelApiServiceImpl.java | 9 +++++ .../resources/dev/commonConfig.properties | 5 +++ .../resources/prod/commonConfig.properties | 4 ++ 8 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 hai-service/src/main/java/com/hai/config/TelConfig.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/TelApiController.java b/hai-bweb/src/main/java/com/bweb/controller/TelApiController.java index 749dd395..7172b4c8 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/TelApiController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/TelApiController.java @@ -8,8 +8,12 @@ import com.hai.common.exception.SysCode; import com.hai.common.pay.util.IOUtil; import com.hai.common.pay.util.XmlUtil; import com.hai.common.utils.*; +import com.hai.config.CommonSysConst; +import com.hai.config.QianZhuConfig; +import com.hai.config.TelConfig; import com.hai.entity.HighDiscount; import com.hai.entity.HighTelOrder; +import com.hai.entity.HighUser; import com.hai.model.ResponseData; import com.hai.service.TelApiService; import io.swagger.annotations.Api; @@ -164,4 +168,18 @@ public class TelApiController { } + @RequestMapping(value = "/getMemberGoods", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取渠道商获取关联商品") + public ResponseData getMemberGoods() { + try { + + JSONObject data = TelConfig.getMemberGoods(); + + return ResponseMsgUtil.success(data); + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-service/src/main/java/com/hai/common/utils/MD5Util.java b/hai-service/src/main/java/com/hai/common/utils/MD5Util.java index 1ca9e865..2dcb5969 100644 --- a/hai-service/src/main/java/com/hai/common/utils/MD5Util.java +++ b/hai-service/src/main/java/com/hai/common/utils/MD5Util.java @@ -42,7 +42,25 @@ public class MD5Util { String newstr=base64en.encodeToString(md5.digest(str.getBytes("utf-8"))); return newstr; }*/ - + + public static String encodeS(byte[] data) throws Exception { + // 初始化MessageDigest + MessageDigest md = MessageDigest.getInstance("MD5"); + // 执行摘要信息 + byte[] digest = md.digest(data); + // 将摘要信息转换为32位的十六进制字符串 + return new HexBinaryAdapter().marshal(digest); + } + /* public static String EncoderByMd5(String str) throws NoSuchAlgorithmException, UnsupportedEncodingException{ + //确定计算方法 + MessageDigest md5=MessageDigest.getInstance("MD5"); + Encoder base64en = Base64.getEncoder(); + //加密后的字符串 + String newstr=base64en.encodeToString(md5.digest(str.getBytes("utf-8"))); + return newstr; + }*/ + + public static void main(String[] args) throws Exception { String str = "123456"; System.out.println(MD5Util.encode(str.getBytes("UTF-8"))); diff --git a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java index d72a8eae..f0ce001c 100644 --- a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java +++ b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java @@ -21,6 +21,11 @@ public class CommonSysConfig { private String wx_cert; + private String telApiKey; + private String telApiSecret; + private String telMemberId; + private String telUrl; + public String getTuanYouUrl() { return tuanYouUrl; } @@ -92,4 +97,36 @@ public class CommonSysConfig { public void setWx_cert(String wx_cert) { this.wx_cert = wx_cert; } + + public String getTelApiKey() { + return telApiKey; + } + + public void setTelApiKey(String telApiKey) { + this.telApiKey = telApiKey; + } + + public String getTelApiSecret() { + return telApiSecret; + } + + public void setTelApiSecret(String telApiSecret) { + this.telApiSecret = telApiSecret; + } + + public String getTelMemberId() { + return telMemberId; + } + + public void setTelMemberId(String telMemberId) { + this.telMemberId = telMemberId; + } + + public String getTelUrl() { + return telUrl; + } + + public void setTelUrl(String telUrl) { + this.telUrl = telUrl; + } } diff --git a/hai-service/src/main/java/com/hai/config/TelConfig.java b/hai-service/src/main/java/com/hai/config/TelConfig.java new file mode 100644 index 00000000..be61905d --- /dev/null +++ b/hai-service/src/main/java/com/hai/config/TelConfig.java @@ -0,0 +1,35 @@ +package com.hai.config; + +import com.alibaba.fastjson.JSONObject; +import com.hai.common.utils.HttpsUtils; +import com.hai.common.utils.MD5Util; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * @ClassName TelConfig + * @Author Sum1Dream + * @Version 1.0.0 + * @Description // 话费接口配置 + * @Date 2021/7/18 14:18 + **/ +public class TelConfig { + + + public static JSONObject getMemberGoods() throws Exception { + Map map = new HashMap<>(); + + Long time = new Date().getTime(); + + String sign = CommonSysConst.getSysConfig().getTelApiSecret() + "_" + time; + + map.put("apiKey", CommonSysConst.getSysConfig().getTelApiKey()); + map.put("memberId", CommonSysConst.getSysConfig().getTelMemberId()); + map.put("time", time); + map.put("sign", MD5Util.encode(sign.getBytes()).toLowerCase()); + return HttpsUtils.doGet(CommonSysConst.getSysConfig().getTelUrl()+ "/getMemberGoods", map); + } + +} diff --git a/hai-service/src/main/java/com/hai/service/TelApiService.java b/hai-service/src/main/java/com/hai/service/TelApiService.java index 0e832596..5194680f 100644 --- a/hai-service/src/main/java/com/hai/service/TelApiService.java +++ b/hai-service/src/main/java/com/hai/service/TelApiService.java @@ -71,5 +71,6 @@ public interface TelApiService { **/ JSONObject outApiTel(String tel); + JSONObject getMemberGoods(); } diff --git a/hai-service/src/main/java/com/hai/service/impl/TelApiServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/TelApiServiceImpl.java index 74b87c80..4df5bb3f 100644 --- a/hai-service/src/main/java/com/hai/service/impl/TelApiServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/TelApiServiceImpl.java @@ -87,4 +87,13 @@ public class TelApiServiceImpl implements TelApiService { querys.put("shouji", tel); return HttpsUtils.doGet("https://jshmgsdmfb.market.alicloudapi.com/shouji/query", querys , headers); } + + @Override + public JSONObject getMemberGoods() { + + Map map = new HashMap<>(); + + + return null; + } } diff --git a/hai-service/src/main/resources/dev/commonConfig.properties b/hai-service/src/main/resources/dev/commonConfig.properties index 593a621f..acc3c40f 100644 --- a/hai-service/src/main/resources/dev/commonConfig.properties +++ b/hai-service/src/main/resources/dev/commonConfig.properties @@ -9,3 +9,8 @@ qinzhuPlatformId=10376 qinzhuSecret=ktxb49sh2jfhgn8g wx_cert=/home/project/wx_cert/ + +telApiKey=2d01f6b520254b1a80f6b167832cea18 +telApiSecret=d11ee9b41e014a039f030e53ae6f5295 +telMemberId=d13091df65d64aafbf0f35d2093157b7 +telUrl=http://cz.jjcxy.com:80/api/2d01f6b520254b1a80f6b167832cea18 diff --git a/hai-service/src/main/resources/prod/commonConfig.properties b/hai-service/src/main/resources/prod/commonConfig.properties index 9829c269..9369b963 100644 --- a/hai-service/src/main/resources/prod/commonConfig.properties +++ b/hai-service/src/main/resources/prod/commonConfig.properties @@ -9,3 +9,7 @@ qinzhuPlatformId=10376 qinzhuSecret=ktxb49sh2jfhgn8g wx_cert=/home/project/wx_cert/ + +TelApiKey=2d01f6b520254b1a80f6b167832cea18 +TelApiSecret=d11ee9b41e014a039f030e53ae6f5295 +TelMemberId=d13091df65d64aafbf0f35d2093157b7