| 
						
						
							
								
							
						
						
					 | 
					@ -32,9 +32,7 @@ import org.springframework.web.bind.annotation.RequestBody; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import javax.servlet.http.HttpServletRequest; | 
					 | 
					 | 
					import javax.servlet.http.HttpServletRequest; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import javax.servlet.http.HttpServletResponse; | 
					 | 
					 | 
					import javax.servlet.http.HttpServletResponse; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.io.IOException; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.io.InputStream; | 
					 | 
					 | 
					import java.io.InputStream; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.io.UnsupportedEncodingException; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.lang.reflect.Field; | 
					 | 
					 | 
					import java.lang.reflect.Field; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.*; | 
					 | 
					 | 
					import java.util.*; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -139,7 +137,6 @@ 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 authCode = result.get(ModuleConstant.AUTHORIZATION_CODE_HUMP); | 
					 | 
					 | 
					                    String authCode = result.get(ModuleConstant.AUTHORIZATION_CODE_HUMP); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    log.info("=============================="+authCode); | 
					 | 
					 | 
					                    log.info("=============================="+authCode); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    AuthCodeResultDTO authCodeResultDTO = authCodeDao.selectCustomerIdByAuthCode(authCode); | 
					 | 
					 | 
					                    AuthCodeResultDTO authCodeResultDTO = authCodeDao.selectCustomerIdByAuthCode(authCode); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -148,10 +145,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    Map<String, Object> authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); | 
					 | 
					 | 
					                    Map<String, Object> authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    String authAppId = authorizerRefreshToken.get("authorizerAppid").toString(); | 
					 | 
					 | 
					                    String authAppId = authorizerRefreshToken.get("authorizerAppid").toString(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    this.updateCustomerMpAppIdAndCreateOpenPlatform(customerId,authAppId,clientType); | 
					 | 
					 | 
					                    this.updateCustomerMpAppIdAndCreateOpenPlatform(customerId,authAppId,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);
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                case ModuleConstant.UNAUTHORIZED://用户取消授权
 | 
					 | 
					 | 
					                case ModuleConstant.UNAUTHORIZED://用户取消授权
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    //todo 取消授权
 | 
					 | 
					 | 
					                    //todo 取消授权
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    String authorizerAppId = result.get(ModuleConstant.AUTHORIZER_APP_ID_HUMP); | 
					 | 
					 | 
					                    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 | 
					 | 
					 | 
					     * @param | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * @author zxc | 
					 | 
					 | 
					     * @author zxc | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     */ | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Transactional(rollbackFor = Exception.class) | 
					 | 
					 | 
					    @Transactional(rollbackFor = Exception.class) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    public void updateCustomerMpAppIdAndCreateOpenPlatform(String customerId,String authAppId,String clientType){ | 
					 | 
					 | 
					    public void updateCustomerMpAppIdAndCreateOpenPlatform(String customerId,String authAppId,String clientType){ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        /*log.info("开始创建开放平台账号并绑定"); | 
					 | 
					 | 
					        log.info("==========回填customer_mp开始=========="); | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					        Integer authCount = customerMpDao.selectAuthCount(customerId); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        String openPlatformId = null; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        Map<String, Object> 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<String,String> 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<String,String> 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); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        }*/ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        AuthCodeFormDTO formDTO = new AuthCodeFormDTO(); | 
					 | 
					 | 
					        AuthCodeFormDTO formDTO = new AuthCodeFormDTO(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        formDTO.setClientType(clientType); | 
					 | 
					 | 
					        formDTO.setClientType(clientType); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        formDTO.setAuthAppId(authAppId); | 
					 | 
					 | 
					        formDTO.setAuthAppId(authAppId); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        formDTO.setCustomerId(customerId); | 
					 | 
					 | 
					        formDTO.setCustomerId(customerId); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        //回填customer_mp的appId 只需以上三个字段
 | 
					 | 
					 | 
					        //回填customer_mp的appId 只需以上三个字段
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        customerMpDao.updateAppIDByCustomerIdAndClient(formDTO); | 
					 | 
					 | 
					        customerMpDao.updateAppIDByCustomerIdAndClient(formDTO); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        //插入 binding_account
 | 
					 | 
					 | 
					        log.info("==========回填customer_mp结束=========="); | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					        /*BindingAccountFormDTO bindingAccount = new BindingAccountFormDTO(); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        bindingAccount.setOpenPlatformAccountId(openPlatformId); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        bindingAccount.setAuthAppId(authAppId); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        bindingAccount.setClientType(clientType); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        bindingAccount.setCustomerId(customerId); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        bindingAccountDao.insertBindingAccount(bindingAccount);*/ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        log.info("创建绑定账号结束"); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    /** | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |