|
@@ -1,5 +1,5 @@
|
|
|
'use strict';
|
|
|
-require('../util/constants');
|
|
|
+const msgvalue = require('../util/constants');
|
|
|
const sd = require('silly-datetime');
|
|
|
const Service = require('egg').Service;
|
|
|
|
|
@@ -56,6 +56,92 @@ class RabbitmqService extends Service {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ async receiveMsgSendWxSch(ex) {
|
|
|
+ const self = this;
|
|
|
+ const { mq } = self.ctx;
|
|
|
+ if (mq) {
|
|
|
+ const ch = await mq.conn.createChannel();
|
|
|
+ try {
|
|
|
+ await ch.assertExchange(ex, self.exType, { durable: self.durable });
|
|
|
+ const q = await ch.assertQueue('', { exclusive: true });
|
|
|
+ console.log('==q=', q);
|
|
|
+
|
|
|
+ await ch.bindQueue(q.queue, ex, '*');
|
|
|
+ ch.consume(q.queue, msg => {
|
|
|
+ console.log('收到消息: ', msg);
|
|
|
+ const result = msg.content.toString();
|
|
|
+
|
|
|
+
|
|
|
+ const headers = msg.properties.headers;
|
|
|
+
|
|
|
+ const path = self.ctx.app.config.baseDir + self.ctx.app.config.corpsDir + headers.userid;
|
|
|
+ const corp = self.ctx.curl(path, {
|
|
|
+ method: 'GET',
|
|
|
+ dataType: 'json',
|
|
|
+ });
|
|
|
+
|
|
|
+ if (corp != null) {
|
|
|
+ self.service.wechat.sendTemplateMsg(msgvalue.REVIEW_TEMPLATE_ID, corp.openid, '您的申请已经得到批复', result, headers.name, '企业申请', headers.remark);
|
|
|
+ }
|
|
|
+ }, { noAck: true });
|
|
|
+ } catch (e) {
|
|
|
+ console.log('==e==', e);
|
|
|
+ await ch.close();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.ctx.logger.error('!!!!!!没有配置MQ插件!!!!!!');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ async receiveMsgSendWxCorp(ex) {
|
|
|
+ const self = this;
|
|
|
+ const { mq } = self.ctx;
|
|
|
+ if (mq) {
|
|
|
+ const ch = await mq.conn.createChannel();
|
|
|
+ try {
|
|
|
+ await ch.assertExchange(ex, self.exType, { durable: self.durable });
|
|
|
+ const q = await ch.assertQueue('', { exclusive: true });
|
|
|
+ console.log('==q=', q);
|
|
|
+
|
|
|
+ await ch.bindQueue(q.queue, ex, '*');
|
|
|
+ ch.consume(q.queue, msg => {
|
|
|
+ console.log('收到消息: ', msg);
|
|
|
+ const result = msg.content.toString();
|
|
|
+
|
|
|
+
|
|
|
+ const headers = msg.properties.headers;
|
|
|
+
|
|
|
+
|
|
|
+ const path = 'http://10.16.5.15:8101/api/studentcorp' + headers.userid;
|
|
|
+ const stus = self.ctx.curl(path, {
|
|
|
+ method: 'GET',
|
|
|
+ dataType: 'json',
|
|
|
+ });
|
|
|
+ for (const elem of stus.data) {
|
|
|
+
|
|
|
+ const pathStu = self.ctx.app.config.baseDir + self.ctx.app.config.strDir + elem.id;
|
|
|
+ const stud = self.ctx.curl(pathStu, {
|
|
|
+ method: 'GET',
|
|
|
+ dataType: 'json',
|
|
|
+ });
|
|
|
+
|
|
|
+ if (result != null) {
|
|
|
+ self.service.wechat.sendTemplateMsg(msgvalue.REVIEW_TEMPLATE_ID, stud.data.openid, '您订阅的企业已经有新职位发布', result, headers.name, '职位发布', headers.remark);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }, { noAck: true });
|
|
|
+ } catch (e) {
|
|
|
+ console.log('==e==', e);
|
|
|
+ await ch.close();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.ctx.logger.error('!!!!!!没有配置MQ插件!!!!!!');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
module.exports = RabbitmqService;
|