|
@@ -61,9 +61,10 @@ class NoticeService extends CrudService {
|
|
|
// 1,判断有没有openid;2有openid的发送消息,添加记录
|
|
|
if (!_.get(user, 'openid')) continue;
|
|
|
const openid = _.get(user, 'openid');
|
|
|
+ const title = '您有一个新的通知';
|
|
|
const detail = content;
|
|
|
const tourl = this.ctx.app.config.baseUrl + '/trainnotice/?userid=' + user.uid + '¬iceid=' + res.id;
|
|
|
- await this.toSendWithUrl(openid, detail, tourl);
|
|
|
+ await this.toSendWithUrl(title, openid, detail, tourl);
|
|
|
const notified = _.get(res, 'notified', []);
|
|
|
notified.push({ notifiedid: user.uid, username: user.name });
|
|
|
res.notified = notified;
|
|
@@ -173,28 +174,30 @@ class NoticeService extends CrudService {
|
|
|
const useridList = notified.filter(f => f.status === '0').map(i => i.notifiedid);
|
|
|
console.log(useridList);
|
|
|
const userList = await this.umodel.find({ uid: { $in: useridList } });
|
|
|
+ console.log(userList);
|
|
|
for (const user of userList) {
|
|
|
if (!_.get(user, 'openid')) continue;
|
|
|
const openid = _.get(user, 'openid');
|
|
|
const detail = content;
|
|
|
const tourl = this.ctx.app.config.baseUrl + '/trainnotice/?userid=' + user.uid + '¬iceid=' + res.id;
|
|
|
console.log(openid);
|
|
|
- await this.toSendWithUrl(openid, detail, tourl);
|
|
|
+ await this.toSendWithUrl('您有信息需要确认', openid, detail, tourl);
|
|
|
}
|
|
|
} else {
|
|
|
throw new BusinessError(ErrorCode.DATA_NOT_EXIST);
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
- *
|
|
|
+ *发送自定义信息
|
|
|
+ * @param {String} title 标题
|
|
|
* @param {String} openid user表的openid
|
|
|
* @param {String} detail 通知内容
|
|
|
* @param {String} tourl 确认通知地址
|
|
|
*/
|
|
|
- async toSendWithUrl(openid, detail, tourl) {
|
|
|
+ async toSendWithUrl(title, openid, detail, tourl) {
|
|
|
const remark = '感谢您的使用';
|
|
|
const date = await this.ctx.service.util.updatedate();
|
|
|
- this.ctx.service.weixin.sendTemplateDesign(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有未读信息需要确认,请点击确认您已收到信息!', detail, date, remark, tourl);
|
|
|
+ this.ctx.service.weixin.sendTemplateDesign(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, `${title},请点击信息,确认您已收到信息!`, detail, date, remark, tourl);
|
|
|
}
|
|
|
}
|
|
|
|