|
@@ -314,6 +314,8 @@ class ApplyService extends CrudService {
|
|
|
if (teauserList)teauserList = JSON.parse(JSON.stringify(teauserList));
|
|
|
// 发送,此处是根据安排,给教师发.还有一种方案是根据教师,整理安排一起发送
|
|
|
// 查询是否发送过这期的通知
|
|
|
+ // 排序
|
|
|
+ arr = _.orderBy(arr, [ 'day' ], [ 'asc' ]);
|
|
|
for (const l of arr) {
|
|
|
// 教师id,期数,班级名,上课的日期,课程名
|
|
|
const { teaid, term, name, day, subname, termid, classid, type } = l;
|
|
@@ -329,22 +331,20 @@ class ApplyService extends CrudService {
|
|
|
有您的课程安排:${subname}`;
|
|
|
msg = `${msg}\n 如果您无法进行授课,请及时联系中心负责人`;
|
|
|
const { openid } = teauser;
|
|
|
-
|
|
|
- // 邮箱与微信都发送
|
|
|
- const { email } = tea;
|
|
|
- if (email) {
|
|
|
- this.toSendEmail(email, msg, tea.name);
|
|
|
- }
|
|
|
+ let tourl;
|
|
|
+ let to_send = true;
|
|
|
if (openid) {
|
|
|
let notice = await this.nmodel.findOne({ planid, termid, classid, type: '6' });
|
|
|
// 找下是否发过信息
|
|
|
if (notice) {
|
|
|
- // 发过信息,找有没有这个教师
|
|
|
+ // 发过信息,找有没有这个教师
|
|
|
const { notified } = notice;
|
|
|
if (_.isArray(notified)) {
|
|
|
const has_notice = notified.find(f => f.notifiedid === teaid);
|
|
|
- if (has_notice) msg = has_notice;
|
|
|
- else {
|
|
|
+ if (has_notice) {
|
|
|
+ const { status } = has_notice;
|
|
|
+ if (status === '1') to_send = false;
|
|
|
+ } else {
|
|
|
const obj = { notifiedid: teaid, username: _.get(tea, 'name', ''), content: msg };
|
|
|
notice.notified.push(obj);
|
|
|
await notice.save();
|
|
@@ -356,9 +356,20 @@ class ApplyService extends CrudService {
|
|
|
await this.nmodel.create(noticeObj);
|
|
|
notice = await this.nmodel.findOne({ planid, termid, classid, type: '6' });
|
|
|
}
|
|
|
- const tourl = this.ctx.app.config.baseUrl + '/msgconfirm/?userid=' + teaid + '¬iceid=' + notice._id;
|
|
|
- this.toSendWxMsg(openid, msg, tea.name, tourl);
|
|
|
+ tourl = this.ctx.app.config.baseUrl + '/msgconfirm/?userid=' + teaid + '¬iceid=' + notice._id;
|
|
|
}
|
|
|
+ if (to_send) {
|
|
|
+ // 邮箱与微信都发送
|
|
|
+ const { email } = tea;
|
|
|
+ if (email) {
|
|
|
+ this.toSendEmail(email, msg, tea.name);
|
|
|
+ }
|
|
|
+ if (openid) {
|
|
|
+ this.toSendWxMsg(openid, msg, tea.name, tourl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
/**
|