30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
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);
|
|
}
|
|
});
|
|
};
|
|
},
|
|
}; |