All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m34s
28 lines
993 B
Go
28 lines
993 B
Go
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 ~ 48h,trade_no 非空(trade_no 为空说明客户端从未上传过 token,服务端无法主动补单)
|
||
// 实际上与第二层的区别是时间窗口:覆盖全天的遗漏
|
||
return l.inner.reconcile(ctx, 1*time.Minute, 48*time.Hour, false)
|
||
}
|