|  | @ -25,7 +25,7 @@ let async = require("async");
 | 
	
		
			
				|  |  | const REDIS_KEYS = require('../../include/commons').REDIS_KEYS;
 | 
	
		
			
				|  |  | const SESSION_TYPES = require('../../include/commons').SESSION_TYPES;
 | 
	
		
			
				|  |  | const STICKY_SESSION_BASE_SCORE = require('../../include/commons').STICKY_SESSION_BASE_SCORE;
 | 
	
		
			
				|  |  | const  SESSION_BUSINESS_TYPE = require('../../include/commons').SESSION_BUSINESS_TYPE;
 | 
	
		
			
				|  |  | const SESSION_BUSINESS_TYPE = require('../../include/commons').SESSION_BUSINESS_TYPE;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |     constructor() {
 | 
	
	
		
			
				|  | @ -66,23 +66,23 @@ class Sessions extends RedisModel {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         function callBusinessType(sessionId) {
 | 
	
		
			
				|  |  |             var businessType = SESSION_BUSINESS_TYPE.DOCTOR;
 | 
	
		
			
				|  |  |             for(var j = 0 ;j<participantArray.length;j++)
 | 
	
		
			
				|  |  |                 callIsPatient(j,businessType,participantArray.length);
 | 
	
		
			
				|  |  |             for (var j = 0; j < participantArray.length; j++)
 | 
	
		
			
				|  |  |                 callIsPatient(j, businessType, participantArray.length);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         function callIsPatient(j,businessType,length){
 | 
	
		
			
				|  |  |         function callIsPatient(j, businessType, length) {
 | 
	
		
			
				|  |  |             Users.isPatientId(participantArray[j], function (isPatient) {
 | 
	
		
			
				|  |  |                 if (isPatient) {
 | 
	
		
			
				|  |  |                     businessType = SESSION_BUSINESS_TYPE.PATIENT
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if (length-1 == j||businessType==SESSION_BUSINESS_TYPE.PATIENT) {
 | 
	
		
			
				|  |  |                 if (length - 1 == j || businessType == SESSION_BUSINESS_TYPE.PATIENT) {
 | 
	
		
			
				|  |  |                     callCreate(sessionId, businessType);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             })
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         function callCreate(sessionId,businessType) {
 | 
	
		
			
				|  |  |         function callCreate(sessionId, businessType) {
 | 
	
		
			
				|  |  |             SessionRepo.findOne(sessionId, function (err, res) {
 | 
	
		
			
				|  |  |                 if (res.length > 0) {
 | 
	
		
			
				|  |  |                     let session = res[0];
 | 
	
	
		
			
				|  | @ -90,7 +90,7 @@ class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |                         id: session.id,
 | 
	
		
			
				|  |  |                         name: session.name,
 | 
	
		
			
				|  |  |                         type: session.type,
 | 
	
		
			
				|  |  |                         business_type:session.business_type||businessType,
 | 
	
		
			
				|  |  |                         business_type: session.business_type || businessType,
 | 
	
		
			
				|  |  |                         create_date: session.create_date
 | 
	
		
			
				|  |  |                     });
 | 
	
		
			
				|  |  |                     return;
 | 
	
	
		
			
				|  | @ -100,7 +100,7 @@ class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |                 let sessionKey = RedisModel.makeRedisKey(REDIS_KEYS.Session, sessionId);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 // 保存会话及成员至MySQL中
 | 
	
		
			
				|  |  |                 self.saveSessionToMysql(sessionId, name, type, createDate,businessType, function (err, res) {
 | 
	
		
			
				|  |  |                 self.saveSessionToMysql(sessionId, name, type, createDate, businessType, function (err, res) {
 | 
	
		
			
				|  |  |                     Participants.saveParticipantsToMysql(sessionId, participantArray, function (err, res) {
 | 
	
		
			
				|  |  |                         if (err) {
 | 
	
		
			
				|  |  |                             ModelUtil.emitError(self.eventEmitter, err.message);
 | 
	
	
		
			
				|  | @ -139,8 +139,8 @@ class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |      * @param createDate
 | 
	
		
			
				|  |  |      * @param handler
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     saveSessionToMysql(sessionId, name, type, createDate,businessType, handler) {
 | 
	
		
			
				|  |  |         SessionRepo.saveSession(sessionId, name, type, createDate,businessType, handler);
 | 
	
		
			
				|  |  |     saveSessionToMysql(sessionId, name, type, createDate, businessType, handler) {
 | 
	
		
			
				|  |  |         SessionRepo.saveSession(sessionId, name, type, createDate, businessType, handler);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -333,8 +333,8 @@ class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |         let participants = new Participants();
 | 
	
		
			
				|  |  |         let offset = (page - 1 < 0 ? 0 : page - 1) * size;
 | 
	
		
			
				|  |  |         let count = size;
 | 
	
		
			
				|  |  |         if(page>1||startMsgId){//翻页由于闭区间,需跳过本身数据
 | 
	
		
			
				|  |  |             offset +=1;
 | 
	
		
			
				|  |  |         if (page > 1 || startMsgId) {//翻页由于闭区间,需跳过本身数据
 | 
	
		
			
				|  |  |             offset += 1;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         participants.existsParticipant(sessionId, userId, function (err, res) {
 | 
	
	
		
			
				|  | @ -366,7 +366,7 @@ class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |                                 redis.hmgetAsync(messagesKey, res).then(function (messages) {
 | 
	
		
			
				|  |  |                                     handler(null, messages);
 | 
	
		
			
				|  |  |                                 }).then(function () {
 | 
	
		
			
				|  |  |                                     Sessions.updateParticipantLastFetchTime(sessionId, userId,new Date().getTime());
 | 
	
		
			
				|  |  |                                     Sessions.updateParticipantLastFetchTime(sessionId, userId, new Date().getTime());
 | 
	
		
			
				|  |  |                                 })
 | 
	
		
			
				|  |  |                             }).catch(function (res) {
 | 
	
		
			
				|  |  |                             handler(res, false);
 | 
	
	
		
			
				|  | @ -638,7 +638,7 @@ class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |         redis.zaddAsync(participantsKey, score, userId)
 | 
	
		
			
				|  |  |             .then(function (res) {
 | 
	
		
			
				|  |  |                 logger.info("update participant last fetch time success.");
 | 
	
		
			
				|  |  |                 ParticipantRepo.updateLastTime(new Date(score),sessionId,userId);
 | 
	
		
			
				|  |  |                 ParticipantRepo.updateLastTime(new Date(score), sessionId, userId);
 | 
	
		
			
				|  |  |             })
 | 
	
		
			
				|  |  |             .catch(function (err) {
 | 
	
		
			
				|  |  |                 logger.error("Update participant last fetch time error: ", err);
 |