| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -106,42 +106,57 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // 将xml转为map
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Map<String, Object> result = WXXmlToMapUtil.multilayerXmlToMap(msg); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Map<String,Object> xml = (Map<String, Object>) result.get(ModuleConstant.XML); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (xml.get(ModuleConstant.MSG_TYPE).equals(ModuleConstant.EVENT_LOW)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // TODO 目前来看,msgType = ‘event’ 的是代码审核结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Long createTime = Long.valueOf(xml.get(ModuleConstant.CREATE_TIME).toString()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            CodeAuditRecordFormDTO codeAuditRecord = ConvertUtils.mapToEntity(xml, CodeAuditRecordFormDTO.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            codeAuditRecord.setWechatCreateTime(componentVerifyTicketServiceImpl.sToDate(createTime.toString())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String toUserName = codeAuditRecord.getToUserName();//小程序原始ID
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            CustomerIdAndClientResultDTO customerIdAndClientResultDTO = miniInfoDao.selectCustomerIdAndClientByToUserName(toUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String clientType = customerIdAndClientResultDTO.getClientType(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String customerId = customerIdAndClientResultDTO.getCustomerId(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            TemplateAndAppIdResultDTO templateAndAppId = codeCustomerDao.selectTemplateAndAppId(customerId, clientType); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String authAppId = templateAndAppId.getAuthAppId(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String templateId = templateAndAppId.getTemplateId(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            codeAuditRecord.setClientType(clientType); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            codeAuditRecord.setCustomerId(customerId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            codeAuditRecord.setAuthAppId(authAppId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            codeAuditRecord.setTemplateId(templateId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //插入 代码审核 记录
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            log.info(String.format(ThirdRunTimeInfoConstant.CODE_AUDIT_RESULT,xml)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            codeAuditRecordDao.insertCodeAuditRecord(codeAuditRecord); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // 修改 code_audit_result 中的代码审核结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String event = codeAuditRecord.getEvent(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String codeResult = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            switch (event) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                case ModuleConstant.WEAPP_AUDIT_SUCCESS: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    codeResult = ModuleConstant.AUDIT_SUCCESS; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                case ModuleConstant.WEAPP_AUDIT_FAIL: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    codeResult = ModuleConstant.AUDIT_FAILED; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                case ModuleConstant.WEAPP_AUDIT_DELAY: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    codeResult = ModuleConstant.DELAY; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String msgType = xml.get(ModuleConstant.MSG_TYPE).toString(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        log.info(String.format(ThirdRunTimeInfoConstant.MSG_TYPE,msgType)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String toUserName = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String fromUserName = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (msgType.equals(ModuleConstant.EVENT_LOW)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String event = xml.get(ModuleConstant.EVENT).toString(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (xml.containsKey(ModuleConstant.TO_USER_NAME)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                toUserName = xml.get(ModuleConstant.TO_USER_NAME).toString(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String codeCustomerId = codeCustomerDao.selectCodeCustomerId(codeAuditRecord); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            codeAuditResultDao.updateAuditResult(customerId, codeCustomerId, codeResult); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }else if (xml.get(ModuleConstant.MSG_TYPE).equals(ModuleConstant.TEXT)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (xml.containsKey(ModuleConstant.FROM_USER_NAME)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                fromUserName = xml.get(ModuleConstant.FROM_USER_NAME).toString(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (event.startsWith(ModuleConstant.WE_APP_AUDIT)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                // TODO 目前来看,msgType = ‘event’ 的是代码审核结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                Long createTime = Long.valueOf(xml.get(ModuleConstant.CREATE_TIME).toString()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                CodeAuditRecordFormDTO codeAuditRecord = ConvertUtils.mapToEntity(xml, CodeAuditRecordFormDTO.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                codeAuditRecord.setWechatCreateTime(componentVerifyTicketServiceImpl.sToDate(createTime.toString())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                String toUserName = codeAuditRecord.getToUserName();//小程序原始ID
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                CustomerIdAndClientResultDTO customerIdAndClientResultDTO = miniInfoDao.selectCustomerIdAndClientByToUserName(toUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String clientType = customerIdAndClientResultDTO.getClientType(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String customerId = customerIdAndClientResultDTO.getCustomerId(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                TemplateAndAppIdResultDTO templateAndAppId = codeCustomerDao.selectTemplateAndAppId(customerId, clientType); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String authAppId = templateAndAppId.getAuthAppId(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String templateId = templateAndAppId.getTemplateId(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                codeAuditRecord.setClientType(clientType); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                codeAuditRecord.setCustomerId(customerId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                codeAuditRecord.setAuthAppId(authAppId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                codeAuditRecord.setTemplateId(templateId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                //插入 代码审核 记录
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.info(String.format(ThirdRunTimeInfoConstant.CODE_AUDIT_RESULT, xml)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                codeAuditRecordDao.insertCodeAuditRecord(codeAuditRecord); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                // 修改 code_audit_result 中的代码审核结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                String event = codeAuditRecord.getEvent();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String codeResult = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                switch (event) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    case ModuleConstant.WEAPP_AUDIT_SUCCESS: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        codeResult = ModuleConstant.AUDIT_SUCCESS; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    case ModuleConstant.WEAPP_AUDIT_FAIL: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        codeResult = ModuleConstant.AUDIT_FAILED; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    case ModuleConstant.WEAPP_AUDIT_DELAY: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        codeResult = ModuleConstant.DELAY; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String codeCustomerId = codeCustomerDao.selectCodeCustomerId(codeAuditRecord); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                codeAuditResultDao.updateAuditResult(customerId, codeCustomerId, codeResult); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                this.replyEventMessage(request,response,event,toUserName,fromUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }else if (msgType.equals(ModuleConstant.TEXT)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // TODO 公众号回复消息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            MessagePushTextFormDTO messagePushTextFormDTO = ConvertUtils.mapToEntity(xml, MessagePushTextFormDTO.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Object createTime = xml.get(ModuleConstant.CREATE_TIME); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -157,7 +172,7 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					             * 1)微信模推送给第三方平台方:文本消息,其中 Content 字段的内容固定为:TESTCOMPONENT_MSG_TYPE_TEXT | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					             * 2)第三方平台方立马回应文本消息并最终触达粉丝:Content 必须固定为:TESTCOMPONENT_MSG_TYPE_TEXT_callback | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					             */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (content.equals(ModuleConstant.TESTCOMPONENT_MSG_TYPE_TEXT)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            /*if (content.equals(ModuleConstant.TESTCOMPONENT_MSG_TYPE_TEXT)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }else if (content.startsWith(ModuleConstant.QUERY_AUTH_CODE)){ | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -166,7 +181,10 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                //auth_code
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String queryAuthCode = content.substring(contentBefore.length() + NumConstant.ONE, content.length()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }*/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            this.processTextMessage(request,response,content,toUserName,fromUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        log.info("消息与事件接收URL【代码审核结果】结束......"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return ModuleConstant.SUCCESS; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -224,7 +242,7 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void replyTextMessage(HttpServletRequest request, HttpServletResponse response, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                                 String content,String toUserName, String fromUserName) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            throws DocumentException, IOException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Long createTime = System.currentTimeMillis() / 1000; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Long createTime = System.currentTimeMillis() / NumConstant.ONE_THOUSAND; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        StringBuffer sb = new StringBuffer(512); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        sb.append("<xml>"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        sb.append("<ToUserName><![CDATA["+toUserName+"]]></ToUserName>"); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -251,7 +269,7 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // 得到微信授权成功的消息后,应该立刻进行处理!!相关信息只会在首次授权的时候推送过来
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //第三方平台【component_access_token】
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String componentAccessToken = redisThird.getComponentAccessToken(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        JSONObject jsonObject = new JSONObject(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        jsonObject.put(ModuleConstant.AUTHORIZATION_CODE, auth_code); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String authInfo = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_QUERY_AUTH_URL + componentAccessToken, JSON.toJSONString(jsonObject)).getData(); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |