lrf402788946 4 سال پیش
والد
کامیت
77f7ff4420
2فایلهای تغییر یافته به همراه27 افزوده شده و 8 حذف شده
  1. 3 2
      app/service/class.js
  2. 24 6
      app/service/lesson.js

+ 3 - 2
app/service/class.js

@@ -411,8 +411,9 @@ class ClassService extends CrudService {
       const tClassBatch = await this.query({ termid, batchid });
       const r = tClassBatch.find(f => ObjectId(tClass._id).equals(f._id));
       const ri = tClassBatch.findIndex(f => ObjectId(tClass._id).equals(f._id));
-      if (r) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '无法确定班级批次排序');
-      else {
+      // TODO 特殊班需要判断,如果没有就没有
+      // if (r) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '无法确定班级批次排序');
+      if (!r) {
         const { batch: tAllClassBatch } = r;
         const templateBatchList = templateList.filter(f => f.batch === tAllClassBatch);
         // 根据该班级所在批次的顺序,找到对应模板,然后复制

+ 24 - 6
app/service/lesson.js

@@ -389,8 +389,14 @@ class LessonService extends CrudService {
       }
     }
     // 查出openid,email
-    const { openid, email } = await this.getSendInfo(headteacherid);
-    return { openid, email, notifiedid: headteacherid, username: headteacher, content: msg, ncontent: `${term}期-${batch}批-${name.includes('班') ? name : `${name}班`}课表确认` };
+    const info = await this.getSendInfo(headteacherid);
+    const obj = { notifiedid: headteacherid, username: headteacher, content: msg, ncontent: `${term}期-${batch}批-${name.includes('班') ? name : `${name}班`}课表确认` };
+    if (info) {
+      const { openid, email } = info;
+      obj.openid = openid;
+      obj.email = email;
+    }
+    return obj;
   }
   // 给教师发送信息
   async getTeacherMsg(classInfo, lessonInfo) {
@@ -417,8 +423,14 @@ class LessonService extends CrudService {
         }
       }
     }
-    const { openid, email } = await this.getSendInfo(lessonInfo.teaid);
-    return { openid, email, notifiedid: _.get(lessonInfo, 'teaid'), username: _.get(lessonInfo, 'teaname'), content: msg, ncontent: `${term}期-${batch}批-${name.includes('班') ? name : `${name}班`}课表确认` };
+    const info = await this.getSendInfo(lessonInfo.teaid);
+    const obj = { notifiedid: _.get(lessonInfo, 'teaid'), username: _.get(lessonInfo, 'teaname'), content: msg, ncontent: `${term}期-${batch}批-${name.includes('班') ? name : `${name}班`}课表确认` };
+    if (info) {
+      const { openid, email } = info;
+      obj.openid = openid;
+      obj.email = email;
+    }
+    return obj;
   }
 
   // 给礼仪教师发送信息
@@ -437,8 +449,14 @@ class LessonService extends CrudService {
         }
       }
     }
-    const { openid, email } = await this.getSendInfo(lyteacherid);
-    return { openid, email, notifiedid: lyteacherid, username: lyteacher, content: msg, ncontent: `${term}期-${batch}批-${name.includes('班') ? name : `${name}班`}课表确认` };
+    const info = await this.getSendInfo(lyteacherid);
+    const obj = { notifiedid: lyteacherid, username: lyteacher, content: msg, ncontent: `${term}期-${batch}批-${name.includes('班') ? name : `${name}班`}课表确认` };
+    if (info) {
+      const { openid, email } = info;
+      obj.openid = openid;
+      obj.email = email;
+    }
+    return obj;
   }
 
   // 查找openid和emaiil