zhangyuewww hace 2 años
padre
commit
a9be140c54

+ 4 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/HyCarCaptainInfo.java

@@ -53,6 +53,10 @@ public class HyCarCaptainInfo extends BaseModel<HyCarCaptainInfo> {
      * 身份证国徽面面附件地址
      */
     private String cardBackAddressUrl;
+    /**
+     * 自拍照片
+     */
+    private String selfPhoto;
     /**
      * 姓名
      */

+ 4 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/HyDriverInfo.java

@@ -77,6 +77,10 @@ public class HyDriverInfo extends BaseModel<HyDriverInfo> {
      * 通讯地址
      */
     private String postalAddress;
+    /**
+     * 自拍照片
+     */
+    private String selfPhoto;
     /**
      * 司机身份证号码
      */

+ 1 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/exception/YExceptionEnum.java

@@ -59,6 +59,7 @@ public enum YExceptionEnum {
 	FAILED_TO_REPORT("ERROR36", "上报失败!"),
 	FAILED_TO_LOADINGADD("ERROR37", "北斗定位与发货地距离相差较大,请检查北斗设备是否正常!"),
 	FAILED_TO_LOADINGA("ERROR38", "获取北斗位置异常!"),
+	REPORT_FAILED("ERROR39", "上报失败!"),
 	;
 	@Getter
 	private String value;

+ 37 - 6
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/OrderInfoServiceImpl.java

@@ -1493,7 +1493,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
+//    @Transactional(rollbackFor = Exception.class)
     public String tripartiteReport(OrderInfo orderInfo) throws Exception {
         if ("3".equals(ENV)) {
             if (CollectionUtils.isNotEmpty(orderInfo.getOrderInfoList())) {
@@ -1521,7 +1521,12 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
                                 String result = UplodeUtil.uploadCustomer(hyCompanyInfo);
                                 JSONObject jsonObject = JSONObject.fromObject(result);
                                 if (!"00000".equals(jsonObject.getString("code"))) {
-                                    throw new RuntimeException(jsonObject.getString("message"));
+                                    //更改上报状态
+                                    orderInfo1.setTripartiteStatusKey(StatusEnum.TRIPARTITE_FAIL.getFlag());
+                                    orderInfo1.setTripartiteStatus(StatusEnum.TRIPARTITE_FAIL.getName());
+                                    orderInfo1.setTripartiteFailureReason(jsonObject.getString("message"));
+                                    orderInfoService.updateById(orderInfo1);
+                                    throw new YException(YExceptionEnum.REPORT_FAILED);
                                 }
                             }
                             //查询托运人名称
@@ -1580,11 +1585,22 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
                         }
                     }
                     try {
+                        //上报承运人信息前实名认证
+                        UplodeUtil.uploadRealName(orderInfo1);
+//                        JSONObject jsonObject5 = JSONObject.fromObject(result5);
+//                        if (!"00000".equals(jsonObject5.getString("code"))) {
+//                            throw new RuntimeException(jsonObject5.getString("message"));
+//                        }
                         //上报运单时上报承运人信息
                         String result1 = UplodeUtil.uploadCarrier(orderInfo1);
                         JSONObject jsonObject1 = JSONObject.fromObject(result1);
                         if (!"00000".equals(jsonObject1.getString("code"))) {
-                            throw new RuntimeException(jsonObject1.getString("message"));
+                            //更改上报状态
+                            orderInfo1.setTripartiteStatusKey(StatusEnum.TRIPARTITE_FAIL.getFlag());
+                            orderInfo1.setTripartiteStatus(StatusEnum.TRIPARTITE_FAIL.getName());
+                            orderInfo1.setTripartiteFailureReason(jsonObject1.getString("message"));
+                            orderInfoService.updateById(orderInfo1);
+                            throw new YException(YExceptionEnum.REPORT_FAILED);
                         }
                         HyFreightSettlementInfo hyFreightSettlementInfo=hyFreightSettlementInfoService.selectOne(new EntityWrapper<HyFreightSettlementInfo>()
                         .eq("order_id",orderInfo1.getId()));
@@ -1592,7 +1608,12 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
                         String result4 = UplodeUtil.uploadSettlement(hyFreightSettlementInfo);
                         JSONObject jsonObject4 = JSONObject.fromObject(result4);
                         if (!"00000".equals(jsonObject4.getString("code"))) {
-                            throw new RuntimeException(jsonObject4.getString("message"));
+                            //更改上报状态
+                            orderInfo1.setTripartiteStatusKey(StatusEnum.TRIPARTITE_FAIL.getFlag());
+                            orderInfo1.setTripartiteStatus(StatusEnum.TRIPARTITE_FAIL.getName());
+                            orderInfo1.setTripartiteFailureReason(jsonObject4.getString("message"));
+                            orderInfoService.updateById(orderInfo1);
+                            throw new YException(YExceptionEnum.REPORT_FAILED);
                         }
                         String result = UplodeUtil.uploadOrder(orderInfo1);
                         JSONObject jsonObject = JSONObject.fromObject(result);
@@ -1607,13 +1628,23 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
                             String result2 = UplodeUtil.uploadLoad(hyCarrierInfo);
                             JSONObject jsonObject2 = JSONObject.fromObject(result2);
                             if (!"00000".equals(jsonObject2.getString("code"))) {
-                                throw new RuntimeException(jsonObject2.getString("message"));
+                                //更改上报状态
+                                orderInfo1.setTripartiteStatusKey(StatusEnum.TRIPARTITE_FAIL.getFlag());
+                                orderInfo1.setTripartiteStatus(StatusEnum.TRIPARTITE_FAIL.getName());
+                                orderInfo1.setTripartiteFailureReason(jsonObject2.getString("message"));
+                                orderInfoService.updateById(orderInfo1);
+                                throw new YException(YExceptionEnum.REPORT_FAILED);
                             }
                             hyCarrierInfo.setLoadingFlag("2");
                             String result3 = UplodeUtil.uploadLoad(hyCarrierInfo);
                             JSONObject jsonObject3 = JSONObject.fromObject(result3);
                             if (!"00000".equals(jsonObject3.getString("code"))) {
-                                throw new RuntimeException(jsonObject3.getString("message"));
+                                //更改上报状态
+                                orderInfo1.setTripartiteStatusKey(StatusEnum.TRIPARTITE_FAIL.getFlag());
+                                orderInfo1.setTripartiteStatus(StatusEnum.TRIPARTITE_FAIL.getName());
+                                orderInfo1.setTripartiteFailureReason(jsonObject3.getString("message"));
+                                orderInfoService.updateById(orderInfo1);
+                                throw new YException(YExceptionEnum.REPORT_FAILED);
                             }
                         } else {
                             //更改上报状态

+ 123 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/RealUtil.java

@@ -0,0 +1,123 @@
+package com.yh.saas.plugin.yiliangyiyun.util;
+
+import java.util.List;
+
+public class RealUtil {
+    private String realName;
+    private String idCard;
+    private String address;
+    private Long idCardStartDate;
+    private Long idCardEndDate;
+    private String nation;
+    private Integer gender;
+    private Long birthday;
+    private String idCardIssueOrganization;
+    private String idCardFrontFilename;
+    private String idCardBackFilename;
+    private String selfImageFilename;
+    private List<String> idCards;
+
+    public List<String> getIdCards() {
+        return idCards;
+    }
+
+    public void setIdCards(List<String> idCards) {
+        this.idCards = idCards;
+    }
+
+    public String getRealName() {
+        return realName;
+    }
+
+    public void setRealName(String realName) {
+        this.realName = realName;
+    }
+
+    public String getIdCard() {
+        return idCard;
+    }
+
+    public void setIdCard(String idCard) {
+        this.idCard = idCard;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public Long getIdCardStartDate() {
+        return idCardStartDate;
+    }
+
+    public void setIdCardStartDate(Long idCardStartDate) {
+        this.idCardStartDate = idCardStartDate;
+    }
+
+    public Long getIdCardEndDate() {
+        return idCardEndDate;
+    }
+
+    public void setIdCardEndDate(Long idCardEndDate) {
+        this.idCardEndDate = idCardEndDate;
+    }
+
+    public String getNation() {
+        return nation;
+    }
+
+    public void setNation(String nation) {
+        this.nation = nation;
+    }
+
+    public Integer getGender() {
+        return gender;
+    }
+
+    public void setGender(Integer gender) {
+        this.gender = gender;
+    }
+
+    public Long getBirthday() {
+        return birthday;
+    }
+
+    public void setBirthday(Long birthday) {
+        this.birthday = birthday;
+    }
+
+    public String getIdCardIssueOrganization() {
+        return idCardIssueOrganization;
+    }
+
+    public void setIdCardIssueOrganization(String idCardIssueOrganization) {
+        this.idCardIssueOrganization = idCardIssueOrganization;
+    }
+
+    public String getIdCardFrontFilename() {
+        return idCardFrontFilename;
+    }
+
+    public void setIdCardFrontFilename(String idCardFrontFilename) {
+        this.idCardFrontFilename = idCardFrontFilename;
+    }
+
+    public String getIdCardBackFilename() {
+        return idCardBackFilename;
+    }
+
+    public void setIdCardBackFilename(String idCardBackFilename) {
+        this.idCardBackFilename = idCardBackFilename;
+    }
+
+    public String getSelfImageFilename() {
+        return selfImageFilename;
+    }
+
+    public void setSelfImageFilename(String selfImageFilename) {
+        this.selfImageFilename = selfImageFilename;
+    }
+}

+ 97 - 4
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/UplodeUtil.java

@@ -225,7 +225,7 @@ public class UplodeUtil {
         net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(result);
 //        net.sf.json.JSONArray dataNJson = jsonObject.getJSONArray("date");
 
-        if(jsonObject.get("data").toString().length()==0){
+        if((jsonObject.getJSONArray("data")).size()==0) {
             customerUtil.setName(hyCompanyInfo.getCompanyName());
             customerUtil.setCreditCode(hyCompanyInfo.getUnifiedSocialCreditCode());
             customerUtil.setLegalName(hyCompanyInfo.getLegalPersonName());
@@ -285,7 +285,7 @@ public class UplodeUtil {
         String result = postJson("payee/search", settlementJson);
         net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(result);
 
-        if(jsonObject.get("data").toString().length()==0) {
+        if((jsonObject.getJSONArray("data")).size()==0)  {
             settlementUtil.setName(hyFreightSettlementInfo.getPayeeName());
             settlementUtil.setPhone("");
             settlementUtil.setIdCard(hyFreightSettlementInfo.getPayeeIdCard());
@@ -355,7 +355,7 @@ public class UplodeUtil {
                 String carrierJson = JSON.toJSONString(carrierUtil);
                 result = postJson("open_middleman/search", carrierJson);
                 net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(result);
-                if(jsonObject.get("data").toString().length()==0) {
+                if((jsonObject.getJSONArray("data")).size()==0) {
                     carrierUtil.setName(carCaptainInfo.getName());
                     carrierUtil.setPhone(orderInfo.getContactPersonPhone());
                     carrierUtil.setIdCardFrontFilename(UplodeUtil.postFile(new ByteArrayInputStream(carCaptainInfo.getCardAddressUrl().getBytes()), "身份证正面照.jpeg"));
@@ -395,7 +395,7 @@ public class UplodeUtil {
                 String carrierJson = JSON.toJSONString(carrierUtil);
                 result = postJson("open_middleman/search", carrierJson);
                 net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(result);
-                if(jsonObject.get("data").toString().length()==0) {
+                if((jsonObject.getJSONArray("data")).size()==0) {
                     carrierUtil.setName(hyDriverInfo.getDriverName());
                     carrierUtil.setPhone(orderInfo.getDriverPhone());
                     carrierUtil.setIdCardFrontFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverInfo.getCardAddressUrl().getBytes()), "身份证正面照.jpeg"));
@@ -429,6 +429,98 @@ public class UplodeUtil {
         }
 
 
+        System.out.println(result);
+        return result;
+    }
+    /**
+     * 实名认证
+     * @param orderInfo
+     * @throws Exception
+     */
+    public static String uploadRealName(OrderInfo orderInfo) throws Exception {
+        SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd");
+        SimpleDateFormat formatter2 = new SimpleDateFormat( "yyyy.MM.dd");
+        SimpleDateFormat formatter1 = new SimpleDateFormat( "yyyy年MM月dd日");
+        RealUtil realUtil = new RealUtil();
+        String result="";
+        //承运人取车队长信息
+        if (orderInfo.getCarCaptainCommonId()!=null){
+            HyCarCaptainInfo carCaptainInfo=uplodeUtil.carCaptainInfoService.selectOne(new EntityWrapper<HyCarCaptainInfo>()
+                    .eq("common_id",orderInfo.getCarCaptainCommonId()));
+            if (carCaptainInfo!=null){
+                List<String> list = new ArrayList<String>();
+                String idCard=carCaptainInfo.getIdCard();
+                list.add(idCard);
+                realUtil.setIdCards(list);
+                String realJson = JSON.toJSONString(realUtil);
+                result = postJson("realName/queryByIdCard", realJson);
+                net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(result);
+                if((jsonObject.getJSONArray("data")).size()==0)  {
+                    realUtil.setRealName(carCaptainInfo.getName());
+                    realUtil.setIdCard(carCaptainInfo.getIdCard());
+                    realUtil.setIdCardFrontFilename(UplodeUtil.postFile(new ByteArrayInputStream(carCaptainInfo.getCardAddressUrl().getBytes()), "身份证正面照.jpeg"));
+                    realUtil.setIdCardBackFilename(UplodeUtil.postFile(new ByteArrayInputStream(carCaptainInfo.getCardBackAddressUrl().getBytes()), "身份证背面照.jpeg"));
+                    //身份证起始日期
+                    String startDate = formatter1.format(carCaptainInfo.getCardValidityStartDate());
+                    //身份证截止日期
+                    Date date = formatter.parse(carCaptainInfo.getCardValidityEndDate());
+                    String endDate = formatter1.format(date);
+                    realUtil.setIdCardStartDate(formatter1.parse(startDate).getTime());
+                    realUtil.setIdCardEndDate(formatter1.parse(endDate).getTime());
+                    DistinguishView distinguishView = UplodeUtil.personShibie(carCaptainInfo.getCardAddressUrl(), "1");
+//                    realUtil.setNation("");
+                    realUtil.setAddress(distinguishView.getRecPersonAddr());
+//                    realUtil.setGender();
+//                    realUtil.setBirthday("");
+//                    realUtil.setIdCardIssueOrganization(orderInfo.getBankDeposit());
+                    realUtil.setSelfImageFilename(UplodeUtil.postFile(new ByteArrayInputStream(carCaptainInfo.getSelfPhoto().getBytes()), "自拍照片.jpeg"));
+                    realJson = JSON.toJSONString(realUtil);
+
+                    result = postJson("realName/submit", realJson);
+                }
+            }
+        }
+        //承运人取司机信息
+        else{
+            HyDriverInfo hyDriverInfo=uplodeUtil.driverInfoService.selectOne(new EntityWrapper<HyDriverInfo>()
+                    .eq("common_id",orderInfo.getCommonId()));
+            if (hyDriverInfo!=null){
+                List<String> list = new ArrayList<String>();
+                String idCard=hyDriverInfo.getNumberCard();
+                list.add(idCard);
+                realUtil.setIdCards(list);
+                String realJson = JSON.toJSONString(realUtil);
+                result = postJson("realName/queryByIdCard", realJson);
+                net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(result);
+                if((jsonObject.getJSONArray("data")).size()==0)  {
+                    realUtil.setRealName(hyDriverInfo.getDriverName());
+                    realUtil.setIdCard(hyDriverInfo.getNumberCard());
+                    realUtil.setIdCardFrontFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverInfo.getCardAddressUrl().getBytes()), "身份证正面照.jpeg"));
+                    realUtil.setIdCardBackFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverInfo.getCardBackAddressUrl().getBytes()), "身份证背面照.jpeg"));
+                    DistinguishView distinguishView = UplodeUtil.personShibie(hyDriverInfo.getCardBackAddressUrl(), "2");
+                    String time = distinguishView.getIdCardValidity().substring(0, distinguishView.getIdCardValidity().indexOf('-'));
+                    Date date1 = formatter2.parse(time);
+                    //身份证起始日期
+                    String startDate = formatter1.format(date1);
+                    //身份证截止日期
+                    Date date = formatter.parse(hyDriverInfo.getCardValidityDate());
+                    String endDate = formatter1.format(date);
+                    realUtil.setIdCardStartDate(formatter1.parse(startDate).getTime());
+                    realUtil.setIdCardEndDate(formatter1.parse(endDate).getTime());
+//                    realUtil.setNation("");
+                    realUtil.setAddress(hyDriverInfo.getCardAddress());
+//                    realUtil.setGender();
+//                    realUtil.setBirthday("");
+//                    realUtil.setIdCardIssueOrganization(orderInfo.getBankDeposit());
+                    realUtil.setSelfImageFilename(UplodeUtil.postFile(new ByteArrayInputStream(hyDriverInfo.getSelfPhoto().getBytes()), "自拍照片.jpeg"));
+                    realJson = JSON.toJSONString(realUtil);
+
+                    result = postJson("realName/submit", realJson);
+                }
+            }
+        }
+
+
         System.out.println(result);
         return result;
     }
@@ -760,6 +852,7 @@ public class UplodeUtil {
             if ("1".equals(flag)) {
                 //身份证正面
                 distinguishView.setRecPersonAddr(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证人像面实体信息").getString("住址"));
+                distinguishView.setRecPersonBrithday(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证人像面实体信息").getString("出生日期"));
             } else if ("2".equals(flag)) {
                 //身份证反面
                 distinguishView.setIdCardValidity(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证国徽面实体信息").getString("有效期限"));