Browse Source

给班主任发送通知修改

lrf402788946 4 years ago
parent
commit
ee129f01a0
1 changed files with 11 additions and 11 deletions
  1. 11 11
      app/service/notice.js

+ 11 - 11
app/service/notice.js

@@ -50,7 +50,7 @@ class NoticeService extends CrudService {
         personList = [ ...sList, ...tList, ...hList ];
       } else if (type === '1') personList = await this.getRangeStudent({ classid });
       else if (type === '2') personList = await this.getRangeTeacher({ classid });
-      else if (type === '3') personList = await this.getRangeClasses({ id: classid });
+      else if (type === '3') personList = await this.getRangeClasses({ _id: classid });
     }
     personList = personList.map(i => i._id);
     // 获取所有人后发送信息
@@ -63,8 +63,8 @@ class NoticeService extends CrudService {
       const openid = _.get(user, 'openid');
       const title = '您有一个新的通知';
       const detail = content;
-      const tourl = this.ctx.app.config.baseUrl + '/trainnotice/?userid=' + user.uid + '&noticeid=' + res.id;
-      await this.toSendWithUrl(title, openid, detail, tourl);
+      const tourl = this.ctx.app.config.baseUrl + '/trainnotice/?userid=' + user.uid + '&noticeid='; // + res.id || ''
+      await this.toSendWithUrl(title, openid, detail, tourl); // openid
       const notified = _.get(res, 'notified', []);
       notified.push({ notifiedid: user.uid, username: user.name });
       res.notified = notified;
@@ -94,19 +94,19 @@ class NoticeService extends CrudService {
   }
 
   /**
-   * 根据条件返回班主任+礼仪教师列表
-   * @param {Object} condition 查询班主任+礼仪教师条件
+   * 根据条件返回班主任 不加礼仪教师列表消息了
+   * @param {Object} condition 查询班主任
    */
-  async getRangeClasses({ _id, termid }) {
+  async getRangeClasses({ _id, ...info }) {
     let resList = [];
-    if (_.id) {
-      const cla = await this.clsmodel.findOne(_id);
-      if (cla) resList.push(cla.headteacherid, cla.lyteacherid);
+    if (_id) {
+      const cla = await this.clsmodel.findOne({ _id: ObjectId(_id) });
+      if (cla) resList.push(cla.headteacherid); // , cla.lyteacherid
     } else {
-      const classesList = await this.clsmodel.find(termid);
+      const classesList = await this.clsmodel.find(info);
       if (classesList) {
         for (const cla of classesList) {
-          resList.push(cla.headteacherid, cla.lyteacherid);
+          resList.push(cla.headteacherid); // , cla.lyteacherid
         }
       }
     }