Feat: Api fix log

This commit is contained in:
Owen 2024-12-31 11:20:18 +08:00
parent bb46296bd6
commit 7701cd7c6f
12 changed files with 159 additions and 94 deletions

View File

@ -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<HaiNanDianXinApi.QryNbrListResponse>
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<HaiNanDianXinApi.FraudCheckResponse>
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<HaiNanDianXinApi.QueryOrderInfoResponse>
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<HaiNanDianXinApi.GetLogisticsTrajectoryResponse>
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<HaiNanDianXinApi.SynOrderInfoResponse>
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

View File

@ -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<HaiNanDxInfo.InternetCardQualificationResp>
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<HaiNanDxInfo.SyncOrderResp>
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<HaiNanDxInfo.QueryOrderResp>
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<HaiNanDxInfo.SendSmsCodeResp>
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<HaiNanDxInfo.VerifySmsCodeResp>
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<HaiNanDxInfo.QueryPhoneNumberResp>
queryPhoneNumber( HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.QueryPhoneNumberParam> param) throws Exception {
return HuNanDXApi.queryPhoneNumber(getConfig(), param);
queryPhoneNumber(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.QueryPhoneNumberParam> param) throws Exception {
return HuNanDXApi.queryPhoneNumber( logVO, getConfig(), param);
}
/**
@ -112,8 +113,8 @@ public class ApiHuNanDXService extends ApiConfigService {
* @throws Exception 如果调用接口时发生异常
*/
public HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.PossessPhoneNumberResp>
possessPhoneNumber(HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.PossessPhoneNumberParam> param) throws Exception {
return HuNanDXApi.possessPhoneNumber(getConfig(), param);
possessPhoneNumber(final SuperiorApiLogSaveReqVO logVO,HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.PossessPhoneNumberParam> param) throws Exception {
return HuNanDXApi.possessPhoneNumber( logVO,getConfig(), param);
}
/**
@ -124,8 +125,8 @@ public class ApiHuNanDXService extends ApiConfigService {
* @throws Exception 如果调用接口时发生异常
*/
public HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.BlackListCheckResp>
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

View File

@ -35,6 +35,7 @@ public class GdDxApi {
logVO.setParam(jsonString);
logVO.setUrl(url);
HttpResponse<String> string = Unirest.post(url)
.header("Content-Type", "application/json")
.header("X-Sign", sign)

View File

@ -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<FraudCheckResponse> fraudCheck(HaiNanDianXinApiConfig config, FraudCheckRequest request) throws UnirestException {
return doPost(config, "fraudCheck", request, FraudCheckResponse.class);
public static HaiNanResponseInfo<FraudCheckResponse> 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<QryNbrListResponse> qryNbrList(HaiNanDianXinApiConfig config, QryNbrListRequest request) throws UnirestException {
return doPost(config, "qryNbrList", request, QryNbrListResponse.class);
public static HaiNanResponseInfo<QryNbrListResponse> 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<QueryOrderInfoResponse> queryOrderInfo(HaiNanDianXinApiConfig config, QueryOrderInfoRequest request) throws UnirestException {
return doPost(config, "queryOrderInfo", request, QueryOrderInfoResponse.class);
public static HaiNanResponseInfo<QueryOrderInfoResponse> 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<GetLogisticsTrajectoryResponse> getLogisticsTrajectory(HaiNanDianXinApiConfig config, GetLogisticsTrajectoryRequest request) throws UnirestException {
return doPost(config, "getLogisticsTrajectory", request, GetLogisticsTrajectoryResponse.class);
public static HaiNanResponseInfo<GetLogisticsTrajectoryResponse> 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<SynOrderInfoResponse> synOrderInfo(HaiNanDianXinApiConfig config, SynOrderInfoRequest request) throws UnirestException {
return doPost(config, "synOrderInfo", request, SynOrderInfoResponse.class);
public static HaiNanResponseInfo<SynOrderInfoResponse> 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 <R, P> HaiNanResponseInfo<R> doPost(HaiNanDianXinApiConfig config, String method, P param, Class<R> rClass) throws UnirestException {
private static <R, P> HaiNanResponseInfo<R> doPost(final SuperiorApiLogSaveReqVO logVO, HaiNanDianXinApiConfig config, String method, P param, Class<R> 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<String> 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);
}

View File

@ -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<HaiNanDxInfo.InternetCardQualificationResp>
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同步订单信息给BPSsyn.orderinfo.SynJdServiceOrder
public static HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.SyncOrderResp>
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<HaiNanDxInfo.QueryOrderResp>
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<HaiNanDxInfo.SendSmsCodeResp>
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<HaiNanDxInfo.VerifySmsCodeResp>
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<HaiNanDxInfo.QueryPhoneNumberResp>
queryPhoneNumber(HaiNanDxInfo.ConfigInfo config,
queryPhoneNumber(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.ConfigInfo config,
HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.QueryPhoneNumberParam> 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<HaiNanDxInfo.PossessPhoneNumberResp>
possessPhoneNumber(HaiNanDxInfo.ConfigInfo config,
possessPhoneNumber(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.ConfigInfo config,
HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.PossessPhoneNumberParam> 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<HaiNanDxInfo.BlackListCheckResp>
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 <T, R> HaiNanDxInfo.ResponseInfo<R>
doExecute(HaiNanDxInfo.ConfigInfo config, String method, T data, Class<R> rClass) throws Exception {
doExecute(final SuperiorApiLogSaveReqVO logVO, HaiNanDxInfo.ConfigInfo config, String method, T data, Class<R> 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<String, Object> 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;
}

View File

@ -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<HaiNanDianXinApi.HaiNanResponseInfo<HaiNanDianXinApi.QryNbrListResponse>>
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<HaiNanDianXinApi.HaiNanResponseInfo<HaiNanDianXinApi.FraudCheckResponse>>
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<HaiNanDianXinApi.HaiNanResponseInfo<HaiNanDianXinApi.QueryOrderInfoResponse>>
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<HaiNanDianXinApi.HaiNanResponseInfo<HaiNanDianXinApi.GetLogisticsTrajectoryResponse>>
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<HaiNanDianXinApi.HaiNanResponseInfo<HaiNanDianXinApi.SynOrderInfoResponse>>
synOrderInfo(@RequestBody HaiNanDianXinApi.SynOrderInfoRequest param) throws UnirestException {
return success(apiHaiNanDXService.synOrderInfo(param));
return success(apiHaiNanDXService.synOrderInfo(new SuperiorApiLogSaveReqVO(), param));
}
}

View File

@ -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<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.InternetCardQualificationResp>>
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<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.SyncOrderResp>>
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<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.QueryOrderResp>>
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<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.SendSmsCodeResp>>
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<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.VerifySmsCodeResp>>
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<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.QueryPhoneNumberResp>>
queryPhoneNumber(@RequestBody HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.QueryPhoneNumberParam> param) throws Exception {
return success(apiHuNanDXService.queryPhoneNumber(param));
return success(apiHuNanDXService.queryPhoneNumber(new SuperiorApiLogSaveReqVO(),param));
}
@PostMapping("/possessPhoneNumber")
@Operation(summary = "湖南电信-占用号码")
public CommonResult<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.PossessPhoneNumberResp>>
possessPhoneNumber(@RequestBody HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.PossessPhoneNumberParam> param) throws Exception {
return success(apiHuNanDXService.possessPhoneNumber(param));
return success(apiHuNanDXService.possessPhoneNumber(new SuperiorApiLogSaveReqVO(),param));
}
@PostMapping("/checkBlackList")
@Operation(summary = "湖南电信-检查黑名单")
public CommonResult<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.BlackListCheckResp>>
checkBlackList(@RequestBody HaiNanDxInfo.BlackListCheckParam param) throws Exception {
return success(apiHuNanDXService.checkBlackList(param));
return success(apiHuNanDXService.checkBlackList(new SuperiorApiLogSaveReqVO(),param));
}
}

View File

@ -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;
}
}

View File

@ -37,6 +37,8 @@ public class ApiDealServiceImpl implements ApiDealStrategyService {
@Override
public ApiDealResp<OrderApiCreateResp> 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<OrderApiCreateResp> 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<OrderApiQueryResp> 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<OrderApiQueryResp> 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());

View File

@ -51,7 +51,8 @@ public class HaiNanDxApiDealStrategy implements ApiDealStrategy {
HaiNanDianXinApi.SynOrderInfoRequest createParam = new HaiNanDianXinApi.SynOrderInfoRequest();
try {
HaiNanDianXinApi.HaiNanResponseInfo<HaiNanDianXinApi.SynOrderInfoResponse> responseInfo = apiHaiNanDXService.synOrderInfo(createParam);
HaiNanDianXinApi.HaiNanResponseInfo<HaiNanDianXinApi.SynOrderInfoResponse> 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<HaiNanDianXinApi.QueryOrderInfoResponse> responseInfo = apiHaiNanDXService.queryOrderInfo(queryParam);
HaiNanDianXinApi.HaiNanResponseInfo<HaiNanDianXinApi.QueryOrderInfoResponse> responseInfo = apiHaiNanDXService.queryOrderInfo(logVO, queryParam);
if (responseInfo.getData() == null) {
return ApiDealResp.failed(responseInfo.getErrMsg());

View File

@ -54,7 +54,7 @@ public class HuNanDxApiDealStrategy implements ApiDealStrategy {
HaiNanDianXinApi.SynOrderInfoRequest createParam = new HaiNanDianXinApi.SynOrderInfoRequest();
try {
HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.SyncOrderResp> responseInfo = apiHuNanDXService.syncOrder(orderParam);
HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.SyncOrderResp> 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<HaiNanDxInfo.QueryOrderResp> responseInfo = apiHuNanDXService.queryOrder(queryParam);
HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.QueryOrderResp> responseInfo = apiHuNanDXService.queryOrder(logVO,queryParam);
if (responseInfo.getData() == null) {
return ApiDealResp.failed(responseInfo.getRes_message());

View File

@ -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);