|
@ -1351,54 +1351,90 @@ class Sessions extends RedisModel {
|
|
|
let patientCount = 0;
|
|
|
let doctorCount = 0;
|
|
|
let patientEndCount = 0;
|
|
|
SessionRepo.findAll(userId, function (err, res) {
|
|
|
// SessionRepo.findUnEndAll(userId, function (err, res) {
|
|
|
if (err) {
|
|
|
if(handler)
|
|
|
{
|
|
|
handler(err,res);
|
|
|
if(type){
|
|
|
SessionRepo.findAllBySessionType(userId, type,function (err, res) {
|
|
|
// SessionRepo.findUnEndAll(userId, function (err, res) {
|
|
|
if (err) {
|
|
|
if(handler)
|
|
|
{
|
|
|
handler(err,res);
|
|
|
return;
|
|
|
}
|
|
|
ModelUtil.logError("getAllSessionsUnreadMessageCount is failed", err);
|
|
|
return;
|
|
|
}
|
|
|
ModelUtil.logError("getAllSessionsUnreadMessageCount is failed", err);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (res && res.length == 0) {
|
|
|
if(handler)
|
|
|
{
|
|
|
handler(err,count);
|
|
|
if (res && res.length == 0) {
|
|
|
if(handler)
|
|
|
{
|
|
|
handler(err,count);
|
|
|
return;
|
|
|
}
|
|
|
ModelUtil.emitOK(self.eventEmitter, {count: count});
|
|
|
return;
|
|
|
}
|
|
|
ModelUtil.emitOK(self.eventEmitter, {count: count});
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
for (let j in res) {
|
|
|
for (let j in res) {
|
|
|
|
|
|
//是否过滤指定类型
|
|
|
if( type != null){
|
|
|
if (res[j].type == SESSION_TYPES.SYSTEM) {
|
|
|
|
|
|
if(type != res[j].type){
|
|
|
if (j == res.length - 1) {
|
|
|
if(handler){
|
|
|
handler(err,count);
|
|
|
return;
|
|
|
}
|
|
|
ModelUtil.emitOK(self.eventEmitter, {count: count, patient: patientCount, doctor: doctorCount});
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
|
|
|
callback(res, j, res[j]);
|
|
|
}
|
|
|
});
|
|
|
}else {
|
|
|
SessionRepo.findAll(userId, function (err, res) {
|
|
|
// SessionRepo.findUnEndAll(userId, function (err, res) {
|
|
|
if (err) {
|
|
|
if(handler)
|
|
|
{
|
|
|
handler(err,res);
|
|
|
return;
|
|
|
}
|
|
|
ModelUtil.logError("getAllSessionsUnreadMessageCount is failed", err);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (res && res.length == 0) {
|
|
|
if(handler)
|
|
|
{
|
|
|
handler(err,count);
|
|
|
return;
|
|
|
}
|
|
|
ModelUtil.emitOK(self.eventEmitter, {count: count});
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (res[j].type == SESSION_TYPES.SYSTEM) {
|
|
|
for (let j in res) {
|
|
|
|
|
|
if (j == res.length - 1) {
|
|
|
if(handler){
|
|
|
handler(err,count);
|
|
|
return;
|
|
|
if (res[j].type == SESSION_TYPES.SYSTEM) {
|
|
|
|
|
|
if (j == res.length - 1) {
|
|
|
if(handler){
|
|
|
handler(err,count);
|
|
|
return;
|
|
|
}
|
|
|
ModelUtil.emitOK(self.eventEmitter, {count: count, patient: patientCount, doctor: doctorCount});
|
|
|
}
|
|
|
ModelUtil.emitOK(self.eventEmitter, {count: count, patient: patientCount, doctor: doctorCount});
|
|
|
continue;
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
|
|
|
callback(res, j, res[j]);
|
|
|
}
|
|
|
});
|
|
|
callback(res, j, res[j]);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
function callback(res, j, session) {
|
|
|
self.getSessionUnreadMessageCount(res[j].id, userId, function (err, con) {
|