|
@ -102,15 +102,15 @@ exports.findAllP2PWithPatient = function (userId, handler) {
|
|
|
var sql="SELECT p1. CODE as code , p1. NAME as name, p1.birthday, p1.sex, p1.photo, w.last_content, w.last_content_type, w. TIMESTAMP as timestamp, w.new_msg_count " +
|
|
|
"FROM msg_p2p p, wlyy.wlyy_patient p1, msg_statistic w " +
|
|
|
"WHERE (( p.to_uid = p1.`code` AND p.from_uid = ? ) OR ( p.from_uid = p1.`code` AND p.to_uid = ? )) " +
|
|
|
"AND w.last_content_type IN (1, 2, 3, 5, 6) AND w.uid = ? AND w.peer_uid = p1.`code` AND w.from_gid IS NULL " +
|
|
|
"GROUP BY p1. CODE, p1. NAME, p1.birthday, p1.sex, p1.photo " +
|
|
|
"union all " +
|
|
|
"SELECT p1. CODE AS code, p1. NAME AS name, p1.birthday, p1.sex, p1.photo, w.last_content, t.type, w. TIMESTAMP AS timestamp, w.new_msg_count " +
|
|
|
"FROM msg_p2p p, wlyy.wlyy_patient p1, msg_statistic w, wlyy.wlyy_consult_team t " +
|
|
|
"WHERE (( p.to_uid = p1.`code` AND p.from_uid = ? ) OR ( p.from_uid = p1.`code` AND p.to_uid = ? )) " +
|
|
|
"AND w.last_content_type = 7 AND t.type = 6 " +
|
|
|
"AND (( t.patient = p.from_uid AND t.doctor = p.to_uid ) OR ( t.patient = p.to_uid AND t.doctor = p.from_uid )) " +
|
|
|
"AND w.uid = ? AND w.peer_uid = p1.`code` AND w.from_gid IS NULL GROUP BY p1. CODE, p1. NAME, p1.birthday, p1.sex, p1.photo;";
|
|
|
"AND w.last_content_type IN (0,1, 2, 3, 4, 5, 6) AND w.uid = ? AND w.peer_uid = p1.`code` AND w.from_gid IS NULL " +
|
|
|
"GROUP BY p1. CODE, p1. NAME, p1.birthday, p1.sex, p1.photo " +
|
|
|
"union all " +
|
|
|
"SELECT p1. CODE AS code, p1. NAME AS name, p1.birthday, p1.sex, p1.photo, w.last_content, t.type, w. TIMESTAMP AS timestamp, w.new_msg_count " +
|
|
|
"FROM msg_p2p p, wlyy.wlyy_patient p1, msg_statistic w, wlyy.wlyy_consult_team t " +
|
|
|
"WHERE (( p.to_uid = p1.`code` AND p.from_uid = ? ) OR ( p.from_uid = p1.`code` AND p.to_uid = ? )) " +
|
|
|
"AND w.last_content_type = 7 AND t.type = 6 " +
|
|
|
"AND (( t.patient = p.from_uid AND t.doctor = p.to_uid ) OR ( t.patient = p.to_uid AND t.doctor = p.from_uid )) " +
|
|
|
"AND w.uid = ? AND w.peer_uid = p1.`code` AND w.from_gid IS NULL GROUP BY p1. CODE, p1. NAME, p1.birthday, p1.sex, p1.photo;";
|
|
|
imRepo.execQuery({
|
|
|
"sql": sql,
|
|
|
"args": [userId, userId,userId,userId, userId,userId],
|