'use strict'; const Subscription = require('egg').Subscription; // 2023/2/2 提现结果定时查询任务 class UpdateCashOutLog extends Subscription { // 通过 schedule 属性来设置定时任务的执行间隔等配置 static get schedule() { return { interval: '60m', // 60 分钟间隔 // interval: '3s', // 10s type: 'all', // 指定所有的 worker 都需要执行 }; } // subscribe 是真正定时任务执行时被运行的函数 async subscribe() { const that = this; // 2023/2/2 查询正在转账中的分佣提现记录 const result = await that.service.cash.getCommissionCashingLog(); // 2023/2/2 查询 提现结果并更新记录 if (result.length) { for (let i = 0; i < result.length; i++) { await that.service.wxPay.getTransferResult({ out_batch_no: result[i].out_batch_no, out_detail_no: result[i].out_detail_no, user_id: result[i].user_id, cash: result[i].cash, }); } } // 2023/2/2 查询正在转账中的餐币提现记录 const result2 = await that.service.cash.getCoinsCashingLog(); // 2023/2/2 查询 提现结果并更新记录 if (result2.length) { for (let i = 0; i < result2.length; i++) { await that.service.businessPayService.getTransferResult({ out_batch_no: result2[i].out_batch_no, out_detail_no: result2[i].out_detail_no, user_id: result2[i].user_id, cash: result2[i].cash, }); } } } } module.exports = UpdateCashOutLog;