|  | @ -139,13 +139,16 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
			
		
	
		
		
			
				
					|  |  |                     break; |  |  |                     break; | 
			
		
	
		
		
			
				
					|  |  |                 case ModuleConstant.AUTHORIZED: //授权成功
 |  |  |                 case ModuleConstant.AUTHORIZED: //授权成功
 | 
			
		
	
		
		
			
				
					|  |  |                     // 更改customer_mp 授权信息,appId,并绑定
 |  |  |                     // 更改customer_mp 授权信息,appId,并绑定
 | 
			
		
	
		
		
			
				
					
					|  |  |                     String authAppId = result.get(ModuleConstant.APP_ID); |  |  | //                    String authAppId = result.get(ModuleConstant.APP_ID);
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |                     String authCode = result.get(ModuleConstant.AUTHORIZATION_CODE_HUMP); |  |  |                     String authCode = result.get(ModuleConstant.AUTHORIZATION_CODE_HUMP); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     log.info("=============================="+authCode); | 
			
		
	
		
		
			
				
					|  |  |                     AuthCodeResultDTO authCodeResultDTO = authCodeDao.selectCustomerIdByAuthCode(authCode); |  |  |                     AuthCodeResultDTO authCodeResultDTO = authCodeDao.selectCustomerIdByAuthCode(authCode); | 
			
		
	
		
		
			
				
					|  |  |                     String clientType = authCodeResultDTO.getClientType(); |  |  |                     String clientType = authCodeResultDTO.getClientType(); | 
			
		
	
		
		
			
				
					|  |  |                     String customerId = authCodeResultDTO.getCustomerId(); |  |  |                     String customerId = authCodeResultDTO.getCustomerId(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     Map<String, Object> authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     String authAppId = authorizerRefreshToken.get("authorizerAppid").toString(); | 
			
		
	
		
		
			
				
					|  |  |                     this.updateCustomerMpAppIdAndCreateOpenPlatform(customerId,authAppId,clientType); |  |  |                     this.updateCustomerMpAppIdAndCreateOpenPlatform(customerId,authAppId,clientType); | 
			
		
	
		
		
			
				
					
					|  |  |                     this.authInfoByAuthCode(authCode, customerId,clientType); |  |  | //                    this.authInfoByAuthCode(authCode, customerId,clientType);
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |                     authCodeDao.updateAppId(customerId,clientType,authAppId); |  |  |                     authCodeDao.updateAppId(customerId,clientType,authAppId); | 
			
		
	
		
		
			
				
					|  |  |                     this.saveAuthAccountInfo(customerId,authAppId,clientType); |  |  |                     this.saveAuthAccountInfo(customerId,authAppId,clientType); | 
			
		
	
		
		
			
				
					|  |  | //                    customerMpDao.updateAuthorizationFlag(authAppId);
 |  |  | //                    customerMpDao.updateAuthorizationFlag(authAppId);
 | 
			
		
	
	
		
		
			
				
					|  | @ -269,7 +272,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
			
		
	
		
		
			
				
					|  |  |         authorizationInfoResultDTO = mapToEntity(map, AuthorizationInfoResultDTO.class); |  |  |         authorizationInfoResultDTO = mapToEntity(map, AuthorizationInfoResultDTO.class); | 
			
		
	
		
		
			
				
					|  |  |         String authAppId = authorizationInfoResultDTO.getAuthorizer_appid(); |  |  |         String authAppId = authorizationInfoResultDTO.getAuthorizer_appid(); | 
			
		
	
		
		
			
				
					|  |  |         log.info("授权信息:"+map); |  |  |         log.info("授权信息:"+map); | 
			
		
	
		
		
			
				
					
					|  |  |         String expiresIn = authorizationInfoResultDTO.getExpires_in(); |  |  |         String expiresIn = authorizationInfoResultDTO.getExpires_in().toString(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         Date expiresInTime = this.countExpirationTime(expiresIn); |  |  |         Date expiresInTime = this.countExpirationTime(expiresIn); | 
			
		
	
		
		
			
				
					|  |  |         //授权信息分为两张表,基础信息authorization_info,授权列表func_info
 |  |  |         //授权信息分为两张表,基础信息authorization_info,授权列表func_info
 | 
			
		
	
		
		
			
				
					|  |  |         // 1. 基础信息
 |  |  |         // 1. 基础信息
 | 
			
		
	
	
		
		
			
				
					|  | @ -288,7 +291,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
			
		
	
		
		
			
				
					|  |  |         List<FuncInfoFormDTO> funcInfos = new ArrayList<>(); |  |  |         List<FuncInfoFormDTO> funcInfos = new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |         List<Map> func_info = authorizationInfoResultDTO.getFunc_info(); |  |  |         List<Map> func_info = authorizationInfoResultDTO.getFunc_info(); | 
			
		
	
		
		
			
				
					|  |  |         log.info("权限列表信息:"+func_info); |  |  |         log.info("权限列表信息:"+func_info); | 
			
		
	
		
		
			
				
					
					|  |  |         func_info.forEach(func -> { |  |  |         /*func_info.forEach(func -> { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |             func.forEach((key,value) -> { |  |  |             func.forEach((key,value) -> { | 
			
		
	
		
		
			
				
					|  |  |                 FuncInfoFormDTO fu = new FuncInfoFormDTO(); |  |  |                 FuncInfoFormDTO fu = new FuncInfoFormDTO(); | 
			
		
	
		
		
			
				
					|  |  |                 fu.setFuncscopeCategory((String) key); |  |  |                 fu.setFuncscopeCategory((String) key); | 
			
		
	
	
		
		
			
				
					|  | @ -298,10 +301,10 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
			
		
	
		
		
			
				
					|  |  |                 fu.setCustomerId(customerId); |  |  |                 fu.setCustomerId(customerId); | 
			
		
	
		
		
			
				
					|  |  |                 funcInfos.add(fu); |  |  |                 funcInfos.add(fu); | 
			
		
	
		
		
			
				
					|  |  |             }); |  |  |             }); | 
			
		
	
		
		
			
				
					
					|  |  |         }); |  |  |         });*/ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         //先逻辑删除,在插入
 |  |  |         // todo 先逻辑删除,在插入
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         funcInfoDao.updateOldFuncInfo(customerId,authAppId); |  |  |         /*funcInfoDao.updateOldFuncInfo(customerId,authAppId); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         funcInfoDao.insertFuncInfo(funcInfos); |  |  |         funcInfoDao.insertFuncInfo(funcInfos);*/ | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |         // 授权信息放入缓存
 |  |  |         // 授权信息放入缓存
 | 
			
		
	
		
		
			
				
					|  |  |         redisThird.setAuthInfo(authorizationInfoResultDTO,customerId,clientType); |  |  |         redisThird.setAuthInfo(authorizationInfoResultDTO,customerId,clientType); | 
			
		
	
		
		
			
				
					|  |  |         //authorizer_refresh_token 放入缓存
 |  |  |         //authorizer_refresh_token 放入缓存
 | 
			
		
	
	
		
		
			
				
					|  | @ -375,6 +378,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
			
		
	
		
		
			
				
					|  |  |         String client = authCodeAndTime.getClientType(); |  |  |         String client = authCodeAndTime.getClientType(); | 
			
		
	
		
		
			
				
					|  |  |         String expiresIn = authCodeAndTime.getExpiresIn(); |  |  |         String expiresIn = authCodeAndTime.getExpiresIn(); | 
			
		
	
		
		
			
				
					|  |  |         String customerId = tokenDto.getCustomerId(); |  |  |         String customerId = tokenDto.getCustomerId(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         customerId = "f530774b31e0609a3c7f0f83794cda0c"; | 
			
		
	
		
		
			
				
					|  |  |         Date expiresInTime = this.countExpirationTime(expiresIn); |  |  |         Date expiresInTime = this.countExpirationTime(expiresIn); | 
			
		
	
		
		
			
				
					|  |  |         if (StringUtils.isBlank(customerId)||StringUtils.isBlank(client)||StringUtils.isBlank(authCode)||StringUtils.isBlank(expiresIn)){ |  |  |         if (StringUtils.isBlank(customerId)||StringUtils.isBlank(client)||StringUtils.isBlank(authCode)||StringUtils.isBlank(expiresIn)){ | 
			
		
	
		
		
			
				
					|  |  |             log.info("客户ID = "+customerId+", 客户端类型为 = "+client+", 授权码为 = "+authCode+", 有效期 = "+expiresIn); |  |  |             log.info("客户ID = "+customerId+", 客户端类型为 = "+client+", 授权码为 = "+authCode+", 有效期 = "+expiresIn); | 
			
		
	
	
		
		
			
				
					|  | @ -387,9 +391,11 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
			
		
	
		
		
			
				
					|  |  |         //授权方AppId
 |  |  |         //授权方AppId
 | 
			
		
	
		
		
			
				
					|  |  |         formDTO.setCustomerId(customerId); |  |  |         formDTO.setCustomerId(customerId); | 
			
		
	
		
		
			
				
					|  |  |         log.info(formDTO.toString()); |  |  |         log.info(formDTO.toString()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         authCodeDao.deleteCustomerAuthCode(customerId,client); | 
			
		
	
		
		
			
				
					|  |  |         authCodeDao.insertRedirectAuthCode(formDTO); |  |  |         authCodeDao.insertRedirectAuthCode(formDTO); | 
			
		
	
		
		
			
				
					|  |  |         //authCode存缓存
 |  |  |         //authCode存缓存
 | 
			
		
	
		
		
			
				
					|  |  |         redisThird.setAuthCode(formDTO); |  |  |         redisThird.setAuthCode(formDTO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         this.authInfoByAuthCode(authCode, customerId,client); | 
			
		
	
		
		
			
				
					|  |  |         log.info("回调结束"); |  |  |         log.info("回调结束"); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -496,14 +502,15 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
			
		
	
		
		
			
				
					|  |  |         log.info("开始创建开放平台账号并绑定"); |  |  |         log.info("开始创建开放平台账号并绑定"); | 
			
		
	
		
		
			
				
					|  |  |         Integer authCount = customerMpDao.selectAuthCount(customerId); |  |  |         Integer authCount = customerMpDao.selectAuthCount(customerId); | 
			
		
	
		
		
			
				
					|  |  |         String openPlatformId = null; |  |  |         String openPlatformId = null; | 
			
		
	
		
		
			
				
					
					|  |  |         String authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); |  |  |         Map<String, Object> authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |         String authorizerAccessToken = authorizerRefreshToken.get("authorizerAccessToken").toString(); | 
			
		
	
		
		
			
				
					|  |  |         if (authCount==NumConstant.ZERO){ |  |  |         if (authCount==NumConstant.ZERO){ | 
			
		
	
		
		
			
				
					|  |  |             log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定"); |  |  |             log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定"); | 
			
		
	
		
		
			
				
					|  |  |             //没有任何一个小程序/公众号授权,【先创建,再绑定】
 |  |  |             //没有任何一个小程序/公众号授权,【先创建,再绑定】
 | 
			
		
	
		
		
			
				
					|  |  |             JSONObject jsonObject = new JSONObject(); |  |  |             JSONObject jsonObject = new JSONObject(); | 
			
		
	
		
		
			
				
					
					|  |  |             jsonObject.put(ModuleConstant.APP_ID,authAppId); |  |  |             jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |             // 此处的 access_token 为 【authorizer_access_token】
 |  |  |             // 此处的 access_token 为 【authorizer_access_token】
 | 
			
		
	
		
		
			
				
					
					|  |  |             String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN + authorizerRefreshToken, JSON.toJSONString(jsonObject)).getData(); |  |  |             String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |             Map<String,String> map = JSON.parseObject(data, Map.class); |  |  |             Map<String,String> map = JSON.parseObject(data, Map.class); | 
			
		
	
		
		
			
				
					|  |  |             CreateOpenResultDTO createOpen = new CreateOpenResultDTO(); |  |  |             CreateOpenResultDTO createOpen = new CreateOpenResultDTO(); | 
			
		
	
		
		
			
				
					|  |  |             createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE))); |  |  |             createOpen.setErrCode(Integer.valueOf(map.get(ModuleConstant.ERR_CODE))); | 
			
		
	
	
		
		
			
				
					|  | 
 |