Files

40 lines
881 B
Go
Raw Permalink Normal View History

2025-03-20 22:27:37 +08:00
package task
import (
2025-06-12 23:38:23 +08:00
"context"
2025-08-14 16:56:09 +08:00
"time"
"github.com/v03413/bepusdt/app/log"
"github.com/v03413/bepusdt/app/model"
2025-10-13 11:27:38 +08:00
"github.com/v03413/bepusdt/app/task/notify"
"github.com/v03413/bepusdt/app/utils"
)
2024-09-27 22:01:48 +08:00
func init() {
2025-10-13 11:27:38 +08:00
Register(Task{Duration: time.Second * 3, Callback: notifyRetry})
Register(Task{Duration: time.Second * 30, Callback: notifyRoll})
2024-09-27 22:01:48 +08:00
}
// notifyRetry 回调失败重试
2025-06-12 23:38:23 +08:00
func notifyRetry(context.Context) {
tradeOrders, err := model.GetNotifyFailedTradeOrders()
if err != nil {
2026-01-03 02:07:06 +08:00
log.Task.Error("待回调订单获取失败", err)
2025-06-12 23:38:23 +08:00
return
}
2025-06-12 23:38:23 +08:00
for _, order := range tradeOrders {
next := utils.CalcNextNotifyTime(*order.ConfirmedAt, order.NotifyNum)
2025-06-12 23:38:23 +08:00
if time.Now().Unix() >= next.Unix() {
go notify.Handle(order)
}
}
}
2025-06-12 23:38:23 +08:00
func notifyRoll(context.Context) {
for _, o := range model.GetOrderByStatus(model.OrderStatusWaiting) {
notify.Bepusdt(o)
}
}