广州电信
This commit is contained in:
parent
a55e0ba820
commit
8fd8f09d1e
|
|
@ -16,6 +16,8 @@ public class ApiHaiNanDXService extends ApiConfigService {
|
|||
public static final String Key_md5Key = "md5Key";
|
||||
public static final String Key_publicKey = "publicKey";
|
||||
public static final String Key_privateKey = "privateKey";
|
||||
public static final String Key_xAppId="xAppId";
|
||||
public static final String Key_xAppKey="xAppKey";
|
||||
|
||||
private HaiNanDianXinApi.HaiNanDianXinApiConfig getConfig() {
|
||||
Map<String, String> devConfig = this.getDevConfig();
|
||||
|
|
@ -26,7 +28,11 @@ public class ApiHaiNanDXService extends ApiConfigService {
|
|||
String md5Key = devConfig.get(Key_md5Key);
|
||||
String publicKey = devConfig.get(Key_publicKey);
|
||||
String privateKey = devConfig.get(Key_privateKey);
|
||||
String xAppId = devConfig.get(Key_xAppId);
|
||||
String xAppKey = devConfig.get(Key_xAppKey);
|
||||
HaiNanDianXinApi.HaiNanDianXinApiConfig config = new HaiNanDianXinApi.HaiNanDianXinApiConfig();
|
||||
config.setXAppId(xAppId);
|
||||
config.setXAppKey(xAppKey);
|
||||
config.setUrl(url);
|
||||
config.setAppCode(appCode);
|
||||
config.setAbilityCode(abilityCode);
|
||||
|
|
@ -41,6 +47,19 @@ public class ApiHaiNanDXService extends ApiConfigService {
|
|||
return HaiNanDianXinApi.qryNbrList(logVO, this.getConfig(), param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 收货地址查询
|
||||
*
|
||||
* @param logVO 日志记录对象
|
||||
* @param param 收货地址查询请求参数
|
||||
* @return 收货地址查询返回结果
|
||||
* @throws UnirestException 请求异常
|
||||
*/
|
||||
public HaiNanDianXinApi.HaiNanResponseInfo<HaiNanDianXinApi.QryReceiveAddrResponse>
|
||||
qryReceiveAddr(final SuperiorApiLogSaveReqVO logVO, HaiNanDianXinApi.QryReceiveAddrRequest param) throws UnirestException {
|
||||
return HaiNanDianXinApi.qryReceiveAddr(logVO, this.getConfig(), param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 防诈校验接口查询
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import lombok.Data;
|
|||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
|
|
@ -28,8 +29,11 @@ public class HaiNanDianXinApi {
|
|||
private String md5Key = "your_md5_key"; // 平台分配的密钥
|
||||
private String publicKey = "your_rsa_public_key"; // RSA加密公钥
|
||||
private String privateKey = ""; // RSA 私钥
|
||||
private String xAppId = "";
|
||||
private String xAppKey = "";
|
||||
}
|
||||
|
||||
// {"message":"JTEOP: Missing APP ID found in request","reason":"APPID not found","code":"10001","referenceError":"","status":401}
|
||||
@Data
|
||||
public static class HaiNanResponseInfo<T> {
|
||||
private T data;
|
||||
|
|
@ -37,6 +41,10 @@ public class HaiNanDianXinApi {
|
|||
private String code;
|
||||
private String errMsg;
|
||||
private String resTime;
|
||||
private String message;
|
||||
private String reason;
|
||||
private String referenceError;
|
||||
private String status;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -54,6 +62,48 @@ public class HaiNanDianXinApi {
|
|||
return config.appCode + ";" + abilityCode + ";" + transactionId + ";" + sign + ";" + reqTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 收货地址查询
|
||||
*
|
||||
* @param request 收货地址查询请求参数
|
||||
* @return 收货地址查询返回结果
|
||||
* @throws UnirestException 请求异常
|
||||
*/
|
||||
public static HaiNanResponseInfo<QryReceiveAddrResponse> qryReceiveAddr(final SuperiorApiLogSaveReqVO logVO, HaiNanDianXinApiConfig config, QryReceiveAddrRequest request) throws UnirestException {
|
||||
return doPost(logVO, config, "qryReceiveAddr", request, QryReceiveAddrResponse.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 收货地址查询请求参数类
|
||||
*/
|
||||
@Data
|
||||
public static class QryReceiveAddrRequest {
|
||||
private String addrLevel; // 查询地址等级 (1:省;2:市;3:区县;4:镇/街道)
|
||||
private String parentName; // 上级地址名称(查省级地址时不传值)
|
||||
private String parentCode; // 上级地址编码(查省级地址时不传值)
|
||||
}
|
||||
|
||||
/**
|
||||
* 收货地址查询返回结果类
|
||||
*/
|
||||
@Data
|
||||
public static class QryReceiveAddrResponse {
|
||||
private String code; // 状态编码:0:成功;-1:失败
|
||||
private String errMsg; // 失败原因
|
||||
private List<AddrInfo> addrList; // 收货地址列表
|
||||
private String resTime; // 请求返回时间
|
||||
}
|
||||
|
||||
/**
|
||||
* 收货地址信息类
|
||||
*/
|
||||
@Data
|
||||
public static class AddrInfo {
|
||||
private String addrName; // 地址名称
|
||||
private String addrCode; // 地址编码
|
||||
private String addrLevel; // 地址等级
|
||||
}
|
||||
|
||||
/**
|
||||
* 防诈校验接口查询
|
||||
*
|
||||
|
|
@ -61,8 +111,8 @@ public class HaiNanDianXinApi {
|
|||
* @return 防诈校验返回结果
|
||||
* @throws UnirestException 请求异常
|
||||
*/
|
||||
public static HaiNanResponseInfo<FraudCheckResponse> fraudCheck(final SuperiorApiLogSaveReqVO logVO,HaiNanDianXinApiConfig config, FraudCheckRequest request) throws UnirestException {
|
||||
return doPost( logVO,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -72,8 +122,8 @@ public class HaiNanDianXinApi {
|
|||
* @return 号码查询列表返回结果
|
||||
* @throws UnirestException 请求异常
|
||||
*/
|
||||
public static HaiNanResponseInfo<QryNbrListResponse> qryNbrList(final SuperiorApiLogSaveReqVO logVO,HaiNanDianXinApiConfig config, QryNbrListRequest request) throws UnirestException {
|
||||
return doPost( logVO,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -83,8 +133,8 @@ public class HaiNanDianXinApi {
|
|||
* @return 订单信息查询返回结果
|
||||
* @throws UnirestException 请求异常
|
||||
*/
|
||||
public static HaiNanResponseInfo<QueryOrderInfoResponse> queryOrderInfo(final SuperiorApiLogSaveReqVO logVO,HaiNanDianXinApiConfig config, QueryOrderInfoRequest request) throws UnirestException {
|
||||
return doPost( logVO,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -96,7 +146,7 @@ public class HaiNanDianXinApi {
|
|||
*/
|
||||
public static HaiNanResponseInfo<GetLogisticsTrajectoryResponse> getLogisticsTrajectory(final SuperiorApiLogSaveReqVO logVO,
|
||||
HaiNanDianXinApiConfig config, GetLogisticsTrajectoryRequest request) throws UnirestException {
|
||||
return doPost( logVO,config, "getLogisticsTrajectory", request, GetLogisticsTrajectoryResponse.class);
|
||||
return doPost(logVO, config, "getLogisticsTrajectory", request, GetLogisticsTrajectoryResponse.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -106,8 +156,8 @@ public class HaiNanDianXinApi {
|
|||
* @return 号卡订单收敛返回结果
|
||||
* @throws UnirestException 请求异常
|
||||
*/
|
||||
public static HaiNanResponseInfo<SynOrderInfoResponse> synOrderInfo(final SuperiorApiLogSaveReqVO logVO,HaiNanDianXinApiConfig config, SynOrderInfoRequest request) throws UnirestException {
|
||||
return doPost(logVO,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -129,10 +179,12 @@ public class HaiNanDianXinApi {
|
|||
HttpResponse<String> response = Unirest.post(config.url)
|
||||
.header("Content-Type", "application/json")
|
||||
.header("x-auth", xAuthHeader)
|
||||
.header("X-APP-ID", config.xAppId)
|
||||
.header("X-APP-KEY", config.xAppKey)
|
||||
.body(encryptedBody)
|
||||
.asString();
|
||||
logVO.setResponse(response.getBody());
|
||||
return dealResponse(response, rClass);
|
||||
return dealResponse(config, response, rClass);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -143,7 +195,7 @@ public class HaiNanDianXinApi {
|
|||
* @param <T> 返回结果泛型
|
||||
* @return 返回结果
|
||||
*/
|
||||
private static <T> HaiNanResponseInfo<T> dealResponse(HttpResponse<String> response, Class<T> tClass) {
|
||||
private static <T> HaiNanResponseInfo<T> dealResponse(HaiNanDianXinApiConfig config, HttpResponse<String> response, Class<T> tClass) {
|
||||
// int status = response.getStatus();
|
||||
// if (status != 200) {
|
||||
// return null;
|
||||
|
|
@ -154,9 +206,9 @@ public class HaiNanDianXinApi {
|
|||
});
|
||||
String biz = haiNanResponseInfo.getBiz();
|
||||
if (StringUtils.isNotEmpty(biz)) {
|
||||
String bizDecrypt = UopRSAUtils.decryptByPrivateKey(body, biz);
|
||||
String bizDecrypt = UopRSAUtils.decryptByPrivateKey(biz, config.getPrivateKey());
|
||||
// T t = JSON.parseObject(bizDecrypt, tClass);
|
||||
T t = JSON.parseObject(body, new TypeReference<T>() {
|
||||
T t = JSON.parseObject(bizDecrypt, new TypeReference<T>() {
|
||||
});
|
||||
haiNanResponseInfo.setData(t);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@PermitAll
|
||||
@Tag(name = "API---上游接口---海南电信")
|
||||
@RestController
|
||||
@RequestMapping("/haoka/api/hainan-dx")
|
||||
|
|
@ -23,6 +24,14 @@ public class HaokaApiHaiNanDXController {
|
|||
@Resource
|
||||
private ApiHaiNanDXService apiHaiNanDXService;
|
||||
|
||||
@PermitAll
|
||||
@PostMapping("/qryReceiveAddr")
|
||||
@Operation(summary = "海南电信-收货地址查询接口")
|
||||
public CommonResult<HaiNanDianXinApi.HaiNanResponseInfo<HaiNanDianXinApi.QryReceiveAddrResponse>>
|
||||
qryReceiveAddr(@RequestBody HaiNanDianXinApi.QryReceiveAddrRequest param) throws UnirestException {
|
||||
return success(apiHaiNanDXService.qryReceiveAddr(new SuperiorApiLogSaveReqVO(), param));
|
||||
}
|
||||
|
||||
@PermitAll
|
||||
@PostMapping("/qryNbrList")
|
||||
@Operation(summary = "海南电信-选号接口")
|
||||
|
|
@ -31,6 +40,7 @@ public class HaokaApiHaiNanDXController {
|
|||
return success(apiHaiNanDXService.qryNbrList(new SuperiorApiLogSaveReqVO(), param));
|
||||
}
|
||||
|
||||
@PermitAll
|
||||
@PostMapping("/fraudCheck")
|
||||
@Operation(summary = "海南电信-防诈校验接口")
|
||||
public CommonResult<HaiNanDianXinApi.HaiNanResponseInfo<HaiNanDianXinApi.FraudCheckResponse>>
|
||||
|
|
@ -38,6 +48,7 @@ public class HaokaApiHaiNanDXController {
|
|||
return success(apiHaiNanDXService.fraudCheck(new SuperiorApiLogSaveReqVO(), param));
|
||||
}
|
||||
|
||||
@PermitAll
|
||||
@PostMapping("/queryOrderInfo")
|
||||
@Operation(summary = "海南电信-订单信息查询接口")
|
||||
public CommonResult<HaiNanDianXinApi.HaiNanResponseInfo<HaiNanDianXinApi.QueryOrderInfoResponse>>
|
||||
|
|
@ -45,6 +56,7 @@ public class HaokaApiHaiNanDXController {
|
|||
return success(apiHaiNanDXService.queryOrderInfo(new SuperiorApiLogSaveReqVO(), param));
|
||||
}
|
||||
|
||||
@PermitAll
|
||||
@PostMapping("/getLogisticsTrajectory")
|
||||
@Operation(summary = "海南电信-物流轨迹查询接口")
|
||||
public CommonResult<HaiNanDianXinApi.HaiNanResponseInfo<HaiNanDianXinApi.GetLogisticsTrajectoryResponse>>
|
||||
|
|
@ -52,6 +64,7 @@ public class HaokaApiHaiNanDXController {
|
|||
return success(apiHaiNanDXService.getLogisticsTrajectory(new SuperiorApiLogSaveReqVO(), param));
|
||||
}
|
||||
|
||||
@PermitAll
|
||||
@PostMapping("/synOrderInfo")
|
||||
@Operation(summary = "海南电信-号卡订单收敛接口")
|
||||
public CommonResult<HaiNanDianXinApi.HaiNanResponseInfo<HaiNanDianXinApi.SynOrderInfoResponse>>
|
||||
|
|
|
|||
Loading…
Reference in New Issue