|  | @ -16,7 +16,7 @@ let configFile = require('../../include/commons').CONFIG_FILE;
 | 
	
		
			
				|  |  | let config = require('../../resources/config/' + configFile);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | const REDIS_KEYS = require('../../include/commons').REDIS_KEYS;
 | 
	
		
			
				|  |  | const SESSION_USER_STATUS = require('../../include/commons').SESSION_USER_STATUS;
 | 
	
		
			
				|  |  | const TOPIC_STATUS = require('../../include/commons').TOPIC_STATUS;
 | 
	
		
			
				|  |  | const SESSION_TYPES = require('../../include/commons').SESSION_TYPES;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | class Topics extends RedisModel {
 | 
	
	
		
			
				|  | @ -74,7 +74,7 @@ class Topics extends RedisModel {
 | 
	
		
			
				|  |  |         let date = new Date();
 | 
	
		
			
				|  |  |         var pars=[];
 | 
	
		
			
				|  |  |         redis.zaddAsync(topics_key, date.getTime(), topicId).then(function (res) {
 | 
	
		
			
				|  |  |             redis.hmsetAsync(topic_key, "name", topicName, "end_by", "", "session_id", sessionId, "create_time", date.getTime(), "end_time", "", "description", messages.description).then(function (res) {
 | 
	
		
			
				|  |  |             redis.hmsetAsync(topic_key, "name", topicName, "end_by", "", "session_id", sessionId, "create_time", date.getTime(), "end_time", "", "description", messages.description, "status", TOPIC_STATUS.NEW).then(function (res) {
 | 
	
		
			
				|  |  |                 sessions.getSessions(sessionId, function (err, res) {
 | 
	
		
			
				|  |  |                     //已经存在对应的会话更新全科为旁听
 | 
	
		
			
				|  |  |                     if (res && res.length > 0) {
 | 
	
	
		
			
				|  | @ -94,7 +94,7 @@ class Topics extends RedisModel {
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 })
 | 
	
		
			
				|  |  |             })
 | 
	
		
			
				|  |  |         });
 | 
	
		
			
				|  |  |         }).catch();
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |         /**
 | 
	
		
			
				|  |  |          * 开始消息发送
 | 
	
	
		
			
				|  | @ -110,7 +110,7 @@ class Topics extends RedisModel {
 | 
	
		
			
				|  |  |                 if (err) {
 | 
	
		
			
				|  |  |                     ModelUtil.emitOK(self.eventEmitter, err);
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     self.saveTopicsToSql(topicName, topicId, sessionId, msgId, date);
 | 
	
		
			
				|  |  |                     self.saveTopicsToSql(topicName, topicId, sessionId, msgId, date,messages.description,TOPIC_STATUS.NEW);
 | 
	
		
			
				|  |  |                     callBeginMsg(msgId);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             })
 | 
	
	
		
			
				|  | @ -148,8 +148,8 @@ class Topics extends RedisModel {
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     saveTopicsToSql(topicName, topicId, sessionId, messageId, date) {
 | 
	
		
			
				|  |  |         TopicsRepo.saveTopic(topicName, topicId, sessionId, messageId, date);
 | 
	
		
			
				|  |  |     saveTopicsToSql(topicName, topicId, sessionId, messageId, date,description) {
 | 
	
		
			
				|  |  |         TopicsRepo.saveTopic(topicName, topicId, sessionId, messageId, date,description);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -161,7 +161,7 @@ class Topics extends RedisModel {
 | 
	
		
			
				|  |  |         let endDate = new Date();
 | 
	
		
			
				|  |  |         let self = this;
 | 
	
		
			
				|  |  |         let topic_key = RedisModel.makeRedisKey(REDIS_KEYS.Topic, topicId);
 | 
	
		
			
				|  |  |         redis.hmsetAsync(topic_key, "end_time", endDate.getTime(), "end_by", endUser).then(function (res) {
 | 
	
		
			
				|  |  |         redis.hmsetAsync(topic_key, "end_time", endDate.getTime(), "end_by", endUser,"status",TOPIC_STATUS.FINISHED).then(function (res) {
 | 
	
		
			
				|  |  |             redis.hgetallAsync(topic_key).then(function (topic) {
 | 
	
		
			
				|  |  |                 callEnd(topic.session_id);
 | 
	
		
			
				|  |  |             })
 | 
	
	
		
			
				|  | @ -172,9 +172,9 @@ class Topics extends RedisModel {
 | 
	
		
			
				|  |  |          */
 | 
	
		
			
				|  |  |         function callEnd(sessionId) {
 | 
	
		
			
				|  |  |             let msg = {};
 | 
	
		
			
				|  |  |             msg.senderId = endUser;
 | 
	
		
			
				|  |  |             msg.senderName = endUserName;
 | 
	
		
			
				|  |  |             msg.contentType = 7;
 | 
	
		
			
				|  |  |             msg.sender_id = endUser;
 | 
	
		
			
				|  |  |             msg.sender_name = endUserName;
 | 
	
		
			
				|  |  |             msg.content_type = 7;
 | 
	
		
			
				|  |  |             msg.content = endUserName + "结束了咨询"
 | 
	
		
			
				|  |  |             msg.timestamp = new Date();
 | 
	
		
			
				|  |  |             let sessions = new Sessions();
 | 
	
	
		
			
				|  | @ -188,6 +188,19 @@ class Topics extends RedisModel {
 | 
	
		
			
				|  |  |             })
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     updateTopic(topicId,valueJson){
 | 
	
		
			
				|  |  |         let self = this;
 | 
	
		
			
				|  |  |         let topic_key = RedisModel.makeRedisKey(REDIS_KEYS.Topic, topicId);
 | 
	
		
			
				|  |  |         var dataArray = [];
 | 
	
		
			
				|  |  |         for(var j in valueJson){
 | 
	
		
			
				|  |  |             dataArray.push(j);
 | 
	
		
			
				|  |  |             dataArray.push(valueJson[j]);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         redis.hmsetAsync(topic_key, dataArray).then(function (res) {
 | 
	
		
			
				|  |  |             TopicsRepo.updateTopis(topicId,valueJson);
 | 
	
		
			
				|  |  |         });
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | // Expose class
 |