|
@@ -49,28 +49,40 @@ class LeaveService extends CrudService {
|
|
|
}
|
|
|
if (status) {
|
|
|
leave.status = status;
|
|
|
- const student = await this.smodel.findById(studentid);
|
|
|
+ const student = await this.smodel.findById(leave.studentid);
|
|
|
const remark = '感谢您的使用';
|
|
|
- const stuuser = await this.umodel.findOne({ uid: studentid, type: '4' });
|
|
|
+ const stuuser = await this.umodel.findOne({ uid: leave.studentid, type: '4' });
|
|
|
if (status === '1') {
|
|
|
+ // 通知中心管理员学生请假通过
|
|
|
let detail = student.name + '的请假申请已通过,请及时查收!';
|
|
|
const users = await this.umodel.find({ type: '0' });
|
|
|
for (const user of users) {
|
|
|
const openid = user.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);
|
|
|
+ this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark);
|
|
|
}
|
|
|
const _class = await this.cmodel.findById(student.classid);
|
|
|
+ // 通知班主任学生请假通过
|
|
|
const headteacherid = _class.headteacherid;
|
|
|
const headuser = await this.umodel.findOne({ uid: headteacherid, type: '1' });
|
|
|
if (headuser) {
|
|
|
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);
|
|
|
- const stuopenid = stuuser.openid;
|
|
|
- detail = '您的请假申请已通过,请及时查收!';
|
|
|
- await this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, stuopenid, '您有一个新的通知', detail, date, remark);
|
|
|
+ this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark);
|
|
|
}
|
|
|
+ const leadstu = await this.smodel.findOne({ classid: student.classid, job: '班长' });
|
|
|
+ console.log(leadstu);
|
|
|
+ const leaduser = await await this.umodel.findOne({ uid: leadstu.id, type: '4' });
|
|
|
+ if (leaduser) {
|
|
|
+ const openid = leaduser.openid;
|
|
|
+ const date = await this.ctx.service.util.updatedate();
|
|
|
+ this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark);
|
|
|
+ }
|
|
|
+ const stuopenid = stuuser.openid;
|
|
|
+ detail = '您的请假申请已通过,请及时查收!';
|
|
|
+ const date = await this.ctx.service.util.updatedate();
|
|
|
+ await this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, stuopenid, '您有一个新的通知', detail, date, remark);
|
|
|
+
|
|
|
}
|
|
|
if (status === '2') {
|
|
|
const detail = '您的请假申请已被拒绝,拒绝原因为:' + refcause;
|