hi-server/queue/logic/iap/dailyReconcileLogic.go
shanshanzhong 7a3a53f1a9
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m47s
ipa
2026-03-08 05:12:28 -07:00

28 lines
992 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package iap
import (
"context"
"time"
"github.com/hibiken/asynq"
"github.com/perfect-panel/server/internal/svc"
"github.com/perfect-panel/server/pkg/logger"
)
// DailyReconcileLogic 第三层:日终全量对账(每天 02:00
// 扫描过去 48h 内所有未支付的 IAP 订单(含 trade_no 为空的极端情况)
type DailyReconcileLogic struct {
inner *ReconcileLogic
}
func NewDailyReconcileLogic(svc *svc.ServiceContext) *DailyReconcileLogic {
return &DailyReconcileLogic{inner: &ReconcileLogic{svc: svc}}
}
func (l *DailyReconcileLogic) ProcessTask(ctx context.Context, _ *asynq.Task) error {
logger.Infof("[IAPDailyReconcile] start at %s", time.Now().Format("2006-01-02 15:04:05"))
// 第三层:扫描 1min ~ 48htrade_no 非空trade_no 为空说明客户端从未上传过 token服务端无法主动补单
// 实际上与第二层的区别是时间窗口:覆盖全天的遗漏
return l.inner.reconcile(ctx, 1*time.Minute, 48*time.Hour, true)
}