增加软质押手动结算测试接口
This commit is contained in:
@@ -2,11 +2,11 @@ package earn
|
||||
|
||||
import (
|
||||
"context"
|
||||
ea "github.com/earn-alliance/earnalliance-go"
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -35,56 +35,8 @@ func (c *Cron) Run() {
|
||||
logx.Errorw("find earn alliance inviter id failed", logx.Field("err", err))
|
||||
return
|
||||
}
|
||||
c.pushUserInfo(cast.ToUint(conf.Value))
|
||||
c.pushUserBind(cast.ToUint(conf.Value))
|
||||
}
|
||||
|
||||
func (c *Cron) pushUserInfo(shareId uint) {
|
||||
us, err := c.svcCtx.PromoteBindModel.FindRequirePushUser(c.ctx, shareId)
|
||||
if err != nil {
|
||||
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 := c.svcCtx.UserModel.FindOne(c.ctx, u.InvitedUid)
|
||||
if err != nil {
|
||||
logx.Errorw("find user failed", logx.Field("err", err), logx.Field("uid", u.InvitedUid))
|
||||
continue
|
||||
}
|
||||
var twitterId string
|
||||
ut, err := c.svcCtx.TwitterModel.FindOne(c.ctx, u.InvitedUid)
|
||||
if err == nil {
|
||||
twitterId = ut.TwitterId
|
||||
}
|
||||
|
||||
err = c.svcCtx.PromoteBindModel.UpdatePushUser(c.ctx, u.Id)
|
||||
if err != nil {
|
||||
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 {
|
||||
c.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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cron) pushUserBind(shareId uint) {
|
||||
us, err := c.svcCtx.TouristBindModel.FindRequirePushUser(c.ctx, shareId)
|
||||
if err != nil {
|
||||
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 {
|
||||
err = c.svcCtx.PromoteBindModel.UpdatePushRole(c.ctx, u.Id)
|
||||
if err != nil {
|
||||
logx.Errorw("update push user failed", logx.Field("err", err), logx.Field("uid", u.Uid))
|
||||
} else {
|
||||
c.svcCtx.Earn.Track(cast.ToString(u.Uid), "BIND_ROLE", nil, nil)
|
||||
logx.Infow("push user info success", logx.Field("uid", u.Uid))
|
||||
}
|
||||
}
|
||||
shareId := cast.ToUint(conf.Value)
|
||||
lg := earn.NewDataReportLogic(c.ctx, c.svcCtx)
|
||||
lg.PushUserInfo(shareId)
|
||||
lg.PushUserBind(shareId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user