From da4d9b98002dcb03f3081cb64ad0b62c2e854b00 Mon Sep 17 00:00:00 2001 From: zxc <954985706@qq.com> Date: Mon, 20 Jul 2020 16:36:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0-=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/form/CodeAuditRecordFormDTO.java | 18 ++--- .../com/epmet/dto/form/MiniInfoFormDTO.java | 14 ++-- .../com/epmet/dto/form/PaInfoFormDTO.java | 14 ++-- .../com/epmet/constant/ModuleConstant.java | 2 + .../epmet/controller/WarrantController.java | 2 +- .../com/epmet/exception/AesException.java | 65 ------------------- .../com/epmet/service/WarrantService.java | 3 +- .../ComponentVerifyTicketServiceImpl.java | 3 +- .../service/impl/WarrantServiceImpl.java | 16 +++-- .../wxapi/constant/WxMaCodeConstant.java | 2 +- .../resources/mapper/CodeAuditRecordDao.xml | 18 ++--- .../src/main/resources/mapper/MiniInfoDao.xml | 14 ++-- .../src/main/resources/mapper/PaInfoDao.xml | 14 ++-- 13 files changed, 62 insertions(+), 123 deletions(-) delete mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/exception/AesException.java diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeAuditRecordFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeAuditRecordFormDTO.java index c0530f1bb7..1081ab0891 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeAuditRecordFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeAuditRecordFormDTO.java @@ -42,12 +42,12 @@ public class CodeAuditRecordFormDTO implements Serializable { /** * 小程序的原始 ID */ - private String toUserName; + private String ToUserName; /** * 发送方帐号(一个 OpenID,此时发送方是系统帐号) */ - private String fromUserName; + private String FromUserName; /** * 消息创建时间 (整型),时间戳 @@ -57,7 +57,7 @@ public class CodeAuditRecordFormDTO implements Serializable { /** * 消息类型 event */ - private String msgType; + private String MsgType; /** * 事件类型 @@ -65,32 +65,32 @@ public class CodeAuditRecordFormDTO implements Serializable { weapp_audit_fail:审核不通过, weapp_audit_delay:审核延后 */ - private String event; + private String Event; /** * 审核成功时的时间戳 */ - private Date succTime; + private Date SuccTime; /** * 审核不通过的时间戳 */ - private Date failTime; + private Date FailTime; /** * 审核延后时的时间戳 */ - private Date delayTime; + private Date DelayTime; /** * 审核不通过的原因 */ - private String reason; + private String Reason; /** * 审核不通过的截图示例。用 | 分隔的 media_id 的列表,可通过获取永久素材接口拉取截图内容 */ - private String screenShot; + private String ScreenShot; /** * 删除状态 diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MiniInfoFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MiniInfoFormDTO.java index 072877f958..bed074d166 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MiniInfoFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MiniInfoFormDTO.java @@ -28,32 +28,32 @@ public class MiniInfoFormDTO implements Serializable { /** * 昵称 */ - private String nickName; + private String nick_name; /** * 头像 */ - private String headImg; + private String head_img; /** * 小程序类型 默认为 0 */ - private String serviceTypeInfo; + private String service_type_info; /** * 小程序认证类型 小程序认证类型 */ - private String verifyTypeInfo; + private String verify_type_info; /** * 原始 ID */ - private String userName; + private String user_name; /** * 主体名称 */ - private String principalName; + private String principal_name; /** * 账号介绍 @@ -63,7 +63,7 @@ public class MiniInfoFormDTO implements Serializable { /** * 二维码图片的 URL */ - private String qrcodeUrl; + private String qrcode_url; private Integer delFlag = 0; diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PaInfoFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PaInfoFormDTO.java index d91c84cfa3..cfd60e3d9a 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PaInfoFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PaInfoFormDTO.java @@ -28,19 +28,19 @@ public class PaInfoFormDTO implements Serializable { /** * 昵称 */ - private String nickName; + private String nick_name; /** * 头像 */ - private String headImg; + private String head_img; /** * 公众号类型 0:订阅号 1:由历史老帐号升级后的订阅号 2:服务号 */ - private String serviceTypeInfo; + private String service_type_info; /** * 公众号认证类型 -1:未认证 @@ -51,17 +51,17 @@ public class PaInfoFormDTO implements Serializable { 4:已资质认证通过、还未通过名称认证,但通过了新浪微博认证 5:已资质认证通过、还未通过名称认证,但通过了腾讯微博认证 */ - private String verifyTypeInfo; + private String verify_type_info; /** * 原始ID */ - private String userName; + private String user_name; /** * 主体名称 */ - private String principalName; + private String principal_name; /** * 公众号所设置的微信号,可能为空 公众号所设置的微信号,可能为空 @@ -71,7 +71,7 @@ public class PaInfoFormDTO implements Serializable { /** * 二维码图片的 URL */ - private String qrcodeUrl; + private String qrcode_url; /** * 删除状态 0:正常,1:删除 diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java index 19bd0fb57a..746da4ba2d 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java @@ -77,6 +77,8 @@ public interface ModuleConstant { String DELAY = "delay"; String AUDIT_SUCCESS = "audit_success"; String AUDIT_FAILED = "audit_failed"; + String XML = "xml"; + String CREATE_TIME = "CreateTime"; int FORTY_THOUSAND_AND_THIRTEEN = 40013; int EIGHTY_NINE_THOUSAND = 89000; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java index 1acb7a60ab..1cb35bb666 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java @@ -1,6 +1,6 @@ package com.epmet.controller; -import com.epmet.exception.AesException; +import com.epmet.mpaes.AesException; import com.epmet.service.WarrantService; import lombok.extern.slf4j.Slf4j; import org.dom4j.DocumentException; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/exception/AesException.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/exception/AesException.java deleted file mode 100644 index 96835b1324..0000000000 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/exception/AesException.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.epmet.exception; - -/** - * @Author zxc - * @CreateTime 2020/7/6 10:03 - */ -@SuppressWarnings("serial") -public class AesException extends Exception { - - /*public final static int OK = 0; - public final static int ValidateSignatureError = -40001; - public final static int ParseXmlError = -40002; - public final static int ComputeSignatureError = -40003; - public final static int IllegalAesKey = -40004; - public final static int ValidateCorpidError = -40005; - public final static int EncryptAESError = -40006; - public final static int DecryptAESError = -40007; - public final static int IllegalBuffer = -40008; - public final static int EncodeBase64Error = -40009; - public final static int DecodeBase64Error = -40010; - public final static int GenReturnXmlError = -40011; - - private int code; - - private static String getMessage(int code) { - switch (code) { - case ValidateSignatureError: - return "签名验证错误"; - case ParseXmlError: - return "xml解析失败"; - case ComputeSignatureError: - return "sha加密生成签名失败"; - case IllegalAesKey: - return "SymmetricKey非法"; - case ValidateCorpidError: - return "corpid校验失败"; - case EncryptAESError: - return "aes加密失败"; - case DecryptAESError: - return "aes解密失败"; - case IllegalBuffer: - return "解密后得到的buffer非法"; - case EncodeBase64Error: - return "base64加密错误"; - case DecodeBase64Error: - return "base64解密错误"; - case GenReturnXmlError: - return "xml生成失败"; - default: - return null; // cannot be - } - } - - public int getCode() { - return code; - } - - public AesException(int code) { - super(getMessage(code)); - this.code = code; - } -*/ -} - - diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/WarrantService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/WarrantService.java index 8475322c5b..4ae4cfd5e1 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/WarrantService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/WarrantService.java @@ -1,8 +1,7 @@ package com.epmet.service; -import com.epmet.exception.AesException; +import com.epmet.mpaes.AesException; import org.dom4j.DocumentException; -import org.springframework.web.bind.annotation.PathVariable; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java index f2b87d0677..92475ea916 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java @@ -408,7 +408,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe JSONObject jsonObject = new JSONObject(); jsonObject.put(ModuleConstant.COMPONENT_APP_ID,componentAppId); jsonObject.put(ModuleConstant.AUTHORIZER_APP_ID,authAppId); - String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_GET_AUTHORIZER_INFO, JSON.toJSONString(jsonObject)).getData(); + String componentAccessToken = redisThird.getComponentAccessToken(); + String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_GET_AUTHORIZER_INFO + componentAccessToken , JSON.toJSONString(jsonObject)).getData(); Map map = JSON.parseObject(data, Map.class); Map authorizerInfo = map.get(ModuleConstant.AUTHORIZER_INFO); log.info("授权信息:"+authorizerInfo); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java index eaffb0dbd4..b49c04788e 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java @@ -10,7 +10,7 @@ import com.epmet.dao.MiniInfoDao; import com.epmet.dto.form.CodeAuditRecordFormDTO; import com.epmet.dto.result.CustomerIdAndClientResultDTO; import com.epmet.dto.result.TemplateAndAppIdResultDTO; -import com.epmet.exception.AesException; +import com.epmet.mpaes.AesException; import com.epmet.mpaes.WXBizMsgCrypt; import com.epmet.mpaes.WXXmlToMapUtil; import com.epmet.service.WarrantService; @@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; +import java.util.Date; import java.util.Map; /** @@ -58,15 +59,14 @@ public class WarrantServiceImpl implements WarrantService { /** * @Description 1.保存代码审核结果 2.更新代码上传结果 * @param request - * @param appid + * @param appId * @param response * @author zxc */ @Transactional(rollbackFor = Exception.class) @Override - public void acceptMessageAndEvent(HttpServletRequest request, String appid, HttpServletResponse response)throws IOException, DocumentException, AesException { - log.info("request:"+request); - log.info("appId:"+ appid); + public void acceptMessageAndEvent(HttpServletRequest request, String appId, HttpServletResponse response)throws IOException, DocumentException, AesException { + log.info("appId:"+ appId); request.setCharacterEncoding(ModuleConstant.UTF8); String msgSignature = request.getParameter(ModuleConstant.MSG_SIGNATURE); String timeStamp = request.getParameter(ModuleConstant.TIMESTAMP); @@ -83,14 +83,16 @@ public class WarrantServiceImpl implements WarrantService { try { wxBizMsgCrypt = new WXBizMsgCrypt(token,aesKey,componentAppId); msg = wxBizMsgCrypt.decryptMsg(msgSignature, timeStamp, nonce, postData); - } catch (com.epmet.mpaes.AesException e) { + } catch (AesException e) { e.printStackTrace(); } log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg)); // 将xml转为map Map result = WXXmlToMapUtil.multilayerXmlToMap(msg); - Map xml = (Map) result.get("xml"); + Map xml = (Map) result.get(ModuleConstant.XML); + Long createTime = Long.valueOf(xml.get(ModuleConstant.CREATE_TIME).toString()); CodeAuditRecordFormDTO codeAuditRecord = componentVerifyTicketService.mapToEntity(xml, CodeAuditRecordFormDTO.class); + codeAuditRecord.setWechatCreateTime(new Date(createTime)); String toUserName = codeAuditRecord.getToUserName();//小程序原始ID CustomerIdAndClientResultDTO customerIdAndClientResultDTO = miniInfoDao.selectCustomerIdAndClientByToUserName(toUserName); String clientType = customerIdAndClientResultDTO.getClientType(); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java index 7cd1607654..fca87baeb7 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java @@ -58,7 +58,7 @@ public interface WxMaCodeConstant { /** * 获取授权方的帐号基本信息 */ - String API_GET_AUTHORIZER_INFO = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info"; + String API_GET_AUTHORIZER_INFO = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token="; /** * 为授权的小程序帐号上传小程序代码. diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeAuditRecordDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeAuditRecordDao.xml index f0d102d0f4..52fd770f9d 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeAuditRecordDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeAuditRecordDao.xml @@ -14,16 +14,16 @@ #{templateId}, #{clientType}, #{authAppId}, - #{toUserName}, - #{fromUserName}, + #{ToUserName}, + #{FromUserName}, #{wechatCreateTime}, - #{msgType}, - #{event}, - IFNULL(#{succTime},NULL), - IFNULL(#{failTime},NULL), - IFNULL(#{delayTime},NULL), - IFNULL(#{reason},NULL), - IFNULL(#{screenShot},NULL), + #{MsgType}, + #{Event}, + IFNULL(#{SuccTime},NULL), + IFNULL(#{FailTime},NULL), + IFNULL(#{DelayTime},NULL), + IFNULL(#{Reason},NULL), + IFNULL(#{ScreenShot},NULL), #{delFlag}, #{revision}, #{createdBy}, diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/MiniInfoDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/MiniInfoDao.xml index c838415721..bd326a8c0c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/MiniInfoDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/MiniInfoDao.xml @@ -15,14 +15,14 @@ REPLACE ( UUID(), '-', '' ), #{customerId}, #{clientType}, - #{nickName}, - #{headImg}, - #{serviceTypeInfo}, - #{verifyTypeInfo}, - #{userName}, - #{principalName}, + #{nick_name}, + #{head_img}, + #{service_type_info}, + #{verify_type_info}, + #{user_name}, + #{principal_name}, #{signature}, - #{qrcodeUrl}, + #{qrcode_url}, #{delFlag}, #{revision}, #{createdBy}, diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaInfoDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaInfoDao.xml index 8715fb65f0..57397dc708 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaInfoDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaInfoDao.xml @@ -15,14 +15,14 @@ REPLACE ( UUID(), '-', '' ), #{customerId}, #{clientType}, - #{nickName}, - #{headImg}, - #{serviceTypeInfo}, - #{verifyTypeInfo}, - #{userName}, - #{principalName}, + #{nick_name}, + #{head_img}, + #{service_type_info}, + #{verify_type_info}, + #{user_name}, + #{principal_name}, #{alias}, - #{qrcodeUrl}, + #{qrcode_url}, #{delFlag}, #{revision}, #{createdBy},