|  | @ -100,10 +100,10 @@ exports.findAllP2PWithPatient = function (userId, handler) {
 | 
	
		
			
				|  |  |     //    "WHERE ms.msg_type = 1 AND ms.last_content_type in (1,2,3,5,6) " +
 | 
	
		
			
				|  |  |     //    "AND ((ms.from_uid = ? AND ms.uid = p.code) OR (ms.uid = ? AND ms.from_uid = p.code)) ORDER BY ms.timestamp";
 | 
	
		
			
				|  |  |     var sql="SELECT p1. id 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, ydf.ydf_patient p1, msg_statistic w " +
 | 
	
		
			
				|  |  |              "WHERE (( p.to_uid = p1.`id` AND p.from_uid = ? ) OR ( p.from_uid = p1.`id` AND p.to_uid = ? )) " +
 | 
	
		
			
				|  |  |              "AND w.last_content_type IN (0,1, 2, 3, 4, 5, 6,7) AND w.uid = ? AND w.peer_uid = p1.`id` AND w.from_gid IS NULL " +
 | 
	
		
			
				|  |  |              "GROUP BY p1. id, p1. NAME, p1.birthday, p1.sex, p1.photo " ;
 | 
	
		
			
				|  |  |         "FROM msg_p2p p, ydf.ydf_patient p1, msg_statistic w " +
 | 
	
		
			
				|  |  |         "WHERE (( p.to_uid = p1.`id` AND p.from_uid = ? ) OR ( p.from_uid = p1.`id` AND p.to_uid = ? )) " +
 | 
	
		
			
				|  |  |         "AND w.last_content_type IN (0,1, 2, 3, 4, 5, 6,7) AND w.uid = ? AND w.peer_uid = p1.`id` AND w.from_gid IS NULL " +
 | 
	
		
			
				|  |  |         "GROUP BY p1. id, p1. NAME, p1.birthday, p1.sex, p1.photo " ;
 | 
	
		
			
				|  |  |     imRepo.execQuery({
 | 
	
		
			
				|  |  |         "sql": sql,
 | 
	
		
			
				|  |  |         "args": [userId, userId,userId,userId, userId,userId],
 | 
	
	
		
			
				|  | @ -129,4 +129,22 @@ exports.findUnread = function(from, to, start, count, handler) {
 | 
	
		
			
				|  |  |         "args": [from, to, start, count],
 | 
	
		
			
				|  |  |         "handler": handler
 | 
	
		
			
				|  |  |     });
 | 
	
		
			
				|  |  | };
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * 统计预约数量
 | 
	
		
			
				|  |  |  * @param userId
 | 
	
		
			
				|  |  |  * @param handler
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | exports.countAppo = function (userId, handler) {
 | 
	
		
			
				|  |  |     //var sql = "SELECT p.code, p.name, p.birthday, p.sex, p.photo, ms.last_content_type, ms.last_content, ms.timestamp, ms.new_msg_count " +
 | 
	
		
			
				|  |  |     //    "FROM msg_statistic ms, ydf.ydf_patient p " +
 | 
	
		
			
				|  |  |     //    "WHERE ms.msg_type = 1 AND ms.last_content_type in (1,2,3,5,6) " +
 | 
	
		
			
				|  |  |     //    "AND ((ms.from_uid = ? AND ms.uid = p.code) OR (ms.uid = ? AND ms.from_uid = p.code)) ORDER BY ms.timestamp";
 | 
	
		
			
				|  |  |     var sql="select count(1) as cou FROM ydf_message m,ydf_appointment a where m.appointment_id = a.id and a.`status` = 0 and m.type=201 and m.receiver = ? " ;
 | 
	
		
			
				|  |  |     imRepo.execQuery({
 | 
	
		
			
				|  |  |         "sql": sql,
 | 
	
		
			
				|  |  |         "args": [userId],
 | 
	
		
			
				|  |  |         "handler": handler
 | 
	
		
			
				|  |  |     });
 | 
	
		
			
				|  |  | };
 |