From 928c61ce9c8fa8a3e708b54c72f51beb81295a81 Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Wed, 20 Dec 2023 15:05:58 +0800 Subject: [PATCH] commit --- .../AliRealNameAuthenticationController.java | 46 ++++++++++++++++++- .../EnterpriseCertificationServiceImpl.java | 2 + 2 files changed, 47 insertions(+), 1 deletion(-) 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 3991486..d217bf3 100644 --- a/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java +++ b/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java @@ -128,7 +128,7 @@ public class AliRealNameAuthenticationController { } - @ApiOperation(value = "统一社会信用代码认证", response = CreditCodeResp.class) + @ApiOperation(value = "统一社会信用代码认证(更改审核状态未提交为待审核)", response = CreditCodeResp.class) @PostMapping("/creditCodeAuthentication") public R creditCodeAuthentication(@RequestBody EnterpriseCertification enterpriseCertification, HttpServletRequest request) throws IOException { @@ -171,5 +171,49 @@ public class AliRealNameAuthenticationController { } + @ApiOperation(value = "统一社会信用代码认证(auditStatus给1,新增认证状态为待审核,用于个人认证幼儿园或供应商情况下)", response = CreditCodeResp.class) + @PostMapping("/organizationCertification") + public R organizationCertification(@RequestBody EnterpriseCertification enterpriseCertification, HttpServletRequest request) throws IOException { + + + String accountId = TokenUtils.getIdByJwtToken(request); + enterpriseCertification.setAccountId(Integer.valueOf(accountId)); + enterpriseCertification.setSubmitTime(new Date()); + 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", enterpriseCertification.getCompanyName()); + querys.put("CreditCode", enterpriseCertification.getCreditCode()); + querys.put("LegalPersonName", enterpriseCertification.getLegalPerson()); + + 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()))) { + errorMsg = "企业名称已存在"; + throw new RuntimeException(errorMsg); + } + enterpriseCertificationService.save(enterpriseCertification); + return R.ok("提交成功,请等待审核!"); + } else { + errorMsg = info.getReason(); + return R.ok().put("message", info.getReason()); + } + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(errorMsg); + } + + + } + + } \ No newline at end of file diff --git a/users/src/main/java/com/huoran/users/service/impl/EnterpriseCertificationServiceImpl.java b/users/src/main/java/com/huoran/users/service/impl/EnterpriseCertificationServiceImpl.java index 370e92c..eb316fc 100644 --- a/users/src/main/java/com/huoran/users/service/impl/EnterpriseCertificationServiceImpl.java +++ b/users/src/main/java/com/huoran/users/service/impl/EnterpriseCertificationServiceImpl.java @@ -26,6 +26,8 @@ public class EnterpriseCertificationServiceImpl extends ServiceImpl wrapper = new QueryWrapper<>(); wrapper.eq("company_name", company_name); + //校验已经通过的企业名称是否重复 + wrapper.eq("audit_status", 2); return getOne(wrapper); }