|
|
@@ -5,8 +5,10 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.anji.captcha.util.MD5Util;
|
|
|
import com.yc.ship.framework.common.pojo.CommonResult;
|
|
|
import com.yc.ship.framework.common.util.http.HttpUtils;
|
|
|
+import com.yc.ship.module.infra.api.config.ConfigApi;
|
|
|
import com.yc.ship.module.trade.api.insurance.dto.InsuranceApplyReqDTO;
|
|
|
import com.yc.ship.module.trade.api.insurance.dto.InsuranceCancelReqDTO;
|
|
|
+import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.http.*;
|
|
|
@@ -15,6 +17,8 @@ import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.HashMap;
|
|
|
@@ -30,20 +34,23 @@ import static com.yc.ship.framework.common.exception.util.ServiceExceptionUtil.e
|
|
|
@Component
|
|
|
public class InsuranceUtil {
|
|
|
|
|
|
- public final String HOST = "https://lbb-admin.anyitech.ltd"; //测试域名
|
|
|
-
|
|
|
- public final String VALIDATE_URL = "/policy/validateJson.do"; // 请求校验接口
|
|
|
-
|
|
|
- public final String RECEIVE_URL = "/policy/receiveJson.do"; // JSON投/退保接口
|
|
|
-
|
|
|
- public final String QUERY_URL = "/policy/querystatus.do"; // 保单状态查询接口
|
|
|
-
|
|
|
- public final String APPID = "123456"; // appId
|
|
|
-
|
|
|
- public final String KEY = "goldpalm"; // key
|
|
|
+// public final String HOST = "https://lbb-admin.anyitech.ltd"; //测试域名
|
|
|
+//
|
|
|
+// public final String VALIDATE_URL = "/policy/validateJson.do"; // 请求校验接口
|
|
|
+//
|
|
|
+// public final String RECEIVE_URL = "/policy/receiveJson.do"; // JSON投/退保接口
|
|
|
+//
|
|
|
+// public final String QUERY_URL = "/policy/querystatus.do"; // 保单状态查询接口
|
|
|
+//
|
|
|
+// public final String APPID = "123456"; // appId
|
|
|
+//
|
|
|
+// public final String KEY = "goldpalm"; // key
|
|
|
|
|
|
private final Integer VALIDATE_LEVEL = 0; //校验级别,其值有 0/1
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ConfigApi configApi;
|
|
|
+
|
|
|
/**
|
|
|
* REST模板
|
|
|
*/
|
|
|
@@ -57,6 +64,7 @@ public class InsuranceUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 发送投保请求
|
|
|
* 将投保请求发送到阳光系统
|
|
|
@@ -65,6 +73,11 @@ public class InsuranceUtil {
|
|
|
* @return 投保响应
|
|
|
*/
|
|
|
public CommonResult sendInsuranceApply(InsuranceApplyReqDTO request) {
|
|
|
+ String HOST = configApi.getConfigValueByKey("insuranceConfig.host");
|
|
|
+ String RECEIVE_URL = configApi.getConfigValueByKey("insuranceConfig.receive_url");
|
|
|
+ String VALIDATE_URL = configApi.getConfigValueByKey("insuranceConfig.validate_url");
|
|
|
+ String APPID = configApi.getConfigValueByKey("insuranceConfig.app_id");
|
|
|
+ String KEY = configApi.getConfigValueByKey("insuranceConfig.key");
|
|
|
try {
|
|
|
String reqJson = JSONObject.toJSONString(request);
|
|
|
String sign = SignUtil.generateMD5Sign(APPID, reqJson, KEY);
|
|
|
@@ -132,6 +145,10 @@ public class InsuranceUtil {
|
|
|
* @return 校验响应
|
|
|
*/
|
|
|
public CommonResult validateInsuranceRequest(InsuranceApplyReqDTO request) {
|
|
|
+ String HOST = configApi.getConfigValueByKey("insuranceConfig.host");
|
|
|
+ String VALIDATE_URL = configApi.getConfigValueByKey("insuranceConfig.validate_url");
|
|
|
+ String APPID = configApi.getConfigValueByKey("insuranceConfig.app_id");
|
|
|
+ String KEY = configApi.getConfigValueByKey("insuranceConfig.key");
|
|
|
try {
|
|
|
String reqJson = JSONObject.toJSONString(request);
|
|
|
|
|
|
@@ -203,6 +220,10 @@ public class InsuranceUtil {
|
|
|
* @return 退保响应
|
|
|
*/
|
|
|
public CommonResult sendInsuranceCancel(InsuranceCancelReqDTO request) {
|
|
|
+ String HOST = configApi.getConfigValueByKey("insuranceConfig.host");
|
|
|
+ String RECEIVE_URL = configApi.getConfigValueByKey("insuranceConfig.receive_url");
|
|
|
+ String APPID = configApi.getConfigValueByKey("insuranceConfig.app_id");
|
|
|
+ String KEY = configApi.getConfigValueByKey("insuranceConfig.key");
|
|
|
try {
|
|
|
String reqJson = JSONObject.toJSONString(request);
|
|
|
String sign = SignUtil.generateMD5Sign(APPID, reqJson, KEY);
|
|
|
@@ -250,6 +271,10 @@ public class InsuranceUtil {
|
|
|
}
|
|
|
|
|
|
public CommonResult queryInsurance(String orderNo) {
|
|
|
+ String QUERY_URL = configApi.getConfigValueByKey("insuranceConfig.query_url");
|
|
|
+ String HOST = configApi.getConfigValueByKey("insuranceConfig.host");
|
|
|
+ String APPID = configApi.getConfigValueByKey("insuranceConfig.app_id");
|
|
|
+ String KEY = configApi.getConfigValueByKey("insuranceConfig.key");
|
|
|
try {
|
|
|
if(StringUtils.isBlank(orderNo)) {
|
|
|
return CommonResult.error(500, "订单号不能为空");
|
|
|
@@ -281,6 +306,10 @@ public class InsuranceUtil {
|
|
|
}
|
|
|
|
|
|
public CommonResult queryInsuranceNew(String orderNo,Long orderId) {
|
|
|
+ String QUERY_URL = configApi.getConfigValueByKey("insuranceConfig.query_url");
|
|
|
+ String HOST = configApi.getConfigValueByKey("insuranceConfig.host");
|
|
|
+ String APPID = configApi.getConfigValueByKey("insuranceConfig.app_id");
|
|
|
+ String KEY = configApi.getConfigValueByKey("insuranceConfig.key");
|
|
|
try {
|
|
|
if(StringUtils.isBlank(orderNo)) {
|
|
|
return CommonResult.error(500, "订单号不能为空");
|