From 614e42e956c6e0ada11ece962285c6ef5b44ddb0 Mon Sep 17 00:00:00 2001 From: zhora Date: Thu, 25 Sep 2025 18:16:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BA=A2=E7=82=B9=E5=8C=BA?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- call/redpoint.go | 81 ++++++++++++++++++++++------------------- pb/proto/platform.proto | 3 +- 2 files changed, 46 insertions(+), 38 deletions(-) diff --git a/call/redpoint.go b/call/redpoint.go index f482a93..6daa058 100644 --- a/call/redpoint.go +++ b/call/redpoint.go @@ -1,15 +1,10 @@ package call import ( - "fmt" - "reflect" + "github.com/liangdas/mqant/log" "server/common" "server/db" "server/pb" - "strings" - - "github.com/liangdas/mqant/log" - "gorm.io/gorm" ) const ( @@ -18,30 +13,34 @@ const ( // UpsertRedPointAndNotify 更新红点并通知客户端 func UpsertRedPointAndNotify(uid, num int, module string) { - red := &common.PlayerRed{UID: uid} - db.Mysql().Get(red) - val := reflect.ValueOf(red).Elem().FieldByName(module) - diff := int(val.Int()) + num - if red.ID == 0 { - if diff < 0 { - diff = 0 - } - val.SetInt(int64(diff)) - db.Mysql().Create(red) - } else { - update := map[string]interface{}{} - if num == 0 || diff <= 0 { - update[module] = 0 - val.SetInt(0) - } else { - update[module] = gorm.Expr(fmt.Sprintf("%v + ?", strings.ToLower(module)), num) - val.SetInt(int64(diff)) - } - db.Mysql().Update(&common.PlayerRed{UID: uid}, update) + //red := &common.PlayerRed{UID: uid} + //db.Mysql().Get(red) + //val := reflect.ValueOf(red).Elem().FieldByName(module) + //diff := int(val.Int()) + num + //if red.ID == 0 { + // if diff < 0 { + // diff = 0 + // } + // val.SetInt(int64(diff)) + // db.Mysql().Create(red) + //} else { + // update := map[string]interface{}{} + // if num == 0 || diff <= 0 { + // update[module] = 0 + // val.SetInt(0) + // } else { + // update[module] = gorm.Expr(fmt.Sprintf("%v + ?", strings.ToLower(module)), num) + // val.SetInt(int64(diff)) + // } + // db.Mysql().Update(&common.PlayerRed{UID: uid}, update) + //} + //send := &pb.RedPoint{} + switch module { + case ModuleMail: + PushMailRed(uid) } - send := &pb.RedPoint{} - send.List = append(send.List, &pb.RedInfo{ModuleName: pb.RedPointModule_RedPointMail, Num: uint32(diff)}) - SendNR(uid, int(pb.ServerCommonResp_CommonRedPointResp), send, "common") + //send.List = append(send.List, &pb.RedInfo{ModuleName: pb.RedPointModule_RedPointMail, Num: uint32(diff)}) + //SendNR(uid, int(pb.ServerCommonResp_CommonRedPointResp), send, "common") } func PushMailRed(uid int) { @@ -61,15 +60,23 @@ func PushMailRed(uid int) { return } - if unReadCount > 0 { - one := &pb.RedPoint{ - List: []*pb.RedInfo{ - { - ModuleName: pb.RedPointModule_RedPointMail, - Num: uint32(unReadCount), - }, - }, + var platform, personal bool + one := &pb.RedPoint{ + Mail: 1, + } + for _, v := range list { + if v.Tag == 0 && !platform { + platform = true + one.List = append(one.List, &pb.RedInfo{ModuleName: pb.RedPointModule_RedPointMail, Num: uint32(unReadCount)}) + } else if v.Tag == 1 && !personal { + personal = true + one.List = append(one.List, &pb.RedInfo{ModuleName: pb.RedPointModule_RedPointMailPersonal, Num: uint32(unReadCount)}) + } + if platform && personal { + break } + } + if unReadCount > 0 { SendNR(uid, int(pb.ServerCommonResp_CommonRedPointResp), one, "common") } //if redPoints.Mail > 0 { diff --git a/pb/proto/platform.proto b/pb/proto/platform.proto index 1db73b9..822f313 100644 --- a/pb/proto/platform.proto +++ b/pb/proto/platform.proto @@ -63,7 +63,7 @@ message LoginResponse{ enum RedPointModule{ RedPointInvalid = 0; - RedPointMail = 1; // 邮件 + RedPointMail = 1; // 邮件-平台 RedPointVipReward = 2; // vip奖励 RedPointWithdraw = 3; // 提现 RedPointFreeCash = 4; // 免费现金 @@ -71,6 +71,7 @@ enum RedPointModule{ RedPointWeekCard = 6; // 周卡 RedPointCashBack = 7; // 返现 RedPointPdd = 8; // pdd次数 + RedPointMailPersonal = 9; // 邮件-个人 } message RedInfo {