Przeglądaj źródła

阳光处理企业车参数

Qchen 1 rok temu
rodzic
commit
2a8abc536a

+ 19 - 8
src/main/java/com/ydtech/modules/order/entity/api/yangguang/request/YangGuangAccuracyCalculateRequest.java

@@ -393,10 +393,7 @@ public class YangGuangAccuracyCalculateRequest extends YangGuangBaseRequest{
         private String IdentifyUseFullife;
 
         public InsuredListDTO(CustomerInfoVo policyHolderInfo, String insuredFlag) {
-            this.InsuredType = "1";
             this.InsuredFlag = insuredFlag;
-            this.IdentifyType = "01";
-            this.IdentifyNumber = policyHolderInfo.getIdentifyNumber();
             this.Name = policyHolderInfo.getName();
             this.Mobile = policyHolderInfo.getMobile();
             this.PostAddress = policyHolderInfo.getAddr();
@@ -404,6 +401,19 @@ public class YangGuangAccuracyCalculateRequest extends YangGuangBaseRequest{
             this.Gender = sex == 1 ? "1" : "2";
             this.IdentifyUseFullifeStart = policyHolderInfo.getIdentifyValidDate();
             this.IdentifyUseFullife = policyHolderInfo.getIdentifyValidEndDate();
+            if (policyHolderInfo.getProperty() != null && policyHolderInfo.getProperty().equals("1")) {
+                this.InsuredType = "1";
+                this.IdentifyType = "01";
+                this.IdentifyNumber = policyHolderInfo.getIdentifyNumber();
+            } else if (policyHolderInfo.getProperty() != null && policyHolderInfo.getProperty().equals("2")) {
+                this.IdentifyType = "09";
+                this.InsuredType = "2";
+                this.IdentifyNumber = policyHolderInfo.getOrganizationCode();
+            } else if (policyHolderInfo.getProperty() != null && policyHolderInfo.getProperty().equals("3")) {
+                this.InsuredType = "2";
+                this.IdentifyType = "99";
+                this.IdentifyNumber = policyHolderInfo.getOrganizationCode();
+            }
         }
 
         public static List<YangGuangAccuracyCalculateRequest.InsuredListDTO> toInsuredListDTOList(CustomerInfoVo policyHolderInfo, CustomerInfoVo insuredPersonInfo) {
@@ -488,21 +498,22 @@ public class YangGuangAccuracyCalculateRequest extends YangGuangBaseRequest{
             this.Name = customerInfoVo.getName();
             this.Mobile = customerInfoVo.getMobile();
             this.OwnerAdress = customerInfoVo.getAddr();
-            this.IdentifyNumber = customerInfoVo.getIdentifyNumber();
-            if (carInfoVo.getProperty() != null && carInfoVo.getProperty().equals("1")) {
+            if (customerInfoVo.getProperty() != null && customerInfoVo.getProperty().equals("1")) {
                 this.InsuredType = "0";
                 this.IdentifyType = "01";
                 this.CarInsuredRelation = "1";
-            } else if (carInfoVo.getProperty() != null && carInfoVo.getProperty().equals("2")) {
+                this.IdentifyNumber = customerInfoVo.getIdentifyNumber();
+            } else if (customerInfoVo.getProperty() != null && customerInfoVo.getProperty().equals("2")) {
                 this.IdentifyType = "09";
                 this.InsuredType = "2";
                 this.CarInsuredRelation = "1";
-            } else if (carInfoVo.getProperty() != null && carInfoVo.getProperty().equals("3")) {
+                this.IdentifyNumber = customerInfoVo.getOrganizationCode();
+            } else if (customerInfoVo.getProperty() != null && customerInfoVo.getProperty().equals("3")) {
                 this.InsuredType = "1";
                 this.IdentifyType = "99";
                 this.CarInsuredRelation = "3";
+                this.IdentifyNumber = customerInfoVo.getOrganizationCode();
             }
-
         }
     }
 

+ 48 - 4
src/main/java/com/ydtech/modules/order/entity/api/yangguang/request/YangGuangSubmitRequest.java

@@ -1,6 +1,7 @@
 package com.ydtech.modules.order.entity.api.yangguang.request;
 
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
 import com.alibaba.fastjson.annotation.JSONField;
 import com.ydtech.modules.order.entity.InsAreaCompany;
@@ -13,6 +14,7 @@ import lombok.NoArgsConstructor;
 import java.io.Serializable;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -115,7 +117,7 @@ public class YangGuangSubmitRequest extends YangGuangBaseRequest{
      *  团车专票信息
      */
     @JSONField(name = "customerList")
-    private CustomerList customerList;
+    private List<CustomerList> customerList;
     /**
      *  关系人信息
      */
@@ -128,6 +130,11 @@ public class YangGuangSubmitRequest extends YangGuangBaseRequest{
     private List<NonVehicleProductInformationList> NonVehicleProductInformationList;
 
     public YangGuangSubmitRequest(InsOrders insOrders, InsAreaCompany insAreaCompany,String productId, YangGuangConfigureParameters ygConfigureParameters) {
+        //判断是否是企业车 1个人 2企业 3机关
+        String isProperty = insOrders.getCarinfo().getString("property");
+        if (isProperty.equals("2") || isProperty.equals("3")) {
+            this.customerList = YangGuangSubmitRequest.CustomerList.toCustomerList(insOrders);
+        }
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         this.RequestNo = "submit";
         this.ComCode = ygConfigureParameters.getComCode();
@@ -142,7 +149,7 @@ public class YangGuangSubmitRequest extends YangGuangBaseRequest{
             this.PolicyType = "3";
         }
         if (insAreaCompany.getAccidentInfo() != null) {
-            this.NonVehicleProductInformationList =JSONArray.parseObject(insAreaCompany.getAccidentInfo().toJSONString(), new TypeReference<List<NonVehicleProductInformationList>>(){});
+            this.NonVehicleProductInformationList = JSONArray.parseObject(insAreaCompany.getAccidentInfo().toJSONString(), new TypeReference<List<NonVehicleProductInformationList>>(){});
             this.CasualtyFlag = "1";
         } else {
             this.CasualtyFlag = "0";
@@ -210,14 +217,14 @@ public class YangGuangSubmitRequest extends YangGuangBaseRequest{
         private String InsuredFlag;
 
         /**
-         * 纳税人类型
+         * 纳税人类型  1. 小规模纳税人 2. 一般纳税人 3. 其他类型
          */
         @JSONField(name = "Taxpayertype")
         private String Taxpayertype;
 
         /**
          * 是否开增值税发票
-         *  0否1是
+         *  0否 1是
          */
         @JSONField(name = "Vatinvoiceflag")
         private String Vatinvoiceflag;
@@ -232,6 +239,43 @@ public class YangGuangSubmitRequest extends YangGuangBaseRequest{
          */
         @JSONField(name = "Revenueaddress")
         private String Revenueaddress;
+
+         public CustomerList(InsOrders insOrders,boolean flag) {
+            String addrapply= insOrders.getApplyinfo().getString("addr");
+            String addrinsurer = insOrders.getInsureinfo().getString("addr");
+             if (flag) {
+                    this.customerFlag = "1";
+                    this.Taxpayertype = "2";
+                    this.Vatinvoiceflag = "0";
+                    this.Revenueaddress = addrapply;
+                    this.InsuredFlag = "2";
+             }
+             if (!flag) {
+                    this.customerFlag = "0";
+                    this.Taxpayertype = "2";
+                    this.Vatinvoiceflag = "0";
+                    this.Revenueaddress = addrinsurer;
+                    this.InsuredFlag = "1";
+             }
+        }
+        public static List<YangGuangSubmitRequest.CustomerList> toCustomerList(InsOrders insOrders) {
+            List<YangGuangSubmitRequest.CustomerList> customerLists = new ArrayList<>();
+            YangGuangSubmitRequest.CustomerList customer;
+            String applyinfo = insOrders.getApplyinfo().getString("insuranceHolder");
+            String insurerinfo = insOrders.getInsureinfo().getString("insuranceHolder");
+                // 投被保人一致
+            if (applyinfo != null && applyinfo.equals(insurerinfo)) {
+                customer = new YangGuangSubmitRequest.CustomerList(insOrders,true);
+                customerLists.add(customer);
+            } else {
+                // 投被保人不一致
+                YangGuangSubmitRequest.CustomerList policyHolder = new YangGuangSubmitRequest.CustomerList(insOrders,true);
+                YangGuangSubmitRequest.CustomerList insuredPerson = new YangGuangSubmitRequest.CustomerList(insOrders,false);
+                customerLists.add(policyHolder);
+                customerLists.add(insuredPerson);
+            }
+            return customerLists;
+        }
     }
 
     @Data

+ 20 - 0
src/main/java/com/ydtech/modules/order/entity/api/yangguang/response/YangGuangBaseResponse.java

@@ -1,6 +1,8 @@
 package com.ydtech.modules.order.entity.api.yangguang.response;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.Data;
 
 @Data
@@ -17,4 +19,22 @@ public class YangGuangBaseResponse {
 
     @JsonProperty("ResponseDate")
     private String ResponseDate;
+
+    public String message(String ErrorMessage) {
+        try {
+            ObjectMapper objectMapper = new ObjectMapper();
+            JsonNode rootNode = objectMapper.readTree(ErrorMessage);
+            JsonNode hintNode = rootNode.get("hint");
+            if (hintNode != null) {
+                JsonNode systemMsgNode = hintNode.get("systemMsg");
+                if (systemMsgNode.isArray() && systemMsgNode.size() > 0) {
+                    JsonNode firstSystemMsg = systemMsgNode.get(0);
+                    return firstSystemMsg.get("info").asText();
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
 }

+ 1 - 1
src/main/java/com/ydtech/modules/order/service/impl/YangGuangOrderApiServiceImpl.java

@@ -309,7 +309,7 @@ public class YangGuangOrderApiServiceImpl implements YangGuangOrderApiService {
         YangGuangSubmitRequest yangGuangSubmitRequest = new YangGuangSubmitRequest(insOrders, insAreaCompany, productid, ygConfigureParameters);
         YangGuangSubmitResponse yangGuangSubmitResponse = yangGuangRequestApiComponents.submit(yangGuangSubmitRequest);
         if (!yangGuangSubmitResponse.getErrorCode().equals("0")) {
-            return HttpResult.error(yangGuangSubmitResponse.getErrorMessage());
+            return HttpResult.error(yangGuangSubmitResponse.message(yangGuangSubmitResponse.getErrorMessage()));
         }
         if (yangGuangSubmitResponse.getCiProposalNo() != null) {
             insAreaCompany.setJqapplyno(yangGuangSubmitResponse.getCiProposalNo());