| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -8,6 +8,7 @@ import com.dingtalk.api.DingTalkClient; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.dingtalk.api.request.OapiRobotSendRequest; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.dingtalk.api.response.OapiRobotSendResponse; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.constant.NumConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.exception.RenException; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.utils.ConvertUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.utils.HttpClientManager; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.constant.ModuleConstant; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -41,6 +42,7 @@ import javax.servlet.http.HttpServletRequest; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.servlet.http.HttpServletResponse; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.io.IOException; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.io.InputStream; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.io.PrintWriter; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.Date; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.HashMap; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.Map; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -87,15 +89,16 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Transactional(rollbackFor = Exception.class) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public String acceptMessageAndEvent(HttpServletRequest request, String appId, HttpServletResponse response)throws IOException, DocumentException, AesException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        log.info("消息与事件接收URL【代码审核结果】开始执行......"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        log.info("appId:"+ appId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void acceptMessageAndEvent(HttpServletRequest request, String appId, HttpServletResponse response)throws IOException, DocumentException, AesException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        request.setCharacterEncoding(ModuleConstant.UTF8); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String msgSignature = request.getParameter(ModuleConstant.MSG_SIGNATURE); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String timeStamp = request.getParameter(ModuleConstant.TIMESTAMP); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String nonce = request.getParameter(ModuleConstant.NONCE); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (!StringUtils.isNotBlank(msgSignature)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return ModuleConstant.SUCCESS;// 微信推送给第三方开放平台的消息一定是加过密的,无消息加密无法解密消息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // 微信推送给第三方开放平台的消息一定是加过密的,无消息加密无法解密消息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            PrintWriter pw = response.getWriter(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            pw.write(ModuleConstant.SUCCESS); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            pw.flush(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        InputStream inputStream; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String postData = null; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -109,7 +112,6 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } catch (AesException e) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            e.printStackTrace(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // 将xml转为map
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Map<String, Object> result = WXXmlToMapUtil.multilayerXmlToMap(msg); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Map<String,Object> xml = (Map<String, Object>) result.get(ModuleConstant.XML); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -117,20 +119,22 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        log.info(String.format(ThirdRunTimeInfoConstant.MSG_TYPE,msgType)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String toUserName = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String fromUserName = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (xml.containsKey(ModuleConstant.TO_USER_NAME)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            toUserName = xml.get(ModuleConstant.TO_USER_NAME).toString(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            log.info("toUserName为:" + toUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (xml.containsKey(ModuleConstant.FROM_USER_NAME)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            fromUserName = xml.get(ModuleConstant.FROM_USER_NAME).toString(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            log.info("fromUserName为:"+fromUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        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(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (xml.containsKey(ModuleConstant.FROM_USER_NAME)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                fromUserName = xml.get(ModuleConstant.FROM_USER_NAME).toString(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (event.startsWith(ModuleConstant.WE_APP_AUDIT)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.info("消息与事件接收URL【代码审核结果】开始执行......"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                // 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(); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -147,7 +151,6 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.info(String.format(ThirdRunTimeInfoConstant.CODE_AUDIT_RESULT, xml)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                codeAuditRecordDao.insertCodeAuditRecord(codeAuditRecord); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                // 修改 code_audit_result 中的代码审核结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                String event = codeAuditRecord.getEvent();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String reason = codeAuditRecord.getReason(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String codeResult = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                switch (event) { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -167,7 +170,11 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String codeCustomerId = codeCustomerDao.selectCodeCustomerId(codeAuditRecord); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                codeAuditResultDao.updateAuditResult(customerId, codeCustomerId, codeResult); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.info("消息与事件接收URL【代码审核结果】结束......"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                PrintWriter pw = response.getWriter(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                pw.write(ModuleConstant.SUCCESS); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                pw.flush(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                log.info("====================  ==== event message  ========= ="); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                this.replyEventMessage(request,response,event,toUserName,fromUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }else if (msgType.equals(ModuleConstant.TEXT)){ | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -179,18 +186,15 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            messagePushTextDao.insertMessageText(messagePushTextFormDTO);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String content = messagePushTextFormDTO.getContent(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            log.info(String.format(ThirdRunTimeInfoConstant.CONTENT,content)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					             * 测试公众号处理用户消息 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					             * 模拟粉丝发送文本消息给专用测试公众号,第三方平台方需根据文本消息的内容进行相应的响应: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					             * 1)微信模推送给第三方平台方:文本消息,其中 Content 字段的内容固定为:TESTCOMPONENT_MSG_TYPE_TEXT | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					             * 2)第三方平台方立马回应文本消息并最终触达粉丝:Content 必须固定为:TESTCOMPONENT_MSG_TYPE_TEXT_callback | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					             */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            this.processTextMessage(request,response,content,toUserName,fromUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            this.processTextMessage(request, response, content, toUserName, fromUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return ModuleConstant.SUCCESS; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /*public static void main(String[] args) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        WarrantServiceImpl w = new WarrantServiceImpl(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        w.dingDingRobot("haha","weapp_audit_fail","haha","jumian"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    }*/ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Description  钉钉机器人报警 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @author zxc | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -236,7 +240,7 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * 方法描述: 类型为enevt的时候,拼接 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * 方法描述: 类型为event的时候,拼接 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param request | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param response | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param event | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -247,8 +251,12 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void replyEventMessage(HttpServletRequest request, HttpServletResponse response, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                                  String event, String toUserName, String fromUserName) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            throws DocumentException, IOException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        log.info("================  event + from_callback..................."); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String content = event + ModuleConstant.FROM_CALLBACK; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        replyTextMessage(request,response,content,toUserName,fromUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String s = replyTextMessage(request, response, content, toUserName, fromUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        PrintWriter pw = response.getWriter(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        pw.write(s); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        pw.flush(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -263,13 +271,24 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                                   String content,String toUserName, String fromUserName) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            throws IOException, DocumentException{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if(ModuleConstant.TESTCOMPONENT_MSG_TYPE_TEXT.equals(content)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String returnContent = content+ModuleConstant._CALL_BACK; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            replyTextMessage(request,response,returnContent,toUserName,fromUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            log.info("收到消息,要回复了......"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            String returnContent = content+ModuleConstant._CALL_BACK;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String returnContent = "TESTCOMPONENT_MSG_TYPE_TEXT_callback"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            log.info("拼接的回复内容【普通】:"+returnContent); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String result = replyTextMessage(request, response, returnContent, toUserName, fromUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            log.info("加密的回复内容为:"+result); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            PrintWriter pw = response.getWriter(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            pw.write(result); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            pw.flush(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }else if(StringUtils.startsWithIgnoreCase(content, ModuleConstant.QUERY_AUTH_CODE)){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            response.getWriter().print("");//需在5秒内返回空串表明暂时不回复,然后再立即使用客服消息接口发送消息回复粉丝
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            PrintWriter pw = response.getWriter();//需在5秒内返回空串表明暂时不回复,然后再立即使用客服消息接口发送消息回复粉丝
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            pw.write(""); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            pw.flush(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            log.info(String.format(ThirdRunTimeInfoConstant.TEXT_MESSAGE_LOG_INFO,content,content.split(ThirdRedisKeyConstant.COLON)[NumConstant.ONE],fromUserName,toUserName)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //接下来客服API再回复一次消息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            replyApiTextMessage(content.split(ThirdRedisKeyConstant.COLON)[NumConstant.ONE],toUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String[] split = content.split(ThirdRedisKeyConstant.COLON); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            replyApiTextMessage(split[NumConstant.ONE],fromUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -284,21 +303,30 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param fromUserName  发送人 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @author zxc | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void replyTextMessage(HttpServletRequest request, HttpServletResponse response, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public String replyTextMessage(HttpServletRequest request, HttpServletResponse response, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                                 String content,String toUserName, String fromUserName) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            throws DocumentException, IOException { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Long createTime = System.currentTimeMillis() / NumConstant.ONE_THOUSAND; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        StringBuffer sb = new StringBuffer(512); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        log.info("**********************   encryption start.............."); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        sb.append("<xml>"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        sb.append("<ToUserName><![CDATA["+toUserName+"]]></ToUserName>"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        sb.append("<FromUserName><![CDATA["+fromUserName+"]]></FromUserName>"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        sb.append("<CreateTime>"+createTime.toString()+"</CreateTime>"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        sb.append("<MsgType><![CDATA[text]]></MsgType>"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        sb.append("<CreateTime>"+createTime+"</CreateTime>"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        sb.append("<Content><![CDATA["+content+"]]></Content>"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        sb.append("<MsgType><![CDATA[text]]></MsgType>"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        sb.append("</xml>"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String replyMsg = sb.toString(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        log.info(String.format(ThirdRunTimeInfoConstant.SEND_MESSAGE_XML,replyMsg)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        returnJSON(replyMsg,response); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        WXBizMsgCrypt wxBizMsgCrypt; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String generate = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            wxBizMsgCrypt = new WXBizMsgCrypt(token,aesKey,componentAppId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            generate = wxBizMsgCrypt.encryptMsg(replyMsg, String.valueOf(createTime), wxBizMsgCrypt.getRandomStr()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } catch (AesException e) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            e.printStackTrace(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return generate; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -319,15 +347,20 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        jsonObject.put(ModuleConstant.AUTHORIZATION_CODE, auth_code); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String authInfo = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_QUERY_AUTH_URL + componentAccessToken, JSON.toJSONString(jsonObject)).getData(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        HashMap<String,Map> hashMap = JSON.parseObject(authInfo, HashMap.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (hashMap.containsKey("errcode")){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            throw new RenException("全网发布接入检测【API文本消息回复失败】"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Map map = hashMap.get(ModuleConstant.AUTHORIZATION_INFO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        AuthorizationInfoResultDTO authorizationInfoResultDTO = ConvertUtils.mapToEntity(map, AuthorizationInfoResultDTO.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String authorizer_access_token = authorizationInfoResultDTO.getAuthorizer_access_token(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Map<String,Object> msgMap = new HashMap<String,Object>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String msg = auth_code + "_from_api"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        msgMap.put("content", msg); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        JSONObject json = new JSONObject(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        json.put("touser",fromUserName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        json.put("msgtype", "text"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        json.put("text", "{\"content\":\""+auth_code+ModuleConstant._FROM_API+"\"}"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        json.put("msgtype","text"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        json.put("text",msgMap); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.SEND_MESSAGE_CUSTOM + authorizer_access_token, JSON.toJSONString(json)).getData(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        log.info("客服发送接口返回值:"+data); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -347,7 +380,7 @@ public class WarrantServiceImpl implements WarrantService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            JsonGenerator generator = objectMapper.getJsonFactory(). | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    createJsonGenerator(response.getOutputStream(), encoding); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            objectMapper.writeValue(generator, data); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } catch (IOException e) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } catch (Exception e) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            e.printStackTrace(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |