|  | @ -83,6 +83,7 @@ class Patient extends BaseModel {
 | 
	
		
			
				|  |  |                 let patientClient = clientCache.findById(message.to);
 | 
	
		
			
				|  |  |                 if (!patientClient) {
 | 
	
		
			
				|  |  |                     log.warn("User is not online, user id: ", message.to);
 | 
	
		
			
				|  |  |                     //发送微信模板消息
 | 
	
		
			
				|  |  |                     self.sendConsultWechatReplyTempMsg(message);
 | 
	
		
			
				|  |  |                     return;
 | 
	
		
			
				|  |  |                 }
 | 
	
	
		
			
				|  | @ -108,7 +109,7 @@ class Patient extends BaseModel {
 | 
	
		
			
				|  |  |      * @param message
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     sendConsultWechatReplyTempMsg(message) {
 | 
	
		
			
				|  |  |         // 推送微信模板消息
 | 
	
		
			
				|  |  |         // 查询居民openid
 | 
	
		
			
				|  |  |         patientRepo.getPatientOpenid(message.to, function (err, result) {
 | 
	
		
			
				|  |  |             if (err) {
 | 
	
		
			
				|  |  |                 modelUtil.emitDbError(self.eventEmitter, "get patient openid failed", err);
 | 
	
	
		
			
				|  | @ -118,28 +119,72 @@ class Patient extends BaseModel {
 | 
	
		
			
				|  |  |             var openid = result && result.length > 0 ? result[0].openid : "";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (openid) {
 | 
	
		
			
				|  |  |                 // 查询医生信息
 | 
	
		
			
				|  |  |                 doctorRepo.getDoctorInfo(message.from, function (err, result) {
 | 
	
		
			
				|  |  |                     if (err) {
 | 
	
		
			
				|  |  |                         modelUtil.emitDbError(self.eventEmitter, "get doctor info failed", err);
 | 
	
		
			
				|  |  |                         return;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     if (result && result.length > 0) {
 | 
	
		
			
				|  |  |                         var name = result[0].name;
 | 
	
		
			
				|  |  |                         var msg = {
 | 
	
		
			
				|  |  |                             touser: openid,
 | 
	
		
			
				|  |  |                             template_id: config.wechatConfig.template.consultTemplate,
 | 
	
		
			
				|  |  |                             url: config.wechatConfig.baseUrl + "/wx/html/yszx/html/consulting-doctor.html?openid=" + openid +
 | 
	
		
			
				|  |  |                             "&consult=" + "" + "&toUser=" + message.to,
 | 
	
		
			
				|  |  |                             data: {
 | 
	
		
			
				|  |  |                                 first: {value: "您的健康咨询有新的回复", color: "#000000"}
 | 
	
		
			
				|  |  |                                 , remark: {value: "", color: "#000000"}
 | 
	
		
			
				|  |  |                                 , keyword1: {value: "XXXX咨询", color: "#000000"}
 | 
	
		
			
				|  |  |                                 , keyword2: {value: "XXXX回复", color: "#000000"}
 | 
	
		
			
				|  |  |                                 , keyword3: {value: name, color: "#000000"}
 | 
	
		
			
				|  |  |                         // 查询医生与居民对应的咨询信息
 | 
	
		
			
				|  |  |                         patientRepo.getPatientDoctorConsult(message.to, message.from, function (err, result) {
 | 
	
		
			
				|  |  |                             if (err) {
 | 
	
		
			
				|  |  |                                 modelUtil.emitDbError(self.eventEmitter, "get patient and doctor consult info failed", err);
 | 
	
		
			
				|  |  |                                 return;
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         };
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         wechatUtil.sendWxTemplateMessage(msg);
 | 
	
		
			
				|  |  |                             var consult = result && result.length > 0 ? result[0] : "";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                             if (consult) {
 | 
	
		
			
				|  |  |                                 var replyContent = message.content;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                                 switch(message.contentType){
 | 
	
		
			
				|  |  |                                     case CONTENT_TYPES.Image:
 | 
	
		
			
				|  |  |                                         replyContent = "[图片]";
 | 
	
		
			
				|  |  |                                         break;
 | 
	
		
			
				|  |  |                                     case CONTENT_TYPES.Audio:
 | 
	
		
			
				|  |  |                                         replyContent = "[语音]";
 | 
	
		
			
				|  |  |                                         break;
 | 
	
		
			
				|  |  |                                     case CONTENT_TYPES.Article:
 | 
	
		
			
				|  |  |                                         replyContent = "[文章]";
 | 
	
		
			
				|  |  |                                         break;
 | 
	
		
			
				|  |  |                                     case CONTENT_TYPES.GoTo:
 | 
	
		
			
				|  |  |                                         replyContent = "[链接]";
 | 
	
		
			
				|  |  |                                         break;
 | 
	
		
			
				|  |  |                                     case CONTENT_TYPES.SessionBegin:
 | 
	
		
			
				|  |  |                                         return;
 | 
	
		
			
				|  |  |                                         break;
 | 
	
		
			
				|  |  |                                     case CONTENT_TYPES.SessionEnd:
 | 
	
		
			
				|  |  |                                         return;
 | 
	
		
			
				|  |  |                                         break;
 | 
	
		
			
				|  |  |                                     default:
 | 
	
		
			
				|  |  |                                         return;
 | 
	
		
			
				|  |  |                                         break;
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                                 // 模板消息数据
 | 
	
		
			
				|  |  |                                 var msg = {
 | 
	
		
			
				|  |  |                                     touser: openid,
 | 
	
		
			
				|  |  |                                     template_id: config.wechatConfig.template.consultTemplate,
 | 
	
		
			
				|  |  |                                     url: config.wechatConfig.baseUrl + "/wx/html/yszx/html/consulting-doctor.html?openid=" + openid +
 | 
	
		
			
				|  |  |                                     "&consult=" + consult.consult + "&toUser=" + message.to,
 | 
	
		
			
				|  |  |                                     data: {
 | 
	
		
			
				|  |  |                                         first: {value: "您的健康咨询有新的回复", color: "#000000"}
 | 
	
		
			
				|  |  |                                         , remark: {value: "", color: "#000000"}
 | 
	
		
			
				|  |  |                                         , keyword1: {value: consult.symptoms, color: "#000000"}
 | 
	
		
			
				|  |  |                                         , keyword2: {value: replyContent, color: "#000000"}
 | 
	
		
			
				|  |  |                                         , keyword3: {value: name, color: "#000000"}
 | 
	
		
			
				|  |  |                                     }
 | 
	
		
			
				|  |  |                                 };
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                                 // 发送模板消息
 | 
	
		
			
				|  |  |                                 wechatUtil.sendWxTemplateMessage(msg);
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         });
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         modelUtil.emitDbError(self.eventEmitter, "can not find doctor info", err);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 });
 | 
	
		
			
				|  |  |             } else {
 |