package earn import ( "context" "github.com/robfig/cron/v3" "github.com/spf13/cast" "github.com/zeromicro/go-zero/core/logx" "nova_task/internal/consts" "nova_task/internal/logic/earn" "nova_task/internal/svc" ) // Cron 用户数据上报earn平台定时任务 type Cron struct { ctx context.Context svcCtx *svc.ServiceContext } func NewCron(ctx context.Context, svcCtx *svc.ServiceContext) cron.Job { e := &Cron{ctx: ctx, svcCtx: svcCtx} if e.svcCtx.Config.EarnCorn.RunOnStart { e.Run() } return e } func (c *Cron) Spec() string { return c.svcCtx.Config.EarnCorn.Spec } func (c *Cron) Run() { logx.Debugw("run earn cron task") conf, err := c.svcCtx.ConfigModel.FindOneByName(c.ctx, consts.EarnAllianceInviterId) if err != nil { logx.Errorw("find earn alliance inviter id failed", logx.Field("err", err)) return } shareId := cast.ToUint(conf.Value) lg := earn.NewDataReportLogic(c.ctx, c.svcCtx) lg.PushUserInfo(shareId) lg.PushUserBind(shareId) }