From a6efc2236a2ffc990181e19572172c5f22f4a1a5 Mon Sep 17 00:00:00 2001 From: lianghuanjie Date: Fri, 10 Jan 2025 11:34:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E6=B5=8B=E8=B4=A8=E6=8A=BC=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=A5=96=E5=8A=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- etc/novatask.yaml | 12 +++++++--- internal/consts/consts.go | 3 +++ internal/logic/carv/bind_wallet_logic.go | 11 ++++++++- .../carv/download_and_bind_role_logic.go | 9 +++---- internal/logic/carv/unlock_chapter_logic.go | 24 +++++++++++++++++++ internal/logic/carv/wallet_check_in_logic.go | 23 ++++++++++++++++++ internal/logic/nft/stake_settle_logic.go | 24 +++++++++---------- internal/model/nh_system_config_model.go | 14 +++++++++++ 8 files changed, 100 insertions(+), 20 deletions(-) diff --git a/etc/novatask.yaml b/etc/novatask.yaml index 4efea51..f473e69 100644 --- a/etc/novatask.yaml +++ b/etc/novatask.yaml @@ -18,10 +18,16 @@ Log: Auth: # js-sdk鉴权相关配置 AccessSecret: "Mj2G%szYe&$MP@ytNv8JktQN1n5^cPq%" # 鉴权token密钥 +#MySql: # mysql相关配置 +# Addr: "192.168.20.101:3306" # mysql地址 +# User: "huangjie" # mysql用户 +# Password: "jMDqPQM^a6hsAR" # mysql密码 +# Database: "nova_home" # 数据库名 + MySql: # mysql相关配置 - Addr: "192.168.20.101:3306" # mysql地址 - User: "huangjie" # mysql用户 - Password: "jMDqPQM^a6hsAR" # mysql密码 + Addr: "127.0.0.1:3306" # mysql地址 + User: "root" # mysql用户 + Password: "123456" # mysql密码 Database: "nova_home" # 数据库名 Redis: diff --git a/internal/consts/consts.go b/internal/consts/consts.go index 4e83d02..1af6f7b 100644 --- a/internal/consts/consts.go +++ b/internal/consts/consts.go @@ -2,6 +2,9 @@ package consts const ( EarnAllianceInviterId = "earn_alliance_inviter_id" + CarvIoInviterId = "carv_io_inviter_id" + KgenIoInviterId = "kgen_io_inviter_id" + Game7IoInviterId = "game7_io_inviter_id" DailyPayConf = "daily_pay_conf" NftStakeTaskDate = "nft_stake_task_date" NftStakeTaskConf = "nft_stake_task_conf" diff --git a/internal/logic/carv/bind_wallet_logic.go b/internal/logic/carv/bind_wallet_logic.go index 8d3cc5c..b0d9298 100644 --- a/internal/logic/carv/bind_wallet_logic.go +++ b/internal/logic/carv/bind_wallet_logic.go @@ -33,7 +33,7 @@ func (l *BindWalletLogic) BindWallet(req *types.EmailKey) *types.CarvResult { return errResult } - _, err := l.svcCtx.WalletModel.FindAddressByUid(l.ctx, uid) + pb, err := l.svcCtx.PromoteBindModel.FindOneByInvitedUid(l.ctx, uid) if err != nil { if !errors.Is(err, model.ErrNotFound) { return &types.CarvResult{ @@ -47,6 +47,15 @@ func (l *BindWalletLogic) BindWallet(req *types.EmailKey) *types.CarvResult { Result: &types.Result{IsValid: false}, } } + + shareId := l.svcCtx.ConfigModel.GetCarvIoInviterId(l.ctx) + + if pb.ShareUid != shareId || pb.IsBindWallet == 0 { + return &types.CarvResult{ + Result: &types.Result{IsValid: false}, + } + } + return &types.CarvResult{ Result: &types.Result{IsValid: true}, } diff --git a/internal/logic/carv/download_and_bind_role_logic.go b/internal/logic/carv/download_and_bind_role_logic.go index 54de8f7..b70681d 100644 --- a/internal/logic/carv/download_and_bind_role_logic.go +++ b/internal/logic/carv/download_and_bind_role_logic.go @@ -45,10 +45,11 @@ func (l *DownloadAndBindRoleLogic) DownloadAndBindRole(req *types.EmailKey) *typ }} } - if pb.IsCreateRole == 0 { - return &types.CarvResult{Result: &types.Result{ - IsValid: false, - }} + shareId := l.svcCtx.ConfigModel.GetCarvIoInviterId(l.ctx) + if pb.ShareUid != shareId || pb.IsCreateRole == 0 { + return &types.CarvResult{ + Result: &types.Result{IsValid: false}, + } } return &types.CarvResult{ diff --git a/internal/logic/carv/unlock_chapter_logic.go b/internal/logic/carv/unlock_chapter_logic.go index bb5de79..e6a1db2 100644 --- a/internal/logic/carv/unlock_chapter_logic.go +++ b/internal/logic/carv/unlock_chapter_logic.go @@ -32,6 +32,30 @@ func (l *UnlockChapterLogic) UnlockChapter(req *types.UnlockChapterReq) *types.C if errResult != nil { return errResult } + + pb, err := l.svcCtx.PromoteBindModel.FindOneByInvitedUid(l.ctx, uid) + if err != nil { + if !errors.Is(err, model.ErrNotFound) { + return &types.CarvResult{ + Error: &types.Error{ + Code: int(errs.ErrDatabaseOperate), + Message: "system error", + }, + } + } + return &types.CarvResult{ + Result: &types.Result{IsValid: false}, + } + } + + shareId := l.svcCtx.ConfigModel.GetCarvIoInviterId(l.ctx) + + if pb.ShareUid != shareId { + return &types.CarvResult{ + Result: &types.Result{IsValid: false}, + } + } + gp, err := l.svcCtx.GameReportModel.FindOneByUid(l.ctx, uid) if err != nil { if !errors.Is(err, model.ErrNotFound) { diff --git a/internal/logic/carv/wallet_check_in_logic.go b/internal/logic/carv/wallet_check_in_logic.go index 9a8583c..b2a4552 100644 --- a/internal/logic/carv/wallet_check_in_logic.go +++ b/internal/logic/carv/wallet_check_in_logic.go @@ -35,6 +35,29 @@ func (l *WalletCheckInLogic) WalletCheckIn(req *types.EmailKey) *types.CarvResul return errResult } + pb, err := l.svcCtx.PromoteBindModel.FindOneByInvitedUid(l.ctx, uid) + if err != nil { + if !errors.Is(err, model.ErrNotFound) { + return &types.CarvResult{ + Error: &types.Error{ + Code: int(errs.ErrDatabaseOperate), + Message: "system error", + }, + } + } + return &types.CarvResult{ + Result: &types.Result{IsValid: false}, + } + } + + shareId := l.svcCtx.ConfigModel.GetCarvIoInviterId(l.ctx) + + if pb.ShareUid != shareId { + return &types.CarvResult{ + Result: &types.Result{IsValid: false}, + } + } + task, err := l.svcCtx.TaskModel.FindDailyPayTask(l.ctx) if err != nil { if !errors.Is(err, model.ErrNotFound) { diff --git a/internal/logic/nft/stake_settle_logic.go b/internal/logic/nft/stake_settle_logic.go index f8f564a..0f8d63f 100644 --- a/internal/logic/nft/stake_settle_logic.go +++ b/internal/logic/nft/stake_settle_logic.go @@ -79,18 +79,18 @@ func (l *StakeSettleLogic) StakeSettle() { } // 二测质押未提取的用户 - //oldStakeNfts, err := l.svcCtx.OldStakeNftModel.AllStakeNft(l.ctx) - //if err != nil { - // logx.Errorw("get all stake nft failed", logx.Field("err", err)) - //} else { - // for _, s := range oldStakeNfts { - // if utils.IsBigTarot(cast.ToString(s.TokenId)) { - // uid2tokens[s.UserId] += float64(taskConf.GreatTarot) - // } else { - // uid2tokens[s.UserId] += float64(taskConf.LittleTarot) - // } - // } - //} + oldStakeNfts, err := l.svcCtx.OldStakeNftModel.AllStakeNft(l.ctx) + if err != nil { + logx.Errorw("get all stake nft failed", logx.Field("err", err)) + } else { + for _, s := range oldStakeNfts { + if utils.IsBigTarot(cast.ToString(s.TokenId)) { + uid2tokens[s.UserId] += float64(taskConf.GreatTarot) + } else { + uid2tokens[s.UserId] += float64(taskConf.LittleTarot) + } + } + } awardSeq := cast.ToInt(time.Now().AddDate(0, 0, -1).Format("20060102")) for uid, tokens := range uid2tokens { diff --git a/internal/model/nh_system_config_model.go b/internal/model/nh_system_config_model.go index dff8aa2..369540e 100755 --- a/internal/model/nh_system_config_model.go +++ b/internal/model/nh_system_config_model.go @@ -4,6 +4,8 @@ import ( "context" "encoding/json" "errors" + "github.com/spf13/cast" + "github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/stores/cache" "github.com/zeromicro/go-zero/core/stores/sqlx" "nova_task/internal/consts" @@ -21,6 +23,7 @@ type ( GetNftStakeTaskConf(ctx context.Context) (conf NftStakeTaskConf, err error) GetCarvApiKey(ctx context.Context) (apiKey string, err error) GetAdminSecret(ctx context.Context) (secret string, err error) + GetCarvIoInviterId(ctx context.Context) uint } customNhSystemConfigModel struct { @@ -28,6 +31,17 @@ type ( } ) +func (m *customNhSystemConfigModel) GetCarvIoInviterId(ctx context.Context) uint { + cf, err := m.FindOneByName(ctx, consts.AdminSecret) + if err != nil { + if !errors.Is(err, sqlx.ErrNotFound) { + logx.Errorw("GetCarvIoInviterId error", logx.Field("err", err)) + } + return 0 + } + return cast.ToUint(cf.Value) +} + func (m *customNhSystemConfigModel) GetAdminSecret(ctx context.Context) (secret string, err error) { cf, err := m.FindOneByName(ctx, consts.AdminSecret) if err != nil {