From f2bd7b494ea89b82a027401358cc52526097430b Mon Sep 17 00:00:00 2001 From: zxc <954985706@qq.com> Date: Wed, 22 Jul 2020 14:56:59 +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-customer=5Fmp=E5=AD=97=E6=AE=B5=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComponentVerifyTicketServiceImpl.java | 80 +------------------ .../main/resources/mapper/CustomerMpDao.xml | 2 +- 2 files changed, 4 insertions(+), 78 deletions(-) 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 ad4cd17964..cdc7b1d456 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 @@ -32,9 +32,7 @@ import org.springframework.web.bind.annotation.RequestBody; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; import java.io.InputStream; -import java.io.UnsupportedEncodingException; import java.lang.reflect.Field; import java.util.*; @@ -139,7 +137,6 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe break; case ModuleConstant.AUTHORIZED: //授权成功 // 更改customer_mp 授权信息,appId,并绑定 -// String authAppId = result.get(ModuleConstant.APP_ID); String authCode = result.get(ModuleConstant.AUTHORIZATION_CODE_HUMP); log.info("=============================="+authCode); AuthCodeResultDTO authCodeResultDTO = authCodeDao.selectCustomerIdByAuthCode(authCode); @@ -148,10 +145,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe Map authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); String authAppId = authorizerRefreshToken.get("authorizerAppid").toString(); this.updateCustomerMpAppIdAndCreateOpenPlatform(customerId,authAppId,clientType); -// this.authInfoByAuthCode(authCode, customerId,clientType); authCodeDao.updateAppId(customerId,clientType,authAppId); this.saveAuthAccountInfo(customerId,authAppId,clientType); -// customerMpDao.updateAuthorizationFlag(authAppId); case ModuleConstant.UNAUTHORIZED://用户取消授权 //todo 取消授权 String authorizerAppId = result.get(ModuleConstant.AUTHORIZER_APP_ID_HUMP); @@ -494,89 +489,20 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 1.创建开放平台账号并绑定 2.回填 customer_mp appId + * @Description 回填 customer_mp appId , 更改授权状态 * @param * @author zxc */ @Transactional(rollbackFor = Exception.class) public void updateCustomerMpAppIdAndCreateOpenPlatform(String customerId,String authAppId,String clientType){ - /*log.info("开始创建开放平台账号并绑定"); - Integer authCount = customerMpDao.selectAuthCount(customerId); - String openPlatformId = null; - Map authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); - String authorizerAccessToken = authorizerRefreshToken.get("authorizerAccessToken").toString(); - if (authCount==NumConstant.ZERO){ - log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定"); - //没有任何一个小程序/公众号授权,【先创建,再绑定】 - JSONObject jsonObject = new JSONObject(); - jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId); - // 此处的 access_token 为 【authorizer_access_token】 - String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData(); - Map map = JSON.parseObject(data, Map.class); - CreateOpenResultDTO createOpen = new CreateOpenResultDTO(); - createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE))); - createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG)); - createOpen.setOpenAppId(map.get(ModuleConstant.OPEN_APP_ID)); - switch (createOpen.getErrCode()){ - case NumConstant.ONE: - log.info(CREATE_AND_BIND_SUCCESS); - break; - case NumConstant.ONE_NEG: - throw new RenException(SYSTEM_ERROR); - case ModuleConstant.FORTY_THOUSAND_AND_THIRTEEN: - throw new RenException(INVALID_APP_ID); - case ModuleConstant.EIGHTY_NINE_THOUSAND: - throw new RenException(ACCOUNT_HAS_BOUND_OPEN); - } - CreateOpenFormDTO coForm = new CreateOpenFormDTO(); - coForm.setOpenid(map.get(ModuleConstant.OPEN_APP_ID)); - coForm.setCustomerId(customerId); - //插入 open_platform_account 表 - openPlatformAccountDao.insertOpenPlatFormAccount(coForm); - openPlatformId = coForm.getId(); - }else if (authCount>NumConstant.ZERO){ - log.info("该客户已创建过开放平台账号,直接绑定"); - String openAppId = openPlatformAccountDao.selectOpenAppIdByCustomerId(customerId); - JSONObject jsonObject = new JSONObject(); - jsonObject.put(ModuleConstant.LOW_APP_ID,componentAppId); - jsonObject.put(ModuleConstant.OPEN_APP_ID,openAppId); - String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_BIND_OPEN + authorizerRefreshToken, JSON.toJSONString(jsonObject)).getData(); - Map map = JSON.parseObject(data, Map.class); - CreateOpenResultDTO createOpen = new CreateOpenResultDTO(); - createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE))); - createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG)); - switch (createOpen.getErrCode()){ - case NumConstant.ONE: - log.info(BIND_SUCCESS); - break; - case NumConstant.ONE_NEG: - throw new RenException(SYSTEM_ERROR); - case ModuleConstant.FORTY_THOUSAND_AND_THIRTEEN: - throw new RenException(INVALID_APP_ID); - case ModuleConstant.EIGHTY_NINE_THOUSAND: - throw new RenException(ACCOUNT_HAS_BOUND_OPEN); - case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_ONE: - throw new RenException(NOT_SAME_CONTRACTOR); - case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_THREE: - throw new RenException(NOT_ALLOWED_OPERATE); - case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_FOUR: - throw new RenException(TO_LIMIT); - } - }*/ + log.info("==========回填customer_mp开始=========="); AuthCodeFormDTO formDTO = new AuthCodeFormDTO(); formDTO.setClientType(clientType); formDTO.setAuthAppId(authAppId); formDTO.setCustomerId(customerId); //回填customer_mp的appId 只需以上三个字段 customerMpDao.updateAppIDByCustomerIdAndClient(formDTO); - //插入 binding_account - /*BindingAccountFormDTO bindingAccount = new BindingAccountFormDTO(); - bindingAccount.setOpenPlatformAccountId(openPlatformId); - bindingAccount.setAuthAppId(authAppId); - bindingAccount.setClientType(clientType); - bindingAccount.setCustomerId(customerId); - bindingAccountDao.insertBindingAccount(bindingAccount);*/ - log.info("创建绑定账号结束"); + log.info("==========回填customer_mp结束=========="); } /** diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml index da99a3dd4f..e64d023ba7 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml @@ -51,7 +51,7 @@