lrf402788946 4 年 前
コミット
a9587ac03a
2 ファイル変更24 行追加13 行削除
  1. 22 11
      app/service/apply.js
  2. 2 2
      app/service/lesson.js

+ 22 - 11
app/service/apply.js

@@ -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 + '&noticeid=' + notice._id;
-        this.toSendWxMsg(openid, msg, tea.name, tourl);
+        tourl = this.ctx.app.config.baseUrl + '/msgconfirm/?userid=' + teaid + '&noticeid=' + 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);
+        }
+      }
+
+
     }
   }
   /**

+ 2 - 2
app/service/lesson.js

@@ -498,12 +498,12 @@ class LessonService extends CrudService {
       // 邮件
       if (email) {
         const subject = '吉林省高等学校毕业生就业指导中心通知';
-        await this.ctx.service.util.sendMail(email, subject, content);
+        this.ctx.service.util.sendMail(email, subject, content);
       }
       if (openid) {
         const tourl = this.ctx.app.config.baseUrl + '/msgconfirm/?userid=' + notifiedid + '&noticeid=' + nres._id;
         // TODO 推送
-        await this.ctx.service.weixin.sendTemplateDesign(
+        this.ctx.service.weixin.sendTemplateDesign(
           this.ctx.app.config.REVIEW_TEMPLATE_ID,
           openid,
           '您有一个新的通知,请点击信息,确认您已收到信息!',