From cb3ef2c242118a46a6a40ccccdff7e463f6096f7 Mon Sep 17 00:00:00 2001 From: Lemon Date: Tue, 1 Aug 2023 10:08:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E5=B9=B3=E5=8F=B0=20=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=AE=A1=E6=A0=B8=E7=8A=B6=E6=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/uniapp/AgentDevController.java | 26 +++++++-- .../com/jsowell/service/AgentDevService.java | 49 ++++++++++++++-- .../jsowell/common/constant/Constants.java | 2 + .../enums/AgentDev/AuditStatusEnum.java | 57 +++++++++++++++++++ .../pile/dto/agentDev/GetAuditStatusDTO.java | 22 +++++++ 5 files changed, 147 insertions(+), 9 deletions(-) create mode 100644 jsowell-common/src/main/java/com/jsowell/common/enums/AgentDev/AuditStatusEnum.java create mode 100644 jsowell-pile/src/main/java/com/jsowell/pile/dto/agentDev/GetAuditStatusDTO.java diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/AgentDevController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/AgentDevController.java index 24a325c0e..75222959c 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/AgentDevController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/AgentDevController.java @@ -6,10 +6,7 @@ import com.jsowell.common.core.controller.BaseController; import com.jsowell.common.response.RestApiResponse; import com.jsowell.pile.domain.AuthorizationEventResult; import com.jsowell.pile.domain.agentDev.CategoryInfo; -import com.jsowell.pile.dto.agentDev.CommitCodeDTO; -import com.jsowell.pile.dto.agentDev.ConcatenateAuthLinkDTO; -import com.jsowell.pile.dto.agentDev.GetComponentTokenDTO; -import com.jsowell.pile.dto.agentDev.SubmitAuditDTO; +import com.jsowell.pile.dto.agentDev.*; import com.jsowell.pile.vo.agentDev.AuthInfoVO; import com.jsowell.service.AgentDevService; import org.springframework.beans.factory.annotation.Autowired; @@ -215,4 +212,25 @@ public class AgentDevController extends BaseController { return response; } + /** + * 获取审核状态 + * + * @param dto + * @return + */ + @PostMapping("/getAuditStatus") + public RestApiResponse getAuditStatus(@RequestBody GetAuditStatusDTO dto) { + logger.info("获取审核状态 params:{}", JSONObject.toJSONString(dto)); + RestApiResponse response = null; + try { + String result = agentDevService.getAuditStatus(dto); + response = new RestApiResponse<>(result); + } catch (Exception e) { + logger.error("获取审核状态 error, ", e); + response = new RestApiResponse<>(e); + } + logger.info("获取审核状态 result:{}", response); + return response; + } + } diff --git a/jsowell-admin/src/main/java/com/jsowell/service/AgentDevService.java b/jsowell-admin/src/main/java/com/jsowell/service/AgentDevService.java index 498e28e63..d4498118a 100644 --- a/jsowell-admin/src/main/java/com/jsowell/service/AgentDevService.java +++ b/jsowell-admin/src/main/java/com/jsowell/service/AgentDevService.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONObject; import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.redis.RedisCache; +import com.jsowell.common.enums.AgentDev.AuditStatusEnum; import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.http.HttpUtils; import com.jsowell.common.util.wxplatform.AesException; @@ -12,13 +13,11 @@ import com.jsowell.common.util.wxplatform.WXBizMsgCrypt; import com.jsowell.common.util.wxplatform.WXXmlToMapUtil; import com.jsowell.pile.domain.agentDev.AuditItem; import com.jsowell.pile.domain.agentDev.CategoryInfo; -import com.jsowell.pile.dto.agentDev.CommitCodeDTO; -import com.jsowell.pile.dto.agentDev.ConcatenateAuthLinkDTO; -import com.jsowell.pile.dto.agentDev.GetComponentTokenDTO; -import com.jsowell.pile.dto.agentDev.SubmitAuditDTO; +import com.jsowell.pile.dto.agentDev.*; import com.jsowell.pile.vo.agentDev.AuthInfoVO; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; +import org.aspectj.weaver.ast.Var; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -363,6 +362,45 @@ public class AgentDevService { return String.valueOf(auditId); } + /** + * 获取审核状态 + * @param dto + * @return + */ + public String getAuditStatus(GetAuditStatusDTO dto) { + if (StringUtils.isBlank(dto.getAuditId())) { + throw new RuntimeException("微信第三方平台 查询审核单状态 error:审核id为空"); + } + // 获取用户接口调用令牌 + String redisKey = CacheConstants.AUTHORIZER_ACCESS_TOKEN + dto.getAuthorizerAppid(); + String authAccessToken = redisCache.getCacheObject(redisKey); + if (StringUtils.isBlank(authAccessToken)) { + throw new RuntimeException("微信第三方平台 查询审核单状态 error: authAccessToken为空"); + } + String url = "https://api.weixin.qq.com/wxa/get_auditstatus?access_token=" + authAccessToken; + // 拼接参数 + JSONObject jsonObject = new JSONObject(); + jsonObject.put("auditid", dto.getAuditId()); + // 发送请求 + String result = HttpUtils.sendPost(url, JSONObject.toJSONString(jsonObject)); + // 将返回结果转为json对象 + JSONObject resultJson = JSONObject.parseObject(result); + int errCode = (int) resultJson.get("errcode"); + if (errCode != Constants.zero) { + String errMsg = resultJson.getString("errmsg"); + logger.info("微信第三方平台 提交代码审核 error, {}", errMsg); + + return errMsg; + } + int status = (int) resultJson.get("status"); + if (status == Constants.one || status == Constants.four) { + // 当 status = 1 时,返回的拒绝原因; status = 4 时,返回的延后原因 + return resultJson.getString("reason"); + } + return AuditStatusEnum.getValueByCode(status); + } + + /** * 获取预授权码 * @@ -413,9 +451,10 @@ public class AgentDevService { public String concatenateAuthLinks(ConcatenateAuthLinkDTO dto) { String versionType = dto.getVersionType(); String url = ""; + String platformAppid = dto.getPlatformAppID() == null ? PLATFORM_APP_ID : dto.getPlatformAppID(); if (StringUtils.equals(Constants.ONE, versionType)) { // 1-PC版链接 - url = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=" + dto.getPlatformAppID() + url = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=" + platformAppid + "&pre_auth_code=" + dto.getPreAuthCode() + "&redirect_uri=" + dto.getRedirectUri() + "&auth_type=" + dto.getAuthType(); } else { // 2-H5版链接 diff --git a/jsowell-common/src/main/java/com/jsowell/common/constant/Constants.java b/jsowell-common/src/main/java/com/jsowell/common/constant/Constants.java index 737ca9049..533de8efb 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/constant/Constants.java +++ b/jsowell-common/src/main/java/com/jsowell/common/constant/Constants.java @@ -64,6 +64,8 @@ public class Constants { public static final int one = 1; + public static final int four = 4; + public static final byte zeroByte = 0x00; public static final byte[] zeroByteArray = new byte[]{zeroByte}; diff --git a/jsowell-common/src/main/java/com/jsowell/common/enums/AgentDev/AuditStatusEnum.java b/jsowell-common/src/main/java/com/jsowell/common/enums/AgentDev/AuditStatusEnum.java new file mode 100644 index 000000000..15daa5b42 --- /dev/null +++ b/jsowell-common/src/main/java/com/jsowell/common/enums/AgentDev/AuditStatusEnum.java @@ -0,0 +1,57 @@ +package com.jsowell.common.enums.AgentDev; + +import com.jsowell.common.enums.uniapp.BalanceChangesEnum; + +/** + * 审核状态enum + * + * @author Lemon + * @Date 2023/8/1 9:43 + */ +public enum AuditStatusEnum { + AUDIT_SUCCESS(0, "审核成功"), + AUDIT_REFUSE(1, "审核被拒绝"), + AUDIT_IN_PROGRESS(2, "审核中"), + AUDIT_REVOCATION(3, "已撤回"), + AUDIT_DELAYED(4, "审核延后"), + + ; + + private int code; + private String value; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + AuditStatusEnum(int value, String label) { + this.code = value; + this.value = label; + } + + /** + * 根据code获取value + * @param code + * @return + */ + public static String getValueByCode(int code) { + for (AuditStatusEnum item : AuditStatusEnum.values()) { + if (item.getCode() == code) { + return item.getValue(); + } + } + return null; + } +} diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/dto/agentDev/GetAuditStatusDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/dto/agentDev/GetAuditStatusDTO.java new file mode 100644 index 000000000..c7f22bace --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/dto/agentDev/GetAuditStatusDTO.java @@ -0,0 +1,22 @@ +package com.jsowell.pile.dto.agentDev; + +import lombok.Data; + +/** + * TODO + * + * @author Lemon + * @Date 2023/8/1 9:33 + */ +@Data +public class GetAuditStatusDTO { + /** + * 审核id + */ + private String auditId; + + /** + * 用户授权appid + */ + private String authorizerAppid; +}