game7 api
This commit is contained in:
81
internal/logic/game7/game7_task_check_logic.go
Normal file
81
internal/logic/game7/game7_task_check_logic.go
Normal file
@@ -0,0 +1,81 @@
|
||||
package game7
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"nova_task/internal/consts"
|
||||
"nova_task/internal/model"
|
||||
"nova_task/internal/pkg/errs"
|
||||
|
||||
"nova_task/internal/svc"
|
||||
"nova_task/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type Game7TaskCheckLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGame7TaskCheckLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Game7TaskCheckLogic {
|
||||
return &Game7TaskCheckLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Game7TaskCheckLogic) Game7TaskCheck(req *types.Game7TaskCheckReq) (*types.Game7ResultData, error) {
|
||||
uid, resultErr := l.svcCtx.GetUidByEmail(l.ctx, req.Email)
|
||||
if resultErr != nil {
|
||||
return nil, errs.New(errs.Reason(resultErr.Error.Code), resultErr.Error.Message)
|
||||
}
|
||||
|
||||
pb, err := l.svcCtx.PromoteBindModel.FindOneByInvitedUid(l.ctx, uid)
|
||||
if err != nil {
|
||||
if !errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errs.New(errs.ErrDatabaseOperate, err)
|
||||
}
|
||||
return &types.Game7ResultData{
|
||||
IsValid: false,
|
||||
}, nil
|
||||
}
|
||||
|
||||
shareId := l.svcCtx.ConfigModel.GetInviterId(l.ctx, consts.Game7IoInviterId)
|
||||
|
||||
if pb.ShareUid != shareId {
|
||||
return nil, errs.New(errs.ErrUserNotFound, "user not found")
|
||||
}
|
||||
|
||||
var isValid bool
|
||||
// 1.是否在官网注册并链接钱包(是/否) 2.是否有超过两个以上的英雄(是/否) 3.是否消耗召唤券召唤了新英雄(是/否) 4. 是否在游戏内绑定了官网账号(是/否) 5. 是否有一个31级以上的英雄(是/否) 6. 是否完成了主线第一章(是/否)
|
||||
switch req.Type {
|
||||
case 1:
|
||||
isValid = pb.IsBindWallet == 1
|
||||
case 4:
|
||||
isValid = pb.IsCreateRole == 1
|
||||
case 2, 3, 5, 6:
|
||||
gp, err := l.svcCtx.GameReportModel.FindOneByUid(l.ctx, uid)
|
||||
if err != nil {
|
||||
if !errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errs.New(errs.ErrDatabaseOperate, err)
|
||||
}
|
||||
isValid = false
|
||||
} else {
|
||||
switch req.Type {
|
||||
case 2:
|
||||
isValid = gp.IsHaveTwoHero == 1
|
||||
case 3:
|
||||
isValid = gp.IsUsedSummon == 1
|
||||
case 5:
|
||||
isValid = gp.IsHaveHero31 == 1
|
||||
case 6:
|
||||
isValid = gp.Chapter >= 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &types.Game7ResultData{IsValid: isValid}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user