Bläddra i källkod

新增请假通过或拒绝通知

reloaded 5 år sedan
förälder
incheckning
33793ef91f
1 ändrade filer med 14 tillägg och 3 borttagningar
  1. 14 3
      app/service/leave.js

+ 14 - 3
app/service/leave.js

@@ -47,9 +47,9 @@ class LeaveService extends CrudService {
     }
     if (status) {
       const student = await this.smodel.findById(studentid);
-      const detail = student.name + '的请假申请已通过,请及时查收!';
       const remark = '感谢您的使用';
-      if (status === 1) {
+      if (status === '1') {
+        const detail = student.name + '的请假申请已通过,请及时查收!';
         const users = await this.umodel.find({ type: '0' });
         for (const user of users) {
           const openid = user.openid;
@@ -60,10 +60,21 @@ class LeaveService extends CrudService {
         const headteacherid = _class.headteacherid;
         const headuser = await this.umodel.findOne({ uid: headteacherid });
         const openid = headuser.openid;
+        const date = await this.ctx.service.util.updatedate();
+        await this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark);
+      }
+      if (status === '2') {
+        const detail = '您的请假申请已被拒绝,拒绝原因为:' + refcause;
+        const stuuser = await this.umodel.findOne({ uid: studentid });
+        const openid = stuuser.openid;
+        const date = await this.ctx.service.util.updatedate();
         await this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark);
       }
     }
-
+    if (refcause) {
+      leave.refcause = refcause;
+    }
+    return await leave.save();
   }
 
 }