|
@@ -22,11 +22,13 @@ class LeaveService extends CrudService {
|
|
|
const student = await this.smodel.findById(studentid);
|
|
|
const schoolid = student.schoolid;
|
|
|
const user = await this.umodel.findOne({ uid: schoolid, type: '2' });
|
|
|
- const openid = user.openid;
|
|
|
- const date = await this.ctx.service.util.updatedate();
|
|
|
- const detail = student.name + '发起了请假请求,请及时处理';
|
|
|
- const remark = '感谢您的使用';
|
|
|
- await this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark);
|
|
|
+ if (user) {
|
|
|
+ const openid = user.openid;
|
|
|
+ const date = await this.ctx.service.util.updatedate();
|
|
|
+ const detail = student.name + '发起了请假请求,请及时处理';
|
|
|
+ const remark = '感谢您的使用';
|
|
|
+ await this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark);
|
|
|
+ }
|
|
|
return await this.fetch({ id: entity.id });
|
|
|
}
|
|
|
|
|
@@ -61,13 +63,14 @@ class LeaveService extends CrudService {
|
|
|
const _class = await this.cmodel.findById(student.classid);
|
|
|
const headteacherid = _class.headteacherid;
|
|
|
const headuser = await this.umodel.findOne({ uid: headteacherid, type: '1' });
|
|
|
- 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);
|
|
|
-
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
if (status === '2') {
|
|
|
const detail = '您的请假申请已被拒绝,拒绝原因为:' + refcause;
|