constsql='SELECT * FROM `msghistory` WHERE id < :maxId AND ((senderId = :senderId AND targetId = :targetId) OR (targetId = :senderId AND senderId = :targetId)) ORDER BY id DESC LIMIT :pageSize ';
constparams={senderId,targetId,maxId,pageSize};
constlist=awaitthis.dao.customQuery(sql,params);
if(!list||list.length==0){
return[];
}
constlicenseIds=[];
constmsgIds=[];
list.forEach((item)=>{
if(item.msgType=='mryzLicense'){
licenseIds.push(Number(item.businessLicense_id));
}
msgIds.push(item.id);
});
if(licenseIds.length>0){
constlicenseSql=`SELECT * FROM yz_business_license WHERE id IN (${licenseIds.join(',')}) `;
constuserList=awaitthis.userDao.customQuery(`SELECT * FROM p_user WHERE id IN (${userIds.join(',')}) `);
userList.forEach((item)=>{
userMap[`id${item.id}`]=item;
});
}
// 未读消息数量
constunreadList=awaitthis.userDao.customQuery(`SELECT senderId, COUNT(1) AS num FROM \`msghistory\` WHERE isRead = 0 AND targetId = ${userId} GROUP BY senderId `);