From 6f16b75d70c3f38e5de50b598848bb3310d626c9 Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Fri, 22 Dec 2023 11:49:02 +0800 Subject: [PATCH 1/3] commit --- .../AliRealNameAuthenticationController.java | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java b/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java index 3ef3cf8..c912186 100644 --- a/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java +++ b/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java @@ -244,7 +244,7 @@ public class AliRealNameAuthenticationController { String method = "GET"; Map headers = new HashMap(); //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105 - headers.put("Authorization", "APPCODE " +AliRealNameAuthenticationConfig.ALI_API_APPCODE); + headers.put("Authorization", "APPCODE " + AliRealNameAuthenticationConfig.ALI_API_APPCODE); Map querys = new HashMap(); querys.put("ComapnyName", enterpriseCertification.getCompanyName()); querys.put("CreditCode", enterpriseCertification.getCreditCode()); @@ -264,7 +264,7 @@ public class AliRealNameAuthenticationController { return R.ok("提交成功,请等待审核!"); } else { errorMsg = info.getReason(); - return R.ok().put("message", info.getReason()); + return R.error().put("message", info.getReason()); } } catch (Exception e) { e.printStackTrace(); @@ -274,5 +274,40 @@ public class AliRealNameAuthenticationController { } + public static void main(String[] args) { + String host = "https://sys.81api.com"; + String path = "/verifyCompany/"; + String method = "GET"; + Map headers = new HashMap(); + //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105 + headers.put("Authorization", "APPCODE " + AliRealNameAuthenticationConfig.ALI_API_APPCODE); + Map querys = new HashMap(); + querys.put("ComapnyName", "荆州国瑞网络科技有限公司"); + querys.put("CreditCode", "91421000MA494BGL8W"); + querys.put("LegalPersonName", "余承文"); + + String errorMsg = ""; + + try { + HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys); + CreditCodeResp info = new Gson().fromJson(EntityUtils.toString(response.getEntity()), CreditCodeResp.class); + if (info.getStatus()) { + /*if (!ObjectUtils.isEmpty(enterpriseCertificationService.checkWhetherItExists(enterpriseCertification.getCompanyName(), null, enterpriseCertification.getOpenId()))) { + errorMsg = "企业名称已存在"; + throw new RuntimeException(errorMsg); + } + enterpriseCertificationService.save(enterpriseCertification);*/ + + } else { + errorMsg = info.getReason(); + + System.err.println("错误信息:"+errorMsg); + } + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(errorMsg); + } + } + } \ No newline at end of file From 3f6eb37476d6b873b28d77ecb24fd3b7937d02d9 Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Fri, 22 Dec 2023 12:13:01 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=8A=9B=E5=87=BA=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AliRealNameAuthenticationController.java | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java b/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java index c912186..48250bc 100644 --- a/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java +++ b/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java @@ -79,13 +79,15 @@ public class AliRealNameAuthenticationController { //身份证信息返回 String idCardInformationReturn = FaceRecognitionAidUtil.IdCardOCRRecognition(imgFile, side); if (ObjectUtils.isEmpty(idCardInformationReturn)) { - throw new RuntimeException("身份证图片验证失败,请重新再试!"); +// ("身份证图片验证失败,请重新再试!"); + return R.error("身份证图片验证失败,请重新再试!"); } IdCardOCRResp resp = new Gson().fromJson(idCardInformationReturn, IdCardOCRResp.class); if (resp.getSuccess()) { return R.ok().put("data", resp); } else { - throw new RuntimeException("身份证图片验证失败,请重新再试!"); +// ("身份证图片验证失败,请重新再试!"); + return R.error("身份证图片验证失败,请重新再试!"); } } @@ -101,7 +103,8 @@ public class AliRealNameAuthenticationController { RealNameAuthenticationResp info = new Gson().fromJson(json, RealNameAuthenticationResp.class); if (!info.getRespCode().equals("0000")) { - throw new RuntimeException(info.getRespMessage()); + // (); + return R.error(info.getRespMessage()); } QueryWrapper queryWrapper = new QueryWrapper<>(); @@ -151,7 +154,7 @@ public class AliRealNameAuthenticationController { queryWrapper.eq("account_id", accountId); UserAuthenticationInformation userAuthenticationInformation = service.getOne(queryWrapper); if (ObjectUtils.isEmpty(userAuthenticationInformation)) { - return R.ok().put("data", false); + return R.ok().put("data", false).put("msg", "未认证"); } return R.ok().put("data", true).put("authenticationInformation", userAuthenticationInformation); } @@ -174,11 +177,13 @@ public class AliRealNameAuthenticationController { if (info.getSuccess()) { return R.ok().put("data", info); } else { - throw new RuntimeException("营业执照图片验证,请重新再试!"); + //("营业执照图片验证失败,请重新再试!"); + return R.error("营业执照图片验证失败,请重新再试!"); } } catch (Exception e) { e.printStackTrace(); - throw new RuntimeException("营业执照图片验证,请重新再试!"); +// ("营业执照图片验证失败,请重新再试!"); + return R.error("营业执照图片验证失败,请重新再试!"); } } @@ -214,7 +219,9 @@ public class AliRealNameAuthenticationController { if (info.getStatus()) { if (!ObjectUtils.isEmpty(enterpriseCertificationService.checkWhetherItExists(enterpriseCertification.getCompanyName(), certification.getId(), enterpriseCertification.getOpenId()))) { errorMsg = "企业名称已存在"; - throw new RuntimeException(errorMsg); +// (errorMsg); + + return R.error(errorMsg); } enterpriseCertificationService.updateById(enterpriseCertification); @@ -225,7 +232,8 @@ public class AliRealNameAuthenticationController { } } catch (Exception e) { e.printStackTrace(); - throw new RuntimeException(errorMsg); +// (errorMsg); + return R.error(errorMsg); } @@ -258,7 +266,7 @@ public class AliRealNameAuthenticationController { if (info.getStatus()) { if (!ObjectUtils.isEmpty(enterpriseCertificationService.checkWhetherItExists(enterpriseCertification.getCompanyName(), null, enterpriseCertification.getOpenId()))) { errorMsg = "企业名称已存在"; - throw new RuntimeException(errorMsg); + return R.error(errorMsg); } enterpriseCertificationService.save(enterpriseCertification); return R.ok("提交成功,请等待审核!"); @@ -268,7 +276,7 @@ public class AliRealNameAuthenticationController { } } catch (Exception e) { e.printStackTrace(); - throw new RuntimeException(errorMsg); + return R.error().put("message", errorMsg); } @@ -294,20 +302,20 @@ public class AliRealNameAuthenticationController { if (info.getStatus()) { /*if (!ObjectUtils.isEmpty(enterpriseCertificationService.checkWhetherItExists(enterpriseCertification.getCompanyName(), null, enterpriseCertification.getOpenId()))) { errorMsg = "企业名称已存在"; - throw new RuntimeException(errorMsg); + (errorMsg); } enterpriseCertificationService.save(enterpriseCertification);*/ } else { errorMsg = info.getReason(); - System.err.println("错误信息:"+errorMsg); + System.err.println("错误信息:" + errorMsg); } } catch (Exception e) { e.printStackTrace(); - throw new RuntimeException(errorMsg); + errorMsg = "系统错误"; } - } + } } \ No newline at end of file From 144f8fe6a5d1f23133eb46718661d186bdef2058 Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Fri, 22 Dec 2023 13:35:36 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E5=A4=B1=E8=B4=A5=E5=90=8E=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=BC=81=E4=B8=9A=E8=B4=A6=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AliRealNameAuthenticationController.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java b/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java index 48250bc..9a619cd 100644 --- a/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java +++ b/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java @@ -272,6 +272,20 @@ public class AliRealNameAuthenticationController { return R.ok("提交成功,请等待审核!"); } else { errorMsg = info.getReason(); + + //失败后删除本次生成的企业团队信息 + QueryWrapper accountQueryWrapper = new QueryWrapper<>(); + accountQueryWrapper.eq("app_open_id", enterpriseCertification.getOpenId()); + accountQueryWrapper.eq("platform_id", enterpriseCertification.getPlatformSource()); + + HrUserAccount userAccount = userAccountService.getOne(accountQueryWrapper); + + userInfoService.removeById(userAccount.getUserId()); + userAccountService.removeById(userAccount); + + // + + return R.error().put("message", info.getReason()); } } catch (Exception e) {