wks 2 лет назад
Родитель
Сommit
d11df1bee3

+ 24 - 14
src/main/java/com/ydtech/modules/order/components/bohai/BoHaiRequestApiComponent.java

@@ -54,28 +54,30 @@ public class BoHaiRequestApiComponent {
     private <Q extends BoHaiBaseRequest, S extends BoHaiBaseResponse> S post(Q q, String url, Class<S> tClass) throws Exception {
         HttpHeaders httpHeaders = new HttpHeaders();
         httpHeaders.setContentType(MediaType.APPLICATION_JSON);
+
         String busReqString = JSON.toJSONString(q, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
         InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> URl: {} \n---------> 请求参数:{}", url, busReqString);
-
         BoHaiEncrypted boHaiEncrypted = new BoHaiEncrypted(busReqString, properties);
         String json = JSON.toJSONString(boHaiEncrypted, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
-
-        // 获取请求头
+        // 获取请求头signature 和加密后的内容
         Map<String, String> stringStringMap = SignatureUtils.encryptAndSign(properties.getSelfPrivateKey(),
                 properties.getBoHaiPublicKey(), json, true, true);
         String signature = stringStringMap.get("signature");
         String content = stringStringMap.get("content");
         httpHeaders.set("signature", signature);
-        InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> 加密后的参数:{}", content);
-        InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> 加密后的参数:{}", signature);
-
+        InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> 加密后的参数:{} \n\t---------> 请求头内容signature:{}", content,
+                signature);
+        // 请求
         HttpEntity<String> httpEntity = new HttpEntity<>(content, httpHeaders);
-        //----加密endding------------
         ResponseEntity<String> response = restTemplate.postForEntity(url, httpEntity, String.class);
         String body = response.getBody();
         InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> 解密前的参数:{}", body);
 
-        return null;
+        // 解密响应
+        BoHaiEncrypted encrypted = JSON.parseObject(body).toJavaObject(BoHaiEncrypted.class);
+        String info = SignatureUtils.decryptByPrivateKey(encrypted.getBizContent(), properties.getSelfPrivateKey());
+        InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> 解密后的参数:{}", info);
+        return JSON.parseObject(body).toJavaObject(tClass);
     }
 
 
@@ -84,22 +86,30 @@ public class BoHaiRequestApiComponent {
      *
      * @param request 生成订单号请求实体
      * @return 返回订单号响应
-     * @throws Exception
      */
     public GenerateOrderNoResponse generateOrderNo(GenerateOrderNoRequest request) throws Exception {
         return post(request, properties.getUrl(), GenerateOrderNoResponse.class);
     }
 
-    public VehicleTypeQueryResponse vehicleTypeQuery(VehicleTypeQueryRequest request) throws Exception{
+    /**
+     * 车辆查询
+     *
+     * @param request 车辆查询请求实体
+     * @return 响应
+     */
+    public VehicleTypeQueryResponse vehicleTypeQuery(VehicleTypeQueryRequest request) throws Exception {
         return post(request, properties.getUrl(), VehicleTypeQueryResponse.class);
     }
 
-    public VehicleConfirmationResponse vehicleConfirmation(VehicleConfirmationReqeust request) throws Exception{
+    /**
+     * 车辆确认
+     *
+     * @param request 车辆确认 请求实体
+     * @return 响应
+     */
+    public VehicleConfirmationResponse vehicleConfirmation(VehicleConfirmationReqeust request) throws Exception {
         return post(request, properties.getUrl(), VehicleConfirmationResponse.class);
     }
 
 
-
-
-
 }

+ 29 - 10
src/main/java/com/ydtech/modules/order/entity/api/bohai/request/VehicleConfirmationReqeust.java

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
 import com.ydtech.modules.ins.model.vo.CarInfoVo;
 import com.ydtech.modules.ins.model.vo.CustomerInfoVo;
 import com.ydtech.modules.order.entity.api.bohai.constants.*;
+import com.ydtech.modules.order.entity.api.bohai.response.VehicleTypeQueryResponse;
 import com.ydtech.modules.order.entity.config.BoHaiConfigureParameters;
 import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
 import com.ydtech.utils.StringUtils;
@@ -39,11 +40,13 @@ public class VehicleConfirmationReqeust extends BoHaiBaseRequest {
     private InsurederDTO insureder;
 
 
-   public VehicleConfirmationReqeust(BoHaiConfigureParameters parameters, BaseQuoteInfoVo quoteInfoVo) {
-        this.setBaseParam(parameters, RequestType.Z00005.getCode());
+   public VehicleConfirmationReqeust(BoHaiConfigureParameters parameters, BaseQuoteInfoVo quoteInfoVo,
+                                     VehicleTypeQueryResponse.DataDTO.VehicleModelsDTO vehicleModelsDTO,
+                                     String orderNo) {
+        this.setBaseParam(parameters, RequestType.Z00005.getCode(), orderNo);
         // 车辆信息
         CarInfoVo carInfo = quoteInfoVo.getCarInfo();
-        this.vehicle = new VehicleDTO(carInfo);
+        this.vehicle = new VehicleDTO(carInfo, vehicleModelsDTO);
         // 车主
         CustomerInfoVo ownerInfo = quoteInfoVo.getOwnerInfo();
         this.carOwner = new CarOwnerDTO(ownerInfo);
@@ -180,22 +183,21 @@ public class VehicleConfirmationReqeust extends BoHaiBaseRequest {
         @JsonProperty("transferDate")
         private String transferDate;
 
-        public VehicleDTO(CarInfoVo carInfo) {
+        public VehicleDTO(CarInfoVo carInfo, VehicleTypeQueryResponse.DataDTO.VehicleModelsDTO vehicleModelsDTO) {
             this.carVin = carInfo.getVinNo();
-            this.vehicleModelCode = vehicleModelCode;
+            this.vehicleModelCode = vehicleModelsDTO.getMoldCharacterCode();
             this.engineNo = carInfo.getEngineNo();
             this.plateNo = carInfo.getLicenseNo();
             this.registerDate = carInfo.getRegisterDate();
-            this.purchasePrice = purchasePrice;
+            this.purchasePrice = vehicleModelsDTO.getPurchasePrice();
             // 新车
             this.newVehicleFlag = StringUtils.isNotEmpty(carInfo.getLicenseNo()) ? "0" : "1";
-            this.moldName = moldName;
+            this.moldName = vehicleModelsDTO.getMoldName();
             this.seatCount = carInfo.getSeatCount();
             this.tonNumber = carInfo.getLimitLoad();
             this.fuelType = carInfo.getEnergyType();
             this.emptyWeight = carInfo.getCompleteKerbMass();
-            this.exhaustMeasure = exhaustMeasure;
-
+            this.exhaustMeasure = vehicleModelsDTO.getExhaustMeasure();
             VehicleKind vehicleKindEnum = VehicleKind.valueOf(carInfo.getCimodelclass());
             this.vehicleKind = vehicleKindEnum.getCode();
             this.vehicleAffNature = VehicleAffNature.VAN_1.getCode();
@@ -286,8 +288,25 @@ public class VehicleConfirmationReqeust extends BoHaiBaseRequest {
         @JsonProperty("elecApplicationFlag")
         private String elecApplicationFlag;
 
-        public HolderDTO(CustomerInfoVo policyHolderInfo) {
 
+
+        public HolderDTO(CustomerInfoVo policyHolderInfo) {
+            this.certType = certType;
+            this.holderName = policyHolderInfo.getName();
+
+            this.certNo = certNo;
+            this.address = address;
+            this.phoneNumber = phoneNumber;
+            this.nation = nation;
+            this.certiStartDate = certiStartDate;
+            this.certiEndDate = certiEndDate;
+            this.certiType = certiType;
+            this.issuer = issuer;
+            this.email = email;
+            this.invoiceType = "";
+            this.bizFormatType = bizFormatType;
+            this.forceFormatType = forceFormatType;
+            this.elecApplicationFlag = elecApplicationFlag;
         }
     }
 

+ 3 - 3
src/main/java/com/ydtech/modules/order/entity/api/bohai/request/VehicleTypeQueryRequest.java

@@ -50,9 +50,9 @@ public class VehicleTypeQueryRequest extends BoHaiBaseRequest {
     @JsonProperty("newVehicleFlag")
     private String newVehicleFlag;
 
-    public VehicleTypeQueryRequest(BoHaiConfigureParameters parameters, String vehicleBrandModelKey) {
-        this.setBaseParam(parameters, RequestType.Z00004.getCode());
+    public VehicleTypeQueryRequest(BoHaiConfigureParameters parameters, String vehicleBrandModelKey, String orderNo) {
+        this.setBaseParam(parameters, RequestType.Z00004.getCode(), orderNo);
         this.vehicleBrandModelKey = vehicleBrandModelKey;
     }
-    
+
 }

+ 2 - 1
src/main/java/com/ydtech/modules/order/entity/api/bohai/response/VehicleTypeQueryResponse.java

@@ -76,7 +76,8 @@ public class VehicleTypeQueryResponse extends BoHaiBaseResponse {
             @JsonProperty("yearPattern")
             private String yearPattern;
 
-
+            @JsonProperty("exhaustMeasure")
+            private String exhaustMeasure;
             @Override
             public String getPurchasePrice() {
                 return purchasePrice;

+ 14 - 9
src/main/java/com/ydtech/modules/order/service/impl/BoHaiOrderApiServiceImpl.java

@@ -13,11 +13,9 @@ import com.ydtech.modules.order.entity.api.bohai.response.VehicleConfirmationRes
 import com.ydtech.modules.order.entity.api.bohai.response.VehicleTypeQueryResponse;
 import com.ydtech.modules.order.entity.api.zijin.request.PaymentCallbacksRequest;
 import com.ydtech.modules.order.entity.api.zijin.request.SubmitVerifyRequest;
-import com.ydtech.modules.order.entity.api.zijin.response.ModelQueryResponse;
 import com.ydtech.modules.order.entity.api.zijin.response.QueryClauseDataResponse;
 import com.ydtech.modules.order.entity.api.zijin.response.QueryVehicProductsResponse;
 import com.ydtech.modules.order.entity.config.BoHaiConfigureParameters;
-import com.ydtech.modules.order.entity.config.HuaTaiConfigureParameters;
 import com.ydtech.modules.order.entity.filter.CarModelsFilterUtils;
 import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
 import com.ydtech.modules.order.entity.vo.BaseQuoteVo;
@@ -46,28 +44,35 @@ public class BoHaiOrderApiServiceImpl implements BoHaiOrderApiService {
 
     @Override
     public HttpResult<QuoteRespVo> quote(BaseQuoteInfoVo quoteInfoVo, BaseQuoteVo<List<ZjQuoteAccidentVo>> quoteVo) {
-        // 1. 协议id获取配置实体
+        // 协议id获取配置实体
         String agreementId = quoteVo.getAgreementId();
         // 账号信息
         PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(agreementId);
         // 通过 协议id获取配置实体
-        BoHaiConfigureParameters parameters = configureParametersComponents.toEntity(BoHaiConfigureParameters.class, ptlAgreementAttribution);
+        BoHaiConfigureParameters parameters = configureParametersComponents.toEntity(BoHaiConfigureParameters.class,
+                ptlAgreementAttribution);
         GenerateOrderNoRequest generateOrderNoRequest = new GenerateOrderNoRequest(parameters);
         try {
+            // 1 生成生成订单
             GenerateOrderNoResponse generateOrderNoResponse = boHaiRequestApiComponent.generateOrderNo(generateOrderNoRequest);
+            String orderNo = generateOrderNoResponse.getData().getOrderNo();
 
             // 2 车型查询接口
             CarInfoVo carInfo = quoteInfoVo.getCarInfo();
-            VehicleTypeQueryRequest vehicleTypeQueryRequest = new VehicleTypeQueryRequest(parameters, carInfo.getModelcname());
+            VehicleTypeQueryRequest vehicleTypeQueryRequest = new VehicleTypeQueryRequest(parameters, carInfo.getModelcname(), orderNo);
             VehicleTypeQueryResponse vehicleTypeQueryResponse = boHaiRequestApiComponent.vehicleTypeQuery(vehicleTypeQueryRequest);
             List<VehicleTypeQueryResponse.DataDTO.VehicleModelsDTO> vehicleModels = vehicleTypeQueryResponse.getData().getVehicleModels();
-            VehicleTypeQueryResponse.DataDTO.VehicleModelsDTO vehicleModelsDTO = new CarModelsFilterUtils<VehicleTypeQueryResponse.DataDTO.VehicleModelsDTO>().to(vehicleModels,
-                    quoteInfoVo.getCarInfo());
+            VehicleTypeQueryResponse.DataDTO.VehicleModelsDTO vehicleModelsDTO =
+                    new CarModelsFilterUtils<VehicleTypeQueryResponse.DataDTO.VehicleModelsDTO>().to(vehicleModels,
+                            quoteInfoVo.getCarInfo());
 
             // 3 车辆确认接口
-            VehicleConfirmationReqeust vehicleConfirmationReqeust = new VehicleConfirmationReqeust(parameters, quoteInfoVo);
-            VehicleConfirmationResponse vehicleConfirmationResponse = boHaiRequestApiComponent.vehicleConfirmation(vehicleConfirmationReqeust);
+            VehicleConfirmationReqeust vehicleConfirmationReqeust = new VehicleConfirmationReqeust(parameters, quoteInfoVo,
+                    vehicleModelsDTO, orderNo);
+            VehicleConfirmationResponse vehicleConfirmationResponse =
+                    boHaiRequestApiComponent.vehicleConfirmation(vehicleConfirmationReqeust);
 
+            // 4. 报价接口