Browse Source

Merge branch 'master' of http://git.cc-lotus.info/new_train/service-center

liuyu 5 years ago
parent
commit
03aacbfad9
1 changed files with 7 additions and 2 deletions
  1. 7 2
      app/service/trainplan.js

+ 7 - 2
app/service/trainplan.js

@@ -54,6 +54,7 @@ class TrainplanService extends CrudService {
     }
     // 如果培训计划状态改为发布
     if (status === '1') {
+      trainplan.status = status;
       // 查询所有入库的教师
       const teachers = await this.tmodel.find({ status: '4' });
       for (const teacher of teachers) {
@@ -65,7 +66,9 @@ class TrainplanService extends CrudService {
         let date = new Date();
         date = moment(date).format('YYYY-MM-DD HH:mm:ss');
         const remark = '感谢您的使用';
-        this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark);
+        if (openid) {
+          this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark);
+        }
       }
       // 查询所有学校用户
       const schools = await this.umodel.find({ type: '2' });
@@ -76,7 +79,9 @@ class TrainplanService extends CrudService {
         let date = new Date();
         date = moment(date).format('YYYY-MM-DD HH:mm:ss');
         const remark = '感谢您的使用';
-        this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark);
+        if (openid) {
+          this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark);
+        }
       }
     }
     return await trainplan.save();