From a1fd9cba254d4577a5c433aacfb15d561bcc9cda Mon Sep 17 00:00:00 2001 From: zxc <954985706@qq.com> Date: Fri, 24 Jul 2020 14:22:34 +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 --- .../constant/ThirdRunTimeInfoConstant.java | 2 +- .../impl/ComponentVerifyTicketServiceImpl.java | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java index 92f372b4fd..b7dc98d4b4 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRunTimeInfoConstant.java @@ -46,7 +46,7 @@ public interface ThirdRunTimeInfoConstant { String END_GET_AUTH_INFO = "=====================结束获取【authorization_info】====================="; - String CREATE_AND_BIND_SUCCESS = "创建开放平台帐号并绑定公众号/小程序"; + String CREATE_AND_BIND_SUCCESS = "开始创建开放平台帐号并绑定公众号/小程序"; String BIND_SUCCESS = "绑定公众号/小程序到开放平台"; 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 1b1617d636..8f1493bd72 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 @@ -111,20 +111,17 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe String nonce = request.getParameter(ModuleConstant.NONCE); String encryptType = request.getParameter(ModuleConstant.ENCRYPT_TYPE); String signature = request.getParameter(ModuleConstant.SIGNATURE); - log.info(String.format(ThirdRunTimeInfoConstant.VERIFY_TICKET,msgSignature,timeStamp,nonce,encryptType,signature)); // 从请求中读取整个post数据 InputStream inputStream; String postData = null; inputStream = request.getInputStream(); postData= IOUtils.toString(inputStream,ModuleConstant.UTF8); - log.info("postData = "+postData); WXBizMsgCrypt wxBizMsgCrypt = new WXBizMsgCrypt(token,aesKey,componentAppId); String msg = wxBizMsgCrypt.decryptMsg(msgSignature, timeStamp, nonce, postData); log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg)); // 将xml转为map Map result = WXXmlToMapUtil.xmlToMap(msg); String infotype = result.get(ModuleConstant.INFO_TYPE); - log.info(infotype); switch (infotype){ case ModuleConstant.TICKET_UNDERLINE_KEY: //接收票据 【component_verify_ticket】 String ComponentVerifyTicket = result.get(ModuleConstant.TICKET_KEY); @@ -353,7 +350,6 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe Map map = JSON.parseObject(data, HashMap.class); if (!map.containsKey(ModuleConstant.ERR_CODE)) { log.info(REFRESH_AUTH_ACCESS_TOKEN); - //authorizer_access_token String authorizerAccessToken = map.get(ModuleConstant.AUTHORIZER_ACCESS_TOKEN).toString(); String expiresIn = map.get(ModuleConstant.EXPIRES_IN).toString(); String authorizerRefreshToken = map.get(ModuleConstant.AUTHORIZER_REFRESH_TOKEN).toString(); @@ -372,7 +368,6 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe //先逻辑删除,在插入 authorizationInfoDao.updateOldAuthorizerAccessToken(customerId, clientType); authorizationInfoDao.insertAuthorizerAccessToken(formDTO); - //缓存 refreshAuthorizerAccessToken redisThird.setAuthorizerRefreshToken(authorizationInfo); } @@ -396,28 +391,26 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe String expiresIn = authCodeAndTime.getExpiresIn(); String customerId = this.getLoginUserCustomerId(tokenDto); Date expiresInTime = this.countExpirationTime(expiresIn); - if (StringUtils.isBlank(customerId)||StringUtils.isBlank(clientType)||StringUtils.isBlank(authCode)||StringUtils.isBlank(expiresIn)){ - log.info("客户ID = "+customerId+", 客户端类型为 = "+clientType+", 授权码为 = "+authCode+", 有效期 = "+expiresIn); - } //authCode存数据库 AuthCodeFormDTO formDTO = new AuthCodeFormDTO(); formDTO.setAuthCode(authCode); formDTO.setExpiresInTime(expiresInTime); formDTO.setClientType(clientType); - //授权方AppId formDTO.setCustomerId(customerId); log.info(formDTO.toString()); authCodeDao.deleteCustomerAuthCode(customerId,clientType); authCodeDao.insertRedirectAuthCode(formDTO); //authCode存缓存 redisThird.setAuthCode(formDTO); + // 1. 开始获取授权信息(使用授权码) AuthorizationInfoResultDTO authorizationInfoResultDTO = this.authInfoByAuthCode(authCode, customerId, clientType); String authAppId = authorizationInfoResultDTO.getAuthorizer_appid(); - // todo ================================================ - AuthCodeResultDTO authCodeResultDTO = authorizationInfoDao.selectCustomerIdByAuthAppId(authAppId); + // 2. 创建开放平台账号并绑定 或者 直接绑定开放平台 this.createAndBindOpenAccount(customerId,authAppId,clientType); + // 3. 更新 customer_mp 表授权状态和AuthAppId this.updateCustomerMpAppId(customerId,authAppId,clientType); authCodeDao.updateAppId(customerId,clientType,authAppId); + // 4. 保存授权方账户信息 this.saveAuthAccountInfo(customerId,authAppId,clientType); log.info("回调结束"); } @@ -546,7 +539,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe Map bindInfo = JSON.parseObject(bindResult, Map.class); boolean bindStatus = bindInfo.containsKey(ModuleConstant.OPEN_APP_ID); if (bindStatus != true) { - log.info("开始创建开放平台账号并绑定"); + log.info(CREATE_AND_BIND_SUCCESS); List authCount = customerMpDao.selectAuthCount(customerId); String openPlatformId = null; if (authCount.size() > 0) {