增加红点区分

dev_aagame_provider
zhora 1 month ago
parent b94d3e110b
commit 614e42e956
  1. 81
      call/redpoint.go
  2. 3
      pb/proto/platform.proto

@ -1,15 +1,10 @@
package call package call
import ( import (
"fmt" "github.com/liangdas/mqant/log"
"reflect"
"server/common" "server/common"
"server/db" "server/db"
"server/pb" "server/pb"
"strings"
"github.com/liangdas/mqant/log"
"gorm.io/gorm"
) )
const ( const (
@ -18,30 +13,34 @@ const (
// UpsertRedPointAndNotify 更新红点并通知客户端 // UpsertRedPointAndNotify 更新红点并通知客户端
func UpsertRedPointAndNotify(uid, num int, module string) { func UpsertRedPointAndNotify(uid, num int, module string) {
red := &common.PlayerRed{UID: uid} //red := &common.PlayerRed{UID: uid}
db.Mysql().Get(red) //db.Mysql().Get(red)
val := reflect.ValueOf(red).Elem().FieldByName(module) //val := reflect.ValueOf(red).Elem().FieldByName(module)
diff := int(val.Int()) + num //diff := int(val.Int()) + num
if red.ID == 0 { //if red.ID == 0 {
if diff < 0 { // if diff < 0 {
diff = 0 // diff = 0
} // }
val.SetInt(int64(diff)) // val.SetInt(int64(diff))
db.Mysql().Create(red) // db.Mysql().Create(red)
} else { //} else {
update := map[string]interface{}{} // update := map[string]interface{}{}
if num == 0 || diff <= 0 { // if num == 0 || diff <= 0 {
update[module] = 0 // update[module] = 0
val.SetInt(0) // val.SetInt(0)
} else { // } else {
update[module] = gorm.Expr(fmt.Sprintf("%v + ?", strings.ToLower(module)), num) // update[module] = gorm.Expr(fmt.Sprintf("%v + ?", strings.ToLower(module)), num)
val.SetInt(int64(diff)) // val.SetInt(int64(diff))
} // }
db.Mysql().Update(&common.PlayerRed{UID: uid}, update) // 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)})
send.List = append(send.List, &pb.RedInfo{ModuleName: pb.RedPointModule_RedPointMail, Num: uint32(diff)}) //SendNR(uid, int(pb.ServerCommonResp_CommonRedPointResp), send, "common")
SendNR(uid, int(pb.ServerCommonResp_CommonRedPointResp), send, "common")
} }
func PushMailRed(uid int) { func PushMailRed(uid int) {
@ -61,15 +60,23 @@ func PushMailRed(uid int) {
return return
} }
if unReadCount > 0 { var platform, personal bool
one := &pb.RedPoint{ one := &pb.RedPoint{
List: []*pb.RedInfo{ Mail: 1,
{ }
ModuleName: pb.RedPointModule_RedPointMail, for _, v := range list {
Num: uint32(unReadCount), 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") SendNR(uid, int(pb.ServerCommonResp_CommonRedPointResp), one, "common")
} }
//if redPoints.Mail > 0 { //if redPoints.Mail > 0 {

@ -63,7 +63,7 @@ message LoginResponse{
enum RedPointModule{ enum RedPointModule{
RedPointInvalid = 0; RedPointInvalid = 0;
RedPointMail = 1; // RedPointMail = 1; // -
RedPointVipReward = 2; // vip奖励 RedPointVipReward = 2; // vip奖励
RedPointWithdraw = 3; // RedPointWithdraw = 3; //
RedPointFreeCash = 4; // RedPointFreeCash = 4; //
@ -71,6 +71,7 @@ enum RedPointModule{
RedPointWeekCard = 6; // RedPointWeekCard = 6; //
RedPointCashBack = 7; // RedPointCashBack = 7; //
RedPointPdd = 8; // pdd次数 RedPointPdd = 8; // pdd次数
RedPointMailPersonal = 9; // -
} }
message RedInfo { message RedInfo {

Loading…
Cancel
Save