From 7701cd7c6f9aa0eeda36fd0123740a455ef8d56c Mon Sep 17 00:00:00 2001 From: Owen <595466820@qq.com> Date: Tue, 31 Dec 2024 11:20:18 +0800 Subject: [PATCH] Feat: Api fix log --- .../module/haoka/api/ApiHaiNanDXService.java | 21 ++++---- .../module/haoka/api/ApiHuNanDXService.java | 33 ++++++------- .../haoka/api/guangdong/inner/GdDxApi.java | 1 + .../api/hainandianxin/HaiNanDianXinApi.java | 26 +++++----- .../haoka/api/hunandianxin/HuNanDXApi.java | 48 ++++++++++--------- .../admin/api/HaokaApiHaiNanDXController.java | 11 +++-- .../admin/api/HaokaHuNanDXController.java | 17 +++---- .../vo/SuperiorApiLogSaveReqVO.java | 31 +++++++++--- .../haoka/service/api/ApiDealServiceImpl.java | 26 +++++++++- .../api/strategy/HaiNanDxApiDealStrategy.java | 5 +- .../api/strategy/HuNanDxApiDealStrategy.java | 4 +- .../api/strategy/LianTongApiDealStrategy.java | 30 ++++++++---- 12 files changed, 159 insertions(+), 94 deletions(-) diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHaiNanDXService.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHaiNanDXService.java index 0557ce93ff..e854deb90b 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHaiNanDXService.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHaiNanDXService.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.haoka.api; import cn.iocoder.yudao.module.haoka.api.hainandianxin.HaiNanDianXinApi; +import cn.iocoder.yudao.module.haoka.controller.admin.superiorapilog.vo.SuperiorApiLogSaveReqVO; import com.mashape.unirest.http.exceptions.UnirestException; import org.springframework.stereotype.Service; @@ -36,28 +37,28 @@ public class ApiHaiNanDXService extends ApiConfigService { } public HaiNanDianXinApi.HaiNanResponseInfo - qryNbrList(HaiNanDianXinApi.QryNbrListRequest param) throws UnirestException { - return HaiNanDianXinApi.qryNbrList(this.getConfig(), param); + qryNbrList(final SuperiorApiLogSaveReqVO logVO,HaiNanDianXinApi.QryNbrListRequest param) throws UnirestException { + return HaiNanDianXinApi.qryNbrList( logVO,this.getConfig(), param); } public HaiNanDianXinApi.HaiNanResponseInfo - fraudCheck(HaiNanDianXinApi.FraudCheckRequest param) throws UnirestException { - return HaiNanDianXinApi.fraudCheck(this.getConfig(), param); + fraudCheck(final SuperiorApiLogSaveReqVO logVO, HaiNanDianXinApi.FraudCheckRequest param) throws UnirestException { + return HaiNanDianXinApi.fraudCheck( logVO,this.getConfig(), param); } public HaiNanDianXinApi.HaiNanResponseInfo - queryOrderInfo(HaiNanDianXinApi.QueryOrderInfoRequest param) throws UnirestException { - return HaiNanDianXinApi.queryOrderInfo(this.getConfig(), param); + queryOrderInfo(final SuperiorApiLogSaveReqVO logVO,HaiNanDianXinApi.QueryOrderInfoRequest param) throws UnirestException { + return HaiNanDianXinApi.queryOrderInfo( logVO,this.getConfig(), param); } public HaiNanDianXinApi.HaiNanResponseInfo - getLogisticsTrajectory(HaiNanDianXinApi.GetLogisticsTrajectoryRequest param) throws UnirestException { - return HaiNanDianXinApi.getLogisticsTrajectory(this.getConfig(), param); + getLogisticsTrajectory(final SuperiorApiLogSaveReqVO logVO,HaiNanDianXinApi.GetLogisticsTrajectoryRequest param) throws UnirestException { + return HaiNanDianXinApi.getLogisticsTrajectory( logVO,this.getConfig(), param); } public HaiNanDianXinApi.HaiNanResponseInfo - synOrderInfo(HaiNanDianXinApi.SynOrderInfoRequest param) throws UnirestException { - return HaiNanDianXinApi.synOrderInfo(this.getConfig(), param); + synOrderInfo(final SuperiorApiLogSaveReqVO logVO,HaiNanDianXinApi.SynOrderInfoRequest param) throws UnirestException { + return HaiNanDianXinApi.synOrderInfo( logVO,this.getConfig(), param); } @Override diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHuNanDXService.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHuNanDXService.java index fc9c3aef71..886076cdfd 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHuNanDXService.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/ApiHuNanDXService.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.haoka.api; import cn.iocoder.yudao.module.haoka.api.hunandianxin.HuNanDXApi; import cn.iocoder.yudao.module.haoka.api.hunandianxin.HaiNanDxInfo; +import cn.iocoder.yudao.module.haoka.controller.admin.superiorapilog.vo.SuperiorApiLogSaveReqVO; import org.springframework.stereotype.Service; import java.util.Map; @@ -40,8 +41,8 @@ public class ApiHuNanDXService extends ApiConfigService { * @throws Exception 如果调用接口时发生异常 */ public HaiNanDxInfo.ResponseInfo - checkInternetCardQualification(HaiNanDxInfo.InternetCardQualificationParam param) throws Exception { - return HuNanDXApi.checkInternetCardQualification(getConfig(), param); + checkInternetCardQualification(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.InternetCardQualificationParam param) throws Exception { + return HuNanDXApi.checkInternetCardQualification(logVO,getConfig(), param); } /** @@ -52,8 +53,8 @@ public class ApiHuNanDXService extends ApiConfigService { * @throws Exception 如果调用接口时发生异常 */ public HaiNanDxInfo.ResponseInfo - syncOrder(HaiNanDxInfo.SyncOrderParam param) throws Exception { - return HuNanDXApi.syncOrder(getConfig(), param); + syncOrder(final SuperiorApiLogSaveReqVO logVO,HaiNanDxInfo.SyncOrderParam param) throws Exception { + return HuNanDXApi.syncOrder( logVO,getConfig(), param); } /** @@ -64,8 +65,8 @@ public class ApiHuNanDXService extends ApiConfigService { * @throws Exception 如果调用接口时发生异常 */ public HaiNanDxInfo.ResponseInfo - queryOrder(HaiNanDxInfo.QueryOrderParam param) throws Exception { - return HuNanDXApi.queryOrder(getConfig(), param); + queryOrder(final SuperiorApiLogSaveReqVO logVO,HaiNanDxInfo.QueryOrderParam param) throws Exception { + return HuNanDXApi.queryOrder( logVO,getConfig(), param); } /** @@ -76,8 +77,8 @@ public class ApiHuNanDXService extends ApiConfigService { * @throws Exception 如果调用接口时发生异常 */ public HaiNanDxInfo.ResponseInfo - sendSmsCode(HaiNanDxInfo.SendSmsCodeParam param) throws Exception { - return HuNanDXApi.sendSmsCode(getConfig(), param); + sendSmsCode(final SuperiorApiLogSaveReqVO logVO,HaiNanDxInfo.SendSmsCodeParam param) throws Exception { + return HuNanDXApi.sendSmsCode( logVO,getConfig(), param); } /** @@ -88,8 +89,8 @@ public class ApiHuNanDXService extends ApiConfigService { * @throws Exception 如果调用接口时发生异常 */ public HaiNanDxInfo.ResponseInfo - verifySmsCode(HaiNanDxInfo.VerifySmsCodeParam param) throws Exception { - return HuNanDXApi.verifySmsCode(getConfig(), param); + verifySmsCode(final SuperiorApiLogSaveReqVO logVO,HaiNanDxInfo.VerifySmsCodeParam param) throws Exception { + return HuNanDXApi.verifySmsCode( logVO,getConfig(), param); } /** @@ -100,8 +101,8 @@ public class ApiHuNanDXService extends ApiConfigService { * @throws Exception 如果调用接口时发生异常 */ public HaiNanDxInfo.ResponseInfo - queryPhoneNumber( HaiNanDxInfo.NeedSignQueryParam param) throws Exception { - return HuNanDXApi.queryPhoneNumber(getConfig(), param); + queryPhoneNumber(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.NeedSignQueryParam param) throws Exception { + return HuNanDXApi.queryPhoneNumber( logVO, getConfig(), param); } /** @@ -112,8 +113,8 @@ public class ApiHuNanDXService extends ApiConfigService { * @throws Exception 如果调用接口时发生异常 */ public HaiNanDxInfo.ResponseInfo - possessPhoneNumber(HaiNanDxInfo.NeedSignQueryParam param) throws Exception { - return HuNanDXApi.possessPhoneNumber(getConfig(), param); + possessPhoneNumber(final SuperiorApiLogSaveReqVO logVO,HaiNanDxInfo.NeedSignQueryParam param) throws Exception { + return HuNanDXApi.possessPhoneNumber( logVO,getConfig(), param); } /** @@ -124,8 +125,8 @@ public class ApiHuNanDXService extends ApiConfigService { * @throws Exception 如果调用接口时发生异常 */ public HaiNanDxInfo.ResponseInfo - checkBlackList(HaiNanDxInfo.BlackListCheckParam param) throws Exception { - return HuNanDXApi.checkBlackList(getConfig(), param); + checkBlackList(final SuperiorApiLogSaveReqVO logVO,HaiNanDxInfo.BlackListCheckParam param) throws Exception { + return HuNanDXApi.checkBlackList( logVO, getConfig(), param); } @Override diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/guangdong/inner/GdDxApi.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/guangdong/inner/GdDxApi.java index b7d026be3f..0cbcbc912f 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/guangdong/inner/GdDxApi.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/guangdong/inner/GdDxApi.java @@ -35,6 +35,7 @@ public class GdDxApi { logVO.setParam(jsonString); logVO.setUrl(url); + HttpResponse string = Unirest.post(url) .header("Content-Type", "application/json") .header("X-Sign", sign) diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/hainandianxin/HaiNanDianXinApi.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/hainandianxin/HaiNanDianXinApi.java index 75a14f6d1f..f8226b6edf 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/hainandianxin/HaiNanDianXinApi.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/hainandianxin/HaiNanDianXinApi.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.haoka.api.hainandianxin; import cn.iocoder.yudao.module.haoka.api.liantong.util.StringUtils; +import cn.iocoder.yudao.module.haoka.controller.admin.superiorapilog.vo.SuperiorApiLogSaveReqVO; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; import com.mashape.unirest.http.HttpResponse; @@ -60,8 +61,8 @@ public class HaiNanDianXinApi { * @return 防诈校验返回结果 * @throws UnirestException 请求异常 */ - public static HaiNanResponseInfo fraudCheck(HaiNanDianXinApiConfig config, FraudCheckRequest request) throws UnirestException { - return doPost(config, "fraudCheck", request, FraudCheckResponse.class); + public static HaiNanResponseInfo fraudCheck(final SuperiorApiLogSaveReqVO logVO,HaiNanDianXinApiConfig config, FraudCheckRequest request) throws UnirestException { + return doPost( logVO,config, "fraudCheck", request, FraudCheckResponse.class); } /** @@ -71,8 +72,8 @@ public class HaiNanDianXinApi { * @return 号码查询列表返回结果 * @throws UnirestException 请求异常 */ - public static HaiNanResponseInfo qryNbrList(HaiNanDianXinApiConfig config, QryNbrListRequest request) throws UnirestException { - return doPost(config, "qryNbrList", request, QryNbrListResponse.class); + public static HaiNanResponseInfo qryNbrList(final SuperiorApiLogSaveReqVO logVO,HaiNanDianXinApiConfig config, QryNbrListRequest request) throws UnirestException { + return doPost( logVO,config, "qryNbrList", request, QryNbrListResponse.class); } /** @@ -82,8 +83,8 @@ public class HaiNanDianXinApi { * @return 订单信息查询返回结果 * @throws UnirestException 请求异常 */ - public static HaiNanResponseInfo queryOrderInfo(HaiNanDianXinApiConfig config, QueryOrderInfoRequest request) throws UnirestException { - return doPost(config, "queryOrderInfo", request, QueryOrderInfoResponse.class); + public static HaiNanResponseInfo queryOrderInfo(final SuperiorApiLogSaveReqVO logVO,HaiNanDianXinApiConfig config, QueryOrderInfoRequest request) throws UnirestException { + return doPost( logVO,config, "queryOrderInfo", request, QueryOrderInfoResponse.class); } /** @@ -93,8 +94,9 @@ public class HaiNanDianXinApi { * @return 物流轨迹查询返回结果 * @throws UnirestException 请求异常 */ - public static HaiNanResponseInfo getLogisticsTrajectory(HaiNanDianXinApiConfig config, GetLogisticsTrajectoryRequest request) throws UnirestException { - return doPost(config, "getLogisticsTrajectory", request, GetLogisticsTrajectoryResponse.class); + public static HaiNanResponseInfo getLogisticsTrajectory(final SuperiorApiLogSaveReqVO logVO, + HaiNanDianXinApiConfig config, GetLogisticsTrajectoryRequest request) throws UnirestException { + return doPost( logVO,config, "getLogisticsTrajectory", request, GetLogisticsTrajectoryResponse.class); } /** @@ -104,8 +106,8 @@ public class HaiNanDianXinApi { * @return 号卡订单收敛返回结果 * @throws UnirestException 请求异常 */ - public static HaiNanResponseInfo synOrderInfo(HaiNanDianXinApiConfig config, SynOrderInfoRequest request) throws UnirestException { - return doPost(config, "synOrderInfo", request, SynOrderInfoResponse.class); + public static HaiNanResponseInfo synOrderInfo(final SuperiorApiLogSaveReqVO logVO,HaiNanDianXinApiConfig config, SynOrderInfoRequest request) throws UnirestException { + return doPost(logVO,config, "synOrderInfo", request, SynOrderInfoResponse.class); } /** @@ -119,15 +121,17 @@ public class HaiNanDianXinApi { * @return 返回结果 * @throws UnirestException 请求异常 */ - private static HaiNanResponseInfo doPost(HaiNanDianXinApiConfig config, String method, P param, Class rClass) throws UnirestException { + private static HaiNanResponseInfo doPost(final SuperiorApiLogSaveReqVO logVO, HaiNanDianXinApiConfig config, String method, P param, Class rClass) throws UnirestException { String jsonString = JSON.toJSONString(param); String encryptedBody = UopRSAUtils.encryptByPublicKey(jsonString, config.publicKey); + logVO.setParam(encryptedBody); String xAuthHeader = generateXAuthHeader(config, method, jsonString); HttpResponse response = Unirest.post(config.url) .header("Content-Type", "application/json") .header("x-auth", xAuthHeader) .body(encryptedBody) .asString(); + logVO.setResponse(response.getBody()); return dealResponse(response, rClass); } diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/hunandianxin/HuNanDXApi.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/hunandianxin/HuNanDXApi.java index a6cb908a1c..48b0dc1b7d 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/hunandianxin/HuNanDXApi.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/api/hunandianxin/HuNanDXApi.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.haoka.api.hunandianxin; +import cn.iocoder.yudao.module.haoka.controller.admin.superiorapilog.vo.SuperiorApiLogSaveReqVO; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.databind.ObjectMapper; @@ -28,69 +29,68 @@ public class HuNanDXApi { // 接口1、校验互联网卡下单资格_新(BPS):chk.ordercheck.InternetCardQualifica public static HaiNanDxInfo.ResponseInfo - checkInternetCardQualification(HaiNanDxInfo.ConfigInfo config, + checkInternetCardQualification(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.InternetCardQualificationParam param) throws Exception { - return doExecute(config, "chk.ordercheck.InternetCardQualifica", param, HaiNanDxInfo.InternetCardQualificationResp.class); + return doExecute(logVO, config, "chk.ordercheck.InternetCardQualifica", param, HaiNanDxInfo.InternetCardQualificationResp.class); } // 接口2、同步订单信息给BPS:syn.orderinfo.SynJdServiceOrder public static HaiNanDxInfo.ResponseInfo - syncOrder(HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.SyncOrderParam param) throws Exception { - return doExecute(config, "syn.orderinfo.SynJdServiceOrder", param, HaiNanDxInfo.SyncOrderResp.class); + syncOrder(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.SyncOrderParam param) throws Exception { + return doExecute(logVO, config, "syn.orderinfo.SynJdServiceOrder", param, HaiNanDxInfo.SyncOrderResp.class); } // 接口3、查询BPS业务订单详情:qry.order.QryBpsOrderInfo public static HaiNanDxInfo.ResponseInfo - queryOrder(HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.QueryOrderParam param) throws Exception { - return doExecute(config, "qry.order.QryBpsOrderInfo", param, HaiNanDxInfo.QueryOrderResp.class); + queryOrder(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.QueryOrderParam param) throws Exception { + return doExecute(logVO, config, "qry.order.QryBpsOrderInfo", param, HaiNanDxInfo.QueryOrderResp.class); } // 接口5、短信渠道短信验证码发送:push.sms.sendsmsCode public static HaiNanDxInfo.ResponseInfo - sendSmsCode(HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.SendSmsCodeParam param) throws Exception { - return doExecute(config, "push.sms.sendsmsCode", param, HaiNanDxInfo.SendSmsCodeResp.class); + sendSmsCode(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.SendSmsCodeParam param) throws Exception { + return doExecute(logVO, config, "push.sms.sendsmsCode", param, HaiNanDxInfo.SendSmsCodeResp.class); } // 接口6、短信渠道下发短信验证码是否验证通过:push.sms.sendsmsCodeYz public static HaiNanDxInfo.ResponseInfo - verifySmsCode(HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.VerifySmsCodeParam param) throws Exception { - return doExecute(config, "push.sms.sendsmsCodeYz", param, HaiNanDxInfo.VerifySmsCodeResp.class); + verifySmsCode(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.VerifySmsCodeParam param) throws Exception { + return doExecute(logVO, config, "push.sms.sendsmsCodeYz", param, HaiNanDxInfo.VerifySmsCodeResp.class); } // 接口7、号码查询:qry.nmall.phoneNumberlList public static HaiNanDxInfo.ResponseInfo - queryPhoneNumber(HaiNanDxInfo.ConfigInfo config, + queryPhoneNumber(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.NeedSignQueryParam param) throws Exception { // 生成签名 JSONObject jsonObject = (JSONObject) JSON.toJSON(param); String sign = genSignFromMap(jsonObject, config.getSecret()); param.setSign(sign); - return doExecute(config, "qry.nmall.phoneNumberlList", param, HaiNanDxInfo.QueryPhoneNumberResp.class); + return doExecute(logVO, config, "qry.nmall.phoneNumberlList", param, HaiNanDxInfo.QueryPhoneNumberResp.class); } // 接口8、占用号码:qry.nmall.possessPhoneNumber public static HaiNanDxInfo.ResponseInfo - possessPhoneNumber(HaiNanDxInfo.ConfigInfo config, + possessPhoneNumber(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.NeedSignQueryParam param) throws Exception { // 生成签名 JSONObject jsonObject = (JSONObject) JSON.toJSON(param); String sign = genSignFromMap(jsonObject, config.getSecret()); param.setSign(sign); - return doExecute(config, "qry.nmall.possessPhoneNumber", param, HaiNanDxInfo.PossessPhoneNumberResp.class); + return doExecute(logVO, config, "qry.nmall.possessPhoneNumber", param, HaiNanDxInfo.PossessPhoneNumberResp.class); } // 接口9、联系电话黑名单接口:getBlackDataByPhone public static HaiNanDxInfo.ResponseInfo - checkBlackList(HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.BlackListCheckParam param) throws Exception { - return doExecute(config, "getBlackDataByPhone", param, HaiNanDxInfo.BlackListCheckResp.class); + checkBlackList(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.BlackListCheckParam param) throws Exception { + return doExecute(logVO, config, "getBlackDataByPhone", param, HaiNanDxInfo.BlackListCheckResp.class); } // 通用 API 调用方法 private static HaiNanDxInfo.ResponseInfo - doExecute(HaiNanDxInfo.ConfigInfo config, String method, T data, Class rClass) throws Exception { + doExecute(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.ConfigInfo config, String method, T data, Class rClass) throws Exception { JSONObject jsonObject = (JSONObject) JSON.toJSON(data); - String calledApi = callApi(config, method, jsonObject); - System.out.println("-------{}--" + calledApi); + String calledApi = callApi(logVO, config, method, jsonObject); HaiNanDxInfo.ResponseInfo responseInfo = JSON.parseObject(calledApi, HaiNanDxInfo.ResponseInfo.class); JSONObject result = responseInfo.getResult(); @@ -102,6 +102,7 @@ public class HuNanDXApi { } return objectResponseInfo; } + private static CloseableHttpClient createHttpClientIgnoreSSL() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException { // 创建信任所有证书的TrustStrategy TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true; @@ -121,7 +122,7 @@ public class HuNanDXApi { } // 通用 API 调用方法 - private static String callApi(HaiNanDxInfo.ConfigInfo config, String method, JSONObject data) throws Exception { + private static String callApi(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.ConfigInfo config, String method, JSONObject data) throws Exception { // 构建请求体 Map requestBody = new TreeMap<>(); requestBody.put("access_token", config.getAccessToken()); @@ -131,14 +132,17 @@ public class HuNanDXApi { // 发送 HTTP 请求 try (CloseableHttpClient httpClient = createHttpClientIgnoreSSL()) { - HttpPost httpPost = new HttpPost(config.getBaseUrl()); + String baseUrl = config.getBaseUrl(); + logVO.setUrl(baseUrl); + logVO.setParam(JSON.toJSONString(requestBody)); + HttpPost httpPost = new HttpPost(baseUrl); httpPost.setHeader("Content-Type", "application/json; charset=UTF-8"); httpPost.setEntity(new StringEntity(new ObjectMapper().writeValueAsString(requestBody))); CloseableHttpResponse response = httpClient.execute(httpPost); String string = EntityUtils.toString(response.getEntity()); - log.info("Response Code: " + response.getStatusLine().getStatusCode()); + logVO.setResponse(JSON.toJSONString(string)); httpClient.close(); return string; } diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/api/HaokaApiHaiNanDXController.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/api/HaokaApiHaiNanDXController.java index 36955dfa62..7c9bf7511c 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/api/HaokaApiHaiNanDXController.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/api/HaokaApiHaiNanDXController.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.haoka.controller.admin.api; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.haoka.api.ApiHaiNanDXService; import cn.iocoder.yudao.module.haoka.api.hainandianxin.HaiNanDianXinApi; +import cn.iocoder.yudao.module.haoka.controller.admin.superiorapilog.vo.SuperiorApiLogSaveReqVO; import com.mashape.unirest.http.exceptions.UnirestException; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -27,34 +28,34 @@ public class HaokaApiHaiNanDXController { @Operation(summary = "海南电信-选号接口") public CommonResult> lianTongSelectNumber(@RequestBody HaiNanDianXinApi.QryNbrListRequest param) throws UnirestException { - return success(apiHaiNanDXService.qryNbrList(param)); + return success(apiHaiNanDXService.qryNbrList(new SuperiorApiLogSaveReqVO(), param)); } @PostMapping("/fraudCheck") @Operation(summary = "海南电信-防诈校验接口") public CommonResult> fraudCheck(@RequestBody HaiNanDianXinApi.FraudCheckRequest param) throws UnirestException { - return success(apiHaiNanDXService.fraudCheck(param)); + return success(apiHaiNanDXService.fraudCheck(new SuperiorApiLogSaveReqVO(), param)); } @PostMapping("/queryOrderInfo") @Operation(summary = "海南电信-订单信息查询接口") public CommonResult> queryOrderInfo(@RequestBody HaiNanDianXinApi.QueryOrderInfoRequest param) throws UnirestException { - return success(apiHaiNanDXService.queryOrderInfo(param)); + return success(apiHaiNanDXService.queryOrderInfo(new SuperiorApiLogSaveReqVO(), param)); } @PostMapping("/getLogisticsTrajectory") @Operation(summary = "海南电信-物流轨迹查询接口") public CommonResult> getLogisticsTrajectory(@RequestBody HaiNanDianXinApi.GetLogisticsTrajectoryRequest param) throws UnirestException { - return success(apiHaiNanDXService.getLogisticsTrajectory(param)); + return success(apiHaiNanDXService.getLogisticsTrajectory(new SuperiorApiLogSaveReqVO(), param)); } @PostMapping("/synOrderInfo") @Operation(summary = "海南电信-号卡订单收敛接口") public CommonResult> synOrderInfo(@RequestBody HaiNanDianXinApi.SynOrderInfoRequest param) throws UnirestException { - return success(apiHaiNanDXService.synOrderInfo(param)); + return success(apiHaiNanDXService.synOrderInfo(new SuperiorApiLogSaveReqVO(), param)); } } diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/api/HaokaHuNanDXController.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/api/HaokaHuNanDXController.java index ce4d2ff34a..1db757f3ec 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/api/HaokaHuNanDXController.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/api/HaokaHuNanDXController.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.haoka.controller.admin.api; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.haoka.api.ApiHuNanDXService; import cn.iocoder.yudao.module.haoka.api.hunandianxin.HaiNanDxInfo; +import cn.iocoder.yudao.module.haoka.controller.admin.superiorapilog.vo.SuperiorApiLogSaveReqVO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; @@ -28,35 +29,35 @@ public class HaokaHuNanDXController { @Operation(summary = "湖南电信-校验互联网卡下单资格") public CommonResult> checkInternetCardQualification(@RequestBody HaiNanDxInfo.InternetCardQualificationParam param) throws Exception { - return success(apiHuNanDXService.checkInternetCardQualification(param)); + return success(apiHuNanDXService.checkInternetCardQualification(new SuperiorApiLogSaveReqVO(), param)); } @PostMapping("/syncOrder") @Operation(summary = "湖南电信-同步订单信息") public CommonResult> syncOrder(@RequestBody HaiNanDxInfo.SyncOrderParam param) throws Exception { - return success(apiHuNanDXService.syncOrder(param)); + return success(apiHuNanDXService.syncOrder(new SuperiorApiLogSaveReqVO(), param)); } @PostMapping("/queryOrder") @Operation(summary = "湖南电信-查询订单详情") public CommonResult> queryOrder(@RequestBody HaiNanDxInfo.QueryOrderParam param) throws Exception { - return success(apiHuNanDXService.queryOrder(param)); + return success(apiHuNanDXService.queryOrder(new SuperiorApiLogSaveReqVO(), param)); } @PostMapping("/sendSmsCode") @Operation(summary = "湖南电信-发送短信验证码") public CommonResult> sendSmsCode(@RequestBody HaiNanDxInfo.SendSmsCodeParam param) throws Exception { - return success(apiHuNanDXService.sendSmsCode(param)); + return success(apiHuNanDXService.sendSmsCode(new SuperiorApiLogSaveReqVO(), param)); } @PostMapping("/verifySmsCode") @Operation(summary = "湖南电信-验证短信验证码") public CommonResult> verifySmsCode(@RequestBody HaiNanDxInfo.VerifySmsCodeParam param) throws Exception { - return success(apiHuNanDXService.verifySmsCode(param)); + return success(apiHuNanDXService.verifySmsCode(new SuperiorApiLogSaveReqVO(), param)); } @PermitAll @@ -64,20 +65,20 @@ public class HaokaHuNanDXController { @Operation(summary = "湖南电信-查询号码") public CommonResult> queryPhoneNumber(@RequestBody HaiNanDxInfo.NeedSignQueryParam param) throws Exception { - return success(apiHuNanDXService.queryPhoneNumber(param)); + return success(apiHuNanDXService.queryPhoneNumber(new SuperiorApiLogSaveReqVO(),param)); } @PostMapping("/possessPhoneNumber") @Operation(summary = "湖南电信-占用号码") public CommonResult> possessPhoneNumber(@RequestBody HaiNanDxInfo.NeedSignQueryParam param) throws Exception { - return success(apiHuNanDXService.possessPhoneNumber(param)); + return success(apiHuNanDXService.possessPhoneNumber(new SuperiorApiLogSaveReqVO(),param)); } @PostMapping("/checkBlackList") @Operation(summary = "湖南电信-检查黑名单") public CommonResult> checkBlackList(@RequestBody HaiNanDxInfo.BlackListCheckParam param) throws Exception { - return success(apiHuNanDXService.checkBlackList(param)); + return success(apiHuNanDXService.checkBlackList(new SuperiorApiLogSaveReqVO(),param)); } } diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/superiorapilog/vo/SuperiorApiLogSaveReqVO.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/superiorapilog/vo/SuperiorApiLogSaveReqVO.java index be664363f4..87e312466d 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/superiorapilog/vo/SuperiorApiLogSaveReqVO.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/controller/admin/superiorapilog/vo/SuperiorApiLogSaveReqVO.java @@ -3,9 +3,12 @@ package cn.iocoder.yudao.module.haoka.controller.admin.superiorapilog.vo; import cn.iocoder.yudao.module.haoka.utils.SnowflakeId; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; + import java.util.*; + import jakarta.validation.constraints.*; import org.springframework.format.annotation.DateTimeFormat; + import java.time.LocalDateTime; @Schema(description = "管理后台 - 订单接口记录新增/修改 Request VO") @@ -25,31 +28,47 @@ public class SuperiorApiLogSaveReqVO { private Long haokaProductId; @Schema(description = "请求时间") - private LocalDateTime time =LocalDateTime.now(); + private LocalDateTime time = LocalDateTime.now(); @Schema(description = "接口类型:提单1/查单2/回调3", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @NotNull(message = "接口类型:提单1/查单2/回调3不能为空") private Integer apiType; @Schema(description = "URl", example = "https://www.iocoder.cn") - private String url; + private String url = ""; @Schema(description = "参数") - private String param; + private String param = ""; @Schema(description = "响应") - private String response; + private String response = ""; @Schema(description = "成功") private Boolean success; @Schema(description = "备注") - private String innerNote; + private String innerNote = ""; @Schema(description = "错误") - private String errorInfo; + private String errorInfo = ""; @Schema(description = "部门ID", example = "25249") private Long deptId; + public void setParam(String param) { + + this.param = this.param + param; + } + + public void setResponse(String response) { + this.response = this.response + response; + } + + public void setInnerNote(String innerNote) { + this.innerNote = this.innerNote + innerNote; + } + + public void setErrorInfo(String errorInfo) { + this.errorInfo = this.errorInfo + errorInfo; + } } diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealServiceImpl.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealServiceImpl.java index 0fde0c061d..5a0c0a7da9 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealServiceImpl.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/ApiDealServiceImpl.java @@ -37,6 +37,8 @@ public class ApiDealServiceImpl implements ApiDealStrategyService { @Override public ApiDealResp createOrder(final SuperiorApiLogSaveReqVO logVO, OrderApiCreateParam param) { logVO.setApiType(1); + logVO.setHaokaOrderId(param.getId()); + logVO.setHaokaProductId(param.getProductId()); try { ApiDealStrategy apiDealStrategy = this.getApiDealStrategy(param.getProductId()); if (apiDealStrategy == null) { @@ -45,7 +47,16 @@ public class ApiDealServiceImpl implements ApiDealStrategyService { logVO.setErrorInfo(noneService); return ApiDealResp.failed(noneService); } - return apiDealStrategy.createOrder(param); + ApiDealResp respApiDealResp = apiDealStrategy.createOrder(param); + if (!respApiDealResp.getIsSupport()){ + logVO.setSuccess(false); + logVO.setInnerNote(respApiDealResp.getMsg()); + } + if (!respApiDealResp.getSuccess()){ + logVO.setSuccess(false); + logVO.setInnerNote(respApiDealResp.getMsg()); + } + return respApiDealResp; } catch (Exception e) { logVO.setSuccess(false); logVO.setErrorInfo(e.getMessage()); @@ -59,6 +70,8 @@ public class ApiDealServiceImpl implements ApiDealStrategyService { @Override public ApiDealResp queryOrder(final SuperiorApiLogSaveReqVO logVO, OrderApiQueryParam param) { logVO.setApiType(2); + logVO.setHaokaOrderId(param.getId()); + logVO.setHaokaProductId(param.getProductId()); try { ApiDealStrategy apiDealStrategy = this.getApiDealStrategy(param.getProductId()); if (apiDealStrategy == null) { @@ -67,7 +80,16 @@ public class ApiDealServiceImpl implements ApiDealStrategyService { logVO.setErrorInfo(noneService); return ApiDealResp.failed(noneService); } - return apiDealStrategy.queryOrder(param); + ApiDealResp respApiDealResp = apiDealStrategy.queryOrder(param); + if (!respApiDealResp.getIsSupport()){ + logVO.setSuccess(false); + logVO.setInnerNote(respApiDealResp.getMsg()); + } + if (!respApiDealResp.getSuccess()){ + logVO.setSuccess(false); + logVO.setInnerNote(respApiDealResp.getMsg()); + } + return respApiDealResp; } catch (Exception e) { logVO.setSuccess(false); logVO.setErrorInfo(e.getMessage()); diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HaiNanDxApiDealStrategy.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HaiNanDxApiDealStrategy.java index 7b25b6df41..8c87635ebe 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HaiNanDxApiDealStrategy.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HaiNanDxApiDealStrategy.java @@ -51,7 +51,8 @@ public class HaiNanDxApiDealStrategy implements ApiDealStrategy { HaiNanDianXinApi.SynOrderInfoRequest createParam = new HaiNanDianXinApi.SynOrderInfoRequest(); try { - HaiNanDianXinApi.HaiNanResponseInfo responseInfo = apiHaiNanDXService.synOrderInfo(createParam); + HaiNanDianXinApi.HaiNanResponseInfo responseInfo + = apiHaiNanDXService.synOrderInfo(logVO, createParam); HaiNanDianXinApi.SynOrderInfoResponse data = responseInfo.getData(); if (data == null) { return ApiDealResp.failed(responseInfo.getErrMsg()); @@ -72,7 +73,7 @@ public class HaiNanDxApiDealStrategy implements ApiDealStrategy { try { HaiNanDianXinApi.QueryOrderInfoRequest queryParam = new HaiNanDianXinApi.QueryOrderInfoRequest(); - HaiNanDianXinApi.HaiNanResponseInfo responseInfo = apiHaiNanDXService.queryOrderInfo(queryParam); + HaiNanDianXinApi.HaiNanResponseInfo responseInfo = apiHaiNanDXService.queryOrderInfo(logVO, queryParam); if (responseInfo.getData() == null) { return ApiDealResp.failed(responseInfo.getErrMsg()); diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HuNanDxApiDealStrategy.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HuNanDxApiDealStrategy.java index 610da179e5..7c0ddb895c 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HuNanDxApiDealStrategy.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/HuNanDxApiDealStrategy.java @@ -54,7 +54,7 @@ public class HuNanDxApiDealStrategy implements ApiDealStrategy { HaiNanDianXinApi.SynOrderInfoRequest createParam = new HaiNanDianXinApi.SynOrderInfoRequest(); try { - HaiNanDxInfo.ResponseInfo responseInfo = apiHuNanDXService.syncOrder(orderParam); + HaiNanDxInfo.ResponseInfo responseInfo = apiHuNanDXService.syncOrder(logVO,orderParam); if (responseInfo.getData() == null) { @@ -75,7 +75,7 @@ public class HuNanDxApiDealStrategy implements ApiDealStrategy { try { HaiNanDxInfo.QueryOrderParam queryParam = new HaiNanDxInfo.QueryOrderParam(); queryParam.setOutId(param.getOuterOrderId()); - HaiNanDxInfo.ResponseInfo responseInfo = apiHuNanDXService.queryOrder(queryParam); + HaiNanDxInfo.ResponseInfo responseInfo = apiHuNanDXService.queryOrder(logVO,queryParam); if (responseInfo.getData() == null) { return ApiDealResp.failed(responseInfo.getRes_message()); diff --git a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/LianTongApiDealStrategy.java b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/LianTongApiDealStrategy.java index 04fb351456..23d9764900 100644 --- a/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/LianTongApiDealStrategy.java +++ b/yudao-module-haoka/yudao-module-haoka-biz/src/main/java/cn/iocoder/yudao/module/haoka/service/api/strategy/LianTongApiDealStrategy.java @@ -52,11 +52,6 @@ public class LianTongApiDealStrategy implements ApiDealStrategy { LianTongArea numAddress = getAddress(preProduct.getParentProduct().getBelongAreaCode()); - // 0、占用号码 lianTongZhanHao - // 1、提交资料 lianTongSubmitUserInfo - // 2、提交预订单 得到token lianTongPreOrderSync - // 3、用 token提交正式订单 lianTongOrderSyncV2 - // 0、占用号码 lianTongZhanHao KingNumStateChangeRequest stateChangeRequest = new KingNumStateChangeRequest(); stateChangeRequest.setCityCode(numAddress.getPhoneCityCode()); @@ -65,8 +60,10 @@ public class LianTongApiDealStrategy implements ApiDealStrategy { stateChangeRequest.setOccupiedFlag("S"); stateChangeRequest.setCertCode(param.getIdCardNum()); stateChangeRequest.setOccupiedTimeTag("S1"); - KingNumStateChangeResponse stateChangeResponse = apiLianTongService.lianTongZhanHao(stateChangeRequest); + logVO.setParam(JSON.toJSONString(stateChangeRequest)); + KingNumStateChangeResponse stateChangeResponse = apiLianTongService.lianTongZhanHao(stateChangeRequest); + logVO.setResponse(JSON.toJSONString(stateChangeResponse)); if (!"0".equals(stateChangeResponse.getRspCode())) { return ApiDealResp.failed(stateChangeResponse.getRspCode()); } @@ -77,8 +74,12 @@ public class LianTongApiDealStrategy implements ApiDealStrategy { ziLiao.setCity(numAddress.getPhoneCityCode()); ziLiao.setCertName(param.getIdCardName()); ziLiao.setCertNum(param.getIdCardNum()); + + logVO.setParam(JSON.toJSONString(ziLiao)); KingIdentityCustV2Response ziLiaoResponse = apiLianTongService.lianTongSubmitUserInfo(ziLiao); + logVO.setResponse(JSON.toJSONString(ziLiaoResponse)); + String rspCode = ziLiaoResponse.getaDesc(); if (!"成功".equals(rspCode)) { @@ -95,12 +96,18 @@ public class LianTongApiDealStrategy implements ApiDealStrategy { preOrder.setPostCityCode(receiveAddress.getCityCode()); preOrder.setPostDistrictCode(receiveAddress.getDistrictCode()); preOrder.setPostAddr(param.getAddress()); + String channel = apiLianTongService.getConfigValue(LianTongApiUtil.KEY_channel); preOrder.setChannel(channel); preOrder.setCreateTime(format); preOrder.setUpdateTime(format); preOrder.setContactNum(param.getAddressMobile()); + + + logVO.setParam(JSON.toJSONString(preOrder)); KingPreOrderSyncResponse preOrderResponse = apiLianTongService.lianTongPreOrderSync(preOrder); + logVO.setResponse(JSON.toJSONString(preOrderResponse)); + if (!"0000".equals(preOrderResponse.getRspCode())) { return ApiDealResp.failed(stateChangeResponse.getRspDesc()); } @@ -117,13 +124,16 @@ public class LianTongApiDealStrategy implements ApiDealStrategy { syncV2.setCreateTime(format); syncV2.setPhoneNum(param.getPlanMobile()); syncV2.setGoodsId(preProduct.getSuperiorProductConfigRespVO().getSuperiorCode()); - syncV2.setToken("tokentokentokentoken"); - KingOrderSyncResponse syncV2Response = apiLianTongService.lianTongOrderSyncV2(syncV2); - if (!"0000".equals(syncV2Response.getRspCode())) { + + syncV2.setToken(preOrderResponse.getBody()); + + logVO.setParam(JSON.toJSONString(syncV2)); + KingOrderSyncResponse response = apiLianTongService.lianTongOrderSyncV2(syncV2); + logVO.setResponse(JSON.toJSONString(response)); + if (!"0000".equals(response.getRspCode())) { return ApiDealResp.failed(stateChangeResponse.getRspDesc()); } - KingOrderSyncResponse response = apiLianTongService.lianTongOrderSyncV2(syncV2); OrderApiCreateResp orderApiCreateResp = new OrderApiCreateResp(); orderApiCreateResp.setData(response); return ApiDealResp.ok(orderApiCreateResp);