|
@@ -34,7 +34,7 @@ class LeaveService extends CrudService {
|
|
|
|
|
|
async update({ id }, data) {
|
|
|
const leave = await this.model.findById(id);
|
|
|
- const { studentid, starttime, endtime, reason, status, refcause, batchid, termid, classid, planid, stuname, type } = data;
|
|
|
+ const { studentid, starttime, endtime, reason, status, refcause, batchid, termid, classid, planid, stuname } = data;
|
|
|
if (studentid) {
|
|
|
leave.studentid = studentid;
|
|
|
}
|
|
@@ -71,37 +71,37 @@ class LeaveService extends CrudService {
|
|
|
// 通知中心管理员学生请假通过
|
|
|
let detail = student.name + '的请假申请已通过,请及时查收!';
|
|
|
const users = await this.umodel.find({ type: '0' });
|
|
|
- let toOtherMsg = `${student.name}的${type === '1' ? '退出' : '请假'}申请已通过,请及时查收!`;
|
|
|
- if (starttime) toOtherMsg = `${toOtherMsg}\n 时间:${starttime} 至 ${endtime}`;
|
|
|
- if (reason) toOtherMsg = `${toOtherMsg}\n ${type === '1' ? '退出' : '请假'}原因:${reason}`;
|
|
|
- if (refcause) toOtherMsg = `${toOtherMsg}\n 学校反馈:${refcause}`;
|
|
|
+ let toOtherMsg = `${student.name}的${leave.type === '1' ? '退出' : '请假'}申请已通过,请及时查收!`;
|
|
|
+ if (leave.starttime) toOtherMsg = `${toOtherMsg}\n 时间:${leave.starttime} 至 ${leave.endtime || ''}`;
|
|
|
+ if (leave.reason) toOtherMsg = `${toOtherMsg}\n ${leave.type === '1' ? '退出' : '请假'}原因:${leave.reason}`;
|
|
|
+ if (leave.refcause) toOtherMsg = `${toOtherMsg}\n 学校反馈:${leave.refcause}`;
|
|
|
for (const user of users) {
|
|
|
const openid = user.openid;
|
|
|
const date = await this.ctx.service.util.updatedate();
|
|
|
this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', toOtherMsg, 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();
|
|
|
- this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', toOtherMsg, date, remark);
|
|
|
- }
|
|
|
- const leadstu = await this.smodel.findOne({ classid: student.classid, job: '班长' });
|
|
|
- if (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, '您有一个新的通知', toOtherMsg, 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);
|
|
|
+ // 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();
|
|
|
+ // this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', toOtherMsg, date, remark);
|
|
|
+ // }
|
|
|
+ // const leadstu = await this.smodel.findOne({ classid: student.classid, job: '班长' });
|
|
|
+ // if (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, '您有一个新的通知', toOtherMsg, 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') {
|