Commit ab70eebf by lixinming

no message

parent 445713a8
......@@ -159,10 +159,10 @@ export async function systemSendMail(userId, type) {
if (!userInfo || !userInfo.userId) throw new BizError(ERRORENUM.用户不存在);
if (!userInfo.mail) {
new BizError(ERRORENUM.该用户邮箱为空, userId, userInfo.name || userId.unitName);
}
} else {
let nameStr = userInfo.memberType == MEMBERTYPE.个人会员 ? userInfo.name : userInfo.unitName;
let result = await send(userInfo.mail, nameStr, type);
}
return successResult();
}
\ No newline at end of file
......@@ -3,11 +3,11 @@
*/
import moment = require("moment");
import { ACTIVITYSTATE, ACTIVITYTYPE, CLIENTACTIVITYLABLE, CLIENTACTIVITYSTATE, CLIENTMSGLABLE, MAILTYPE, MEMBERLEVEL, MEMBERTYPE, STATE } from "../../config/enum";
import { ACTIVITYSTATE, ACTIVITYTYPE, CHANGEAPPLYTYPE, CLIENTACTIVITYLABLE, CLIENTACTIVITYSTATE, CLIENTMSGLABLE, INFOCHANGEAPPLYTYPE, MAILTYPE, MEMBERLEVEL, MEMBERTYPE, STATE } from "../../config/enum";
import { ERRORENUM } from "../../config/errorEnum";
import { addManyData, addOneData } from "../../data/add";
import { TABLEENUM } from "../../data/models/model";
import { find, findCount, findOnce, findToPage, findToSort, findToSortToPage } from "../../data/select";
import { find, findCount, findOnce, findOnceToSort, findToPage, findToSort, findToSortToPage } from "../../data/select";
import { generateSystemId, getTodayMs, successErrorResult, successResult } from "../../tools/system";
import { BizError } from "../../util/bizError";
import { extractData } from "../../util/piecemeal";
......@@ -218,7 +218,7 @@ export async function delMessage({msgId}) {
*/
export async function noticeMessage({userId}) {
/**非游客用户通知消息条件 */
let userInfo = await findOnce(TABLEENUM.用户表, {userId}, ["lableId", "memberType", "memberLever", "rejectRemarks"]);
let userInfo = await findOnce(TABLEENUM.用户表, {userId}, ["lableId", "memberType", "memberLever", "rejectRemarks", "changeApplyType", "rejectRemarks"]);
if (!userInfo) throw new BizError(ERRORENUM.目标数据不存在);
// if (!userInfo || !userInfo.lableId) return successErrorResult("该会员暂无消息通知标签分类");
......@@ -245,50 +245,108 @@ export async function noticeMessage({userId}) {
let dataList = [];
const SelectFiles = ["msgId", "msgTitle", "effectiveTime", "msgContent", "isPop", "lableId"];
let msgInfo = await findToSort(TABLEENUM.消息通知表, selectParam, {createTime:-1}, SelectFiles);
// let msgInfo = await find(TABLEENUM.消息通知表, selectParam, SelectFiles);
// if (!msgInfo || !msgInfo.msgId) throw new BizError(ERRORENUM.目标数据不存在);
if (msgInfo) {
msgInfo.forEach( info => {
if (!info.msgId) return successErrorResult("该会员暂无消息通知标签分类");
let msgList = await findToSort(TABLEENUM.消息通知表, selectParam, {createTime:-1}, SelectFiles);
let msgReadList = await find(TABLEENUM.消息已读状态表, {userId:userId}, ["readId", "isRead", "msgId"]);
let distinctMap = {};
msgReadList.forEach(info => {
let {msgId} = info;
distinctMap[msgId] = info;
});
}
for(let i = 0; i < msgInfo.length; i++) {
let info = msgInfo[i];
for(let i = 0; i < msgList.length; i++) {
let info = msgList[i];
let item:any = extractData(info, SelectFiles);
item.effectiveTime = moment(item.effectiveTime).format("YYYY-MM-DD");
//会员的消息已读数据
let selectMsgParam:any = {msgId:item.msgId, userId:userId};
// if (!userId) selectMsgParam.userId = userId;
let msgReadOldInfo = await findOnce(TABLEENUM.消息已读状态表, selectMsgParam, ["readId", "isRead"]);
let msgReadInfo:any = {};
/**没有已读状态的用户新建一条消息未读状态 */
if (!msgReadOldInfo) {
/**消息已读Id */
const readId = generateSystemId(TABLEENUM.消息已读状态表, userId);
if (!distinctMap[info.msgId]) {
const ReadId = generateSystemId(TABLEENUM.消息已读状态表, userId);
let addReadInfo = {
readId,
readId:ReadId,
msgId:item.msgId,
userId,
isRead:STATE.
}
await addOneData(TABLEENUM.消息已读状态表, addReadInfo);
msgReadInfo = await findOnce(TABLEENUM.消息已读状态表, selectMsgParam, ["readId", "isRead"]);
item.readId = ReadId;
item.isRead = STATE.;
} else {
msgReadInfo = msgReadOldInfo;
item.readId = distinctMap[info.msgId].readId;
item.isRead = distinctMap[info.msgId].isRead;
}
item.readId = msgReadInfo.readId;
item.isRead = msgReadInfo.isRead;
if (item.lableId.includes(CLIENTMSGLABLE.驳回理事申请) || item.lableId.includes(CLIENTMSGLABLE.驳回常务理事申请)) item.rejectRemarks = userInfo.rejectRemarks
if (item.lableId.includes(CLIENTMSGLABLE.驳回理事申请) || item.lableId.includes(CLIENTMSGLABLE.驳回常务理事申请)) {
item.rejectRemarks = userInfo.rejectRemarks;
}
dataList.push(item);
}
//需要审批消息
if (userInfo.changeApplyType && userInfo.changeApplyType == CHANGEAPPLYTYPE.驳回修改) {
let msgId = `${userInfo.userId}_zwsp`;
let readId = `${userInfo.userId}_zwsp_readId`;
if (!distinctMap[msgId]) {
//创建新的弹窗
let addReadInfo = {
readId,
msgId:msgId,
userId,
isRead:STATE.
}
await addOneData(TABLEENUM.消息已读状态表, addReadInfo);
dataList.push(addReadInfo);
} else {
dataList.push({
msgId,
readId,
userId,
isRead:distinctMap[msgId].isRead
});
}
} else {
//把老消息去掉
let msgId = `${userInfo.userId}_zwsp`;
if (distinctMap[msgId]) {
await deleteOneData(TABLEENUM.消息已读状态表, {msgId} );
}
}
let infomationHistory = await findOnceToSort(TABLEENUM.资料变更审批历史表, {userId}, {createTimeMs:-1});
if (infomationHistory == INFOCHANGEAPPLYTYPE.驳回修改) {
let msgId = `${userInfo.userId}_zlsp`;
let readId = `${userInfo.userId}_zlsp_readId`;
if (!distinctMap[msgId]) {
//创建新的弹窗
let addReadInfo = {
readId,
msgId:msgId,
userId,
isRead:STATE.
}
await addOneData(TABLEENUM.消息已读状态表, addReadInfo);
dataList.push(addReadInfo);
} else {
dataList.push({
msgId,
readId,
userId,
isRead:distinctMap[msgId].isRead
});
}
} else {
//把老消息去掉
let msgId = `${userInfo.userId}_zlsp`;
if (distinctMap[msgId]) {
await deleteOneData(TABLEENUM.消息已读状态表, {msgId} );
}
}
return {dataList};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment