Files
novatask/internal/logic/game7/game7_task_check_logic.go
2025-01-15 16:23:49 +08:00

93 lines
2.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package game7
import (
"context"
"errors"
"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:
address, err := l.svcCtx.WalletModel.FindAddressByUid(l.ctx, uid)
if err != nil {
if !errors.Is(err, model.ErrNotFound) {
return nil, errs.New(errs.ErrDatabaseOperate, err)
}
isValid = false
} else {
isValid = address != ""
}
case 4:
var err error
isValid, err = l.svcCtx.RoleModel.AccountExist(l.ctx, req.Email)
if err != nil {
return nil, errs.New(errs.ErrDatabaseOperate, err)
}
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
}