lrf402788946 4 jaren geleden
bovenliggende
commit
c57c2dae8a
2 gewijzigde bestanden met toevoegingen van 18 en 10 verwijderingen
  1. 15 7
      app/service/apply.js
  2. 3 3
      app/service/weixin.js

+ 15 - 7
app/service/apply.js

@@ -16,6 +16,7 @@ class ApplyService extends CrudService {
     this.tmodel = this.ctx.model.Teacher;
     this.submodel = this.ctx.model.Subject;
     this.trainmodel = this.ctx.model.Trainplan;
+    this.umodel = this.ctx.model.User;
     this.dayList = [ '日', '一', '二', '三', '四', '五', '六' ];
   }
 
@@ -268,12 +269,17 @@ class ApplyService extends CrudService {
     teaids = _.uniq(teaids);
     // 找到教师信息
     let teaList = await this.tmodel.find({ _id: teaids });
+    // 找到教师用户信息
+    let teauserList = await this.umodel.find({ uid: teaids });
     if (teaList) teaList = JSON.parse(JSON.stringify(teaList));
+    if (teauserList)teauserList = JSON.parse(JSON.stringify(teauserList));
     // 发送,此处是根据安排,给教师发.还有一种方案是根据教师,整理安排一起发送
     for (const l of arr) {
       // 教师id,期数,班级名,上课的日期,课程名
       const { teaid, term, name, day, subname } = l;
       const tea = teaList.find(f => f._id === teaid);
+      const teauser = teauserList.find(f => f.uid === teaid);
+      console.log(teauser);
       // 文案
       const msg = `${_.get(tea, 'name', '')}老师您好:
       吉林省高等学校毕业生就业指导中心-双困生培训系统提醒您:
@@ -281,11 +287,14 @@ class ApplyService extends CrudService {
       ${day}(星期${this.dayList[moment(day).days()]})
       有您的课程安排:${subname}`;
       // 邮箱与微信都发送
-      const { openid, email } = tea;
+      const { email } = tea;
       if (email) {
-        this.toSendEmail('402788946@qq.com', msg, tea.name);
+        // this.toSendEmail(email, msg, tea.name);
+      }
+      const { openid } = teauser;
+      if (openid) {
+        this.toSendWxMsg('ocPqjswkUejZHq2ANriNrFFC7A3I', msg, tea.name);
       }
-      if (openid) this.toSendWxMsg('ocPqjswkUejZHq2ANriNrFFC7A3I', msg, tea.name);
     }
   }
   /**
@@ -299,7 +308,7 @@ class ApplyService extends CrudService {
       console.error(`计划教师发送通知:${teaname}没有email`);
       return;
     }
-    const subject = '吉林省高等学校毕业生就业指导中心通知(测试)'; //
+    const subject = '吉林省高等学校毕业生就业指导中心通知(系统邮件,请勿回复)'; //
     this.ctx.service.util.sendMail(email, subject, content);
   }
   /**
@@ -315,15 +324,14 @@ class ApplyService extends CrudService {
     }
     // TODO or notTODO 发送微信推送记录
     // const tourl = this.ctx.app.config.baseUrl + '/msgconfirm/?userid=' + teacherUser.uid + '&noticeid=' + nresid;
+    console.log('in function:');
     await this.ctx.service.weixin.sendTemplateDesign(
       this.ctx.app.config.REVIEW_TEMPLATE_ID,
       openid,
-      // '您有一个新的通知',
-      '测试信息推送',
+      '您有一个新的通知',
       '您有新的安排',
       content,
       '感谢您的使用'
-      // tourl
     );
   }
 }

+ 3 - 3
app/service/weixin.js

@@ -264,9 +264,9 @@ class WeixinAuthService extends AxiosService {
         },
       },
     };
-    console.log('templateid---' + templateid);
-    console.log('openid---' + openid);
-    console.log('requestData---' + JSON.stringify(requestData));
+    // console.log('templateid---' + templateid);
+    // console.log('openid---' + openid);
+    // console.log('requestData---' + JSON.stringify(requestData));
     const res = await this.ctx.curl(url, {
       method: 'post',
       headers: {