北斗应用技术培训报名系统
This commit is contained in:
30
app/schedule/auditTask.js
Normal file
30
app/schedule/auditTask.js
Normal file
@@ -0,0 +1,30 @@
|
||||
module.exports = {
|
||||
schedule: {
|
||||
interval: '1h', // 1 小时间隔
|
||||
type: 'all', // 指定所有的 worker 都需要执行
|
||||
},
|
||||
async task(ctx) {
|
||||
const AuditResult = await ctx.model.Audit.findAll({ where: { status: 0 } });
|
||||
if (AuditResult.length != 0) {
|
||||
AuditResult.forEach(async element => {
|
||||
const { identity_card, user_name } = element.dataValues;
|
||||
const check = await ctx.app.redis.get('db3').get(identity_card);
|
||||
if (check == null) {
|
||||
await ctx.curl('http://127.0.0.1:' + 8011 + '/CNTEV', {
|
||||
dataType: 'json',
|
||||
contentType: 'application/x-www-form-urlencoded',
|
||||
method: 'POST',
|
||||
timeout: 3000,
|
||||
data: {
|
||||
idCard: identity_card,
|
||||
name: user_name
|
||||
},
|
||||
});
|
||||
} else {
|
||||
await ctx.service.user.updateCNTEV(identity_card, user_name, JSON.parse(check).real_check);
|
||||
await ctx.app.redis.get('db3').del(identity_card);
|
||||
}
|
||||
});
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user