增加软质押手动结算测试接口
This commit is contained in:
71
internal/logic/earn/data_report_logic.go
Normal file
71
internal/logic/earn/data_report_logic.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package earn
|
||||
|
||||
import (
|
||||
"context"
|
||||
ea "github.com/earn-alliance/earnalliance-go"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"nova_task/internal/svc"
|
||||
)
|
||||
|
||||
type DataReportLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDataReportLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DataReportLogic {
|
||||
return &DataReportLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DataReportLogic) PushUserInfo(shareId uint) {
|
||||
us, err := l.svcCtx.PromoteBindModel.FindRequirePushUser(l.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 := l.svcCtx.UserModel.FindOne(l.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 := l.svcCtx.TwitterModel.FindOne(l.ctx, u.InvitedUid)
|
||||
if err == nil {
|
||||
twitterId = ut.TwitterId
|
||||
}
|
||||
|
||||
err = l.svcCtx.PromoteBindModel.UpdatePushUser(l.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 {
|
||||
l.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 (l *DataReportLogic) PushUserBind(shareId uint) {
|
||||
us, err := l.svcCtx.TouristBindModel.FindRequirePushUser(l.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 = l.svcCtx.PromoteBindModel.UpdatePushRole(l.ctx, u.Id)
|
||||
if err != nil {
|
||||
logx.Errorw("update push user failed", logx.Field("err", err), logx.Field("uid", u.Uid))
|
||||
} else {
|
||||
l.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