定时推送账单添加执行日志;
This commit is contained in:
+5
-8
@@ -50,18 +50,15 @@ public class BillingScheduler {
|
||||
continue;
|
||||
} else {
|
||||
// 乐观锁更新状态,防止重复执行
|
||||
int updated = scheduledTaskMapper.updateStatusIfPending(
|
||||
task.getId(), "PENDING", "PROCESSING");
|
||||
//int updated = scheduledTaskMapper.updateStatusIfPending(task.getId(), "PENDING", "PROCESSING");
|
||||
|
||||
if (updated > 0) {
|
||||
// 异步执行具体业务
|
||||
CompletableFuture.runAsync(() -> {
|
||||
executeTask(task);
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
scheduledTaskMapper.updateStatus(task.getId(), "FAILED");
|
||||
//scheduledTaskMapper.updateStatus(task.getId(), "FAILED");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,16 +69,16 @@ public class BillingScheduler {
|
||||
// 执行具体的出账逻辑
|
||||
scheduledTaskService.executeBilling(task.getBusId());
|
||||
|
||||
scheduledTaskMapper.updateStatus(task.getId(), "SUCCESS");
|
||||
//scheduledTaskMapper.updateStatus(task.getId(), "SUCCESS");
|
||||
status = "SUCCESS";
|
||||
} catch (Exception e) {
|
||||
// 重试机制
|
||||
scheduledTaskMapper.incrementRetryCount(task.getId());
|
||||
if (task.getRetryCount() < 3) {
|
||||
scheduledTaskMapper.updateStatus(task.getId(), "PENDING");
|
||||
//scheduledTaskMapper.updateStatus(task.getId(), "PENDING");
|
||||
} else {
|
||||
status = "FAILED";
|
||||
scheduledTaskMapper.updateStatus(task.getId(), "FAILED");
|
||||
//scheduledTaskMapper.updateStatus(task.getId(), "FAILED");
|
||||
}
|
||||
}
|
||||
ScheduledTaskLog log = new ScheduledTaskLog();
|
||||
|
||||
Reference in New Issue
Block a user