nft持有查询定时任务
This commit is contained in:
@@ -17,15 +17,18 @@ type Earn struct {
|
||||
|
||||
func NewEarn(ctx context.Context, svcCtx *svc.ServiceContext) *Earn {
|
||||
e := &Earn{ctx: ctx, svcCtx: svcCtx}
|
||||
e.Run()
|
||||
if e.svcCtx.Config.EarnCorn.RunOnStart {
|
||||
e.Run()
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *Earn) Spec() string {
|
||||
return "@every 5m"
|
||||
return e.svcCtx.Config.EarnCorn.Spec
|
||||
}
|
||||
|
||||
func (e *Earn) Run() {
|
||||
logx.Debugw("run earn cron task")
|
||||
c, err := e.svcCtx.ConfigModel.FindOneByName(e.ctx, consts.EarnAllianceInviterId)
|
||||
if err != nil {
|
||||
logx.Errorw("find earn alliance inviter id failed", logx.Field("err", err))
|
||||
@@ -41,6 +44,7 @@ func (e *Earn) pushUserInfo(shareId uint) {
|
||||
logx.Errorw("find require push user failed", logx.Field("err", err), logx.Field("share_id", shareId))
|
||||
return
|
||||
}
|
||||
logx.Debugw("find require push user", logx.Field("count", len(us)))
|
||||
for _, u := range us {
|
||||
ui, err := e.svcCtx.UserModel.FindOne(e.ctx, u.InvitedUid)
|
||||
if err != nil {
|
||||
@@ -53,15 +57,15 @@ func (e *Earn) pushUserInfo(shareId uint) {
|
||||
twitterId = ut.TwitterId
|
||||
}
|
||||
|
||||
e.svcCtx.Earn.SetIdentifiers(cast.ToString(ui.Id), &ea.Identifiers{
|
||||
Email: ea.IdentifierFrom(ui.Email),
|
||||
TwitterId: ea.IdentifierFrom(twitterId),
|
||||
})
|
||||
err = e.svcCtx.PromoteBindModel.UpdatePushUser(e.ctx, u.Id)
|
||||
if err != nil {
|
||||
logx.Errorw("update push user failed", logx.Field("err", err), logx.Field("uid", u.InvitedUid))
|
||||
logx.Errorw("update push user failed", logx.Field("err", err), logx.Field("uid", u.InvitedUid), logx.Field("twitter_id", twitterId), logx.Field("email", ui.Email))
|
||||
} else {
|
||||
logx.Infow("push user info success", logx.Field("uid", u.InvitedUid))
|
||||
e.svcCtx.Earn.SetIdentifiers(cast.ToString(ui.Id), &ea.Identifiers{
|
||||
Email: ea.IdentifierFrom(ui.Email),
|
||||
TwitterId: ea.IdentifierFrom(twitterId),
|
||||
})
|
||||
logx.Infow("push user info success", logx.Field("uid", u.InvitedUid), logx.Field("twitter_id", twitterId), logx.Field("email", ui.Email))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,12 +76,13 @@ func (e *Earn) pushUserBind(shareId uint) {
|
||||
logx.Errorw("find require push bind role user failed", logx.Field("err", err), logx.Field("share_id", shareId))
|
||||
return
|
||||
}
|
||||
logx.Debugw("find require push bind role user", logx.Field("count", len(us)))
|
||||
for _, u := range us {
|
||||
e.svcCtx.Earn.Track(cast.ToString(u.Uid), "BIND_ROLE", nil, nil)
|
||||
err = e.svcCtx.PromoteBindModel.UpdatePushRole(e.ctx, u.Id)
|
||||
if err != nil {
|
||||
logx.Errorw("update push user failed", logx.Field("err", err), logx.Field("uid", u.Uid))
|
||||
} else {
|
||||
e.svcCtx.Earn.Track(cast.ToString(u.Uid), "BIND_ROLE", nil, nil)
|
||||
logx.Infow("push user info success", logx.Field("uid", u.Uid))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user