|
|
@@ -1,16 +1,82 @@
|
|
|
package com.ydtech.modules.order.components.pingan;
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
+import com.ydtech.config.properties.PingAnApiConfigurationProperties;
|
|
|
+import com.ydtech.constants.InsuranceEnum;
|
|
|
+import com.ydtech.modules.order.entity.api.bohai.BoHaiEncrypted;
|
|
|
+import com.ydtech.modules.order.entity.api.bohai.constants.RequestType;
|
|
|
+import com.ydtech.modules.order.entity.api.bohai.request.BoHaiBaseRequest;
|
|
|
+import com.ydtech.modules.order.entity.api.bohai.response.BoHaiBaseResponse;
|
|
|
+import com.ydtech.modules.order.entity.api.pingan.constants.RequestUrl;
|
|
|
+import com.ydtech.modules.order.entity.api.pingan.request.PingAnBaseRequest;
|
|
|
+import com.ydtech.modules.order.entity.api.pingan.response.PingAnBaseResponse;
|
|
|
+import com.ydtech.modules.order.entity.config.PingAnConfigureParameters;
|
|
|
+import com.ydtech.modules.order.utils.InsuranceLog;
|
|
|
+import com.ydtech.modules.order.utils.PingAnRSAUtils;
|
|
|
+import com.ydtech.modules.order.utils.SignatureUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
@Component
|
|
|
@RequiredArgsConstructor
|
|
|
public class PinganRequestApiComponents {
|
|
|
|
|
|
private final RestTemplate restTemplate;
|
|
|
|
|
|
+ private final PingAnApiConfigurationProperties properties;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 加密请求
|
|
|
+ *
|
|
|
+ * @param q 请求参数
|
|
|
+ * @param url 请求url
|
|
|
+ * @param tClass 响应类型
|
|
|
+ * @param <Q> Request 请求体
|
|
|
+ * @param <S> Response 响应体
|
|
|
+ * @return <S>
|
|
|
+ */
|
|
|
+// private <Q extends PingAnBaseRequest, S extends PingAnBaseResponse> S post(Q q, String url, Class<S> tClass, String sysSourceCode,
|
|
|
+// RequestUrl requestUrl) throws Exception {
|
|
|
+//
|
|
|
+// HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
+// httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
+// String busReqString = JSON.toJSONString(q, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
|
|
+// InsuranceLog.infoLog(InsuranceEnum.PAIC.getPinyin(), "\n\t---------> {} \n\t---------> URl: {} \n\t---------> 请求参数:{}",
|
|
|
+// requestUrl.getDesc(), url, busReqString);
|
|
|
+//
|
|
|
+// JSONObject jsonObject = (JSONObject) JSON.toJSON(q);
|
|
|
+//
|
|
|
+// // TODO
|
|
|
+// String signature = PingAnRSAUtils.sortParametersWithASCII(jsonObject);
|
|
|
+// String signData = PingAnRSAUtils.sign(signature, properties.getSelfPrivateKey());
|
|
|
+//
|
|
|
+// InsuranceLog.infoLog(InsuranceEnum.PAIC.getPinyin(), "\n\t---------> {} \n\t---------> 加密后的参数:{} \n\t---------> " +
|
|
|
+// "请求头内容signature:{}", requestUrl.getDesc(), signData, signature);
|
|
|
+//
|
|
|
+// // 请求
|
|
|
+// HttpEntity<String> httpEntity = new HttpEntity<>(signData, httpHeaders);
|
|
|
+// ResponseEntity<String> response = restTemplate.postForEntity(url, httpEntity, String.class);
|
|
|
+//
|
|
|
+// String body = response.getBody();
|
|
|
+// InsuranceLog.infoLog(InsuranceEnum.PAIC.getPinyin(), "\n\t---------> {} \n\t---------> 解密前的参数:{}", requestUrl.getDesc(), body);
|
|
|
+//
|
|
|
+// // 解密响应
|
|
|
+// BoHaiEncrypted encrypted = JSON.parseObject(body).toJavaObject(BoHaiEncrypted.class);
|
|
|
+// String info = SignatureUtils.decryptByPrivateKey(encrypted.getBizContent(), properties.getSelfPrivateKey());
|
|
|
+// InsuranceLog.infoLog(InsuranceEnum.PAIC.getPinyin(), "\n\t---------> {} \n\t---------> 解密后的参数:{}", requestUrl.getDesc(), info);
|
|
|
+// return JSON.parseObject(info).toJavaObject(tClass);
|
|
|
+// }
|
|
|
+
|
|
|
|
|
|
|
|
|
|