修改邮件推送逻辑

dev_aagame_provider
zhora 1 month ago
parent 90b03ff2bd
commit b94d3e110b
  1. 31
      call/mail.go
  2. 25
      call/redpoint.go
  3. 11
      db/mysql/mysql_mail.go
  4. 1
      modules/hall/player.go
  5. 15
      modules/web/handler/activity.go
  6. 25
      modules/web/handler/mail.go
  7. 10
      modules/web/handler/task.go
  8. 4
      modules/web/handler/vip.go
  9. 3
      modules/web/values/protocol.go
  10. 34
      pb/proto/platform.proto

@ -6,9 +6,6 @@ import (
"server/db" "server/db"
"server/util" "server/util"
"time" "time"
"github.com/liangdas/mqant/log"
"gorm.io/gorm"
) )
var ( var (
@ -21,7 +18,7 @@ var (
EmailShareRank = "Congratulations on achieving Rank %v in the million giveaway event. You have received a bonus of ₹%v. Thank you for participating!" EmailShareRank = "Congratulations on achieving Rank %v in the million giveaway event. You have received a bonus of ₹%v. Thank you for participating!"
) )
func checkMail(uid int, red *common.PlayerRed) { func checkMail(uid int, red *common.PlayerRed) (unReadCount int) {
data := &common.PlayerData{UID: uid} data := &common.PlayerData{UID: uid}
db.Mysql().Get(data) db.Mysql().Get(data)
user := &common.PlayerDBInfo{Id: uid} user := &common.PlayerDBInfo{Id: uid}
@ -54,11 +51,11 @@ func checkMail(uid int, red *common.PlayerRed) {
db.Mysql().QueryAll(sql, "", &common.Mail{}, &all) db.Mysql().QueryAll(sql, "", &common.Mail{}, &all)
if len(all) > 0 { if len(all) > 0 {
now := time.Now().Unix() now := time.Now().Unix()
u, err := db.Mysql().UpdateRes(&common.PlayerData{UID: uid, LastSysEmailDraw: data.LastSysEmailDraw}, &common.PlayerData{LastSysEmailDraw: now}) //u, err := db.Mysql().UpdateRes(&common.PlayerData{UID: uid, LastSysEmailDraw: data.LastSysEmailDraw}, &common.PlayerData{LastSysEmailDraw: now})
if err != nil || u == 0 { //if err != nil || u == 0 {
log.Error("err:%v", err) // log.Error("err:%v", err)
return // return
} //}
for _, v := range all { for _, v := range all {
one := v one := v
one.ID = 0 one.ID = 0
@ -67,14 +64,16 @@ func checkMail(uid int, red *common.PlayerRed) {
db.Mysql().Create(&one) db.Mysql().Create(&one)
mailCount++ mailCount++
} }
if red.ID == 0 { //if red.ID == 0 {
red.Mail = mailCount // red.Mail = mailCount
db.Mysql().Create(red) // db.Mysql().Create(red)
} else { //} else {
db.Mysql().Update(red, map[string]interface{}{"mail": gorm.Expr("mail + ?", mailCount)}) // db.Mysql().Update(red, map[string]interface{}{"mail": gorm.Expr("mail + ?", mailCount)})
//}
} }
} unReadCount = int(db.Mysql().Count(&common.Mail{}, fmt.Sprintf("receiver = %d and `status` = %d", uid, common.MailStatusNew)))
red.Mail += mailCount //red.Mail += mailCount
return
} }
const ( const (

@ -45,18 +45,33 @@ func UpsertRedPointAndNotify(uid, num int, module string) {
} }
func PushMailRed(uid int) { func PushMailRed(uid int) {
redPoints := &common.PlayerRed{UID: uid} //redPoints := &common.PlayerRed{UID: uid}
db.Mysql().Get(redPoints) //db.Mysql().Get(redPoints)
checkMail(uid, redPoints) var user common.PlayerDBInfo
err := db.Mysql().C().Model(&common.PlayerDBInfo{}).Where("id = ?", uid).Find(&user).Error
if err != nil {
log.Error("get user err, %s", err.Error())
return
}
rechargeInfo := GetRechargeInfo(uid)
list := []common.Mail{}
unReadCount, err := db.Mysql().QueryMailList(uid, 0, 0, user.Birth, int64(user.ChannelID), rechargeInfo.TotalRecharge, -1, true, &list)
if err != nil {
log.Error("get un read mail count err, %s", err.Error())
return
}
if unReadCount > 0 {
one := &pb.RedPoint{ one := &pb.RedPoint{
List: []*pb.RedInfo{ List: []*pb.RedInfo{
{ {
ModuleName: pb.RedPointModule_RedPointMail, ModuleName: pb.RedPointModule_RedPointMail,
Num: uint32(redPoints.Mail), Num: uint32(unReadCount),
}, },
}, },
} }
SendNR(uid, int(pb.ServerCommonCmd_CMD_BS_RedPointResp), one, "common") SendNR(uid, int(pb.ServerCommonResp_CommonRedPointResp), one, "common")
}
//if redPoints.Mail > 0 { //if redPoints.Mail > 0 {
// one := new(pb.RedPoint) // one := new(pb.RedPoint)
// one.List = append(one.List, &pb.RedInfo{ModuleName: pb.RedPointModule_RedPointMail, Num: uint32(redPoints.Mail)}) // one.List = append(one.List, &pb.RedInfo{ModuleName: pb.RedPointModule_RedPointMail, Num: uint32(redPoints.Mail)})

@ -8,7 +8,7 @@ import (
) )
// QueryMailList 查询玩家邮件列表 // QueryMailList 查询玩家邮件列表
func (c *MysqlClient) QueryMailList(uid, page, num int, birth, channelId, rechargeAmount int64, tag int, list *[]common.Mail) (count int64, err error) { func (c *MysqlClient) QueryMailList(uid, page, num int, birth, channelId, rechargeAmount int64, tag int, unRead bool, list *[]common.Mail) (count int64, err error) {
now := time.Now().Unix() now := time.Now().Unix()
start := now - common.MailExpireTime start := now - common.MailExpireTime
today := util.GetZeroTime(time.Now()) today := util.GetZeroTime(time.Now())
@ -30,8 +30,17 @@ func (c *MysqlClient) QueryMailList(uid, page, num int, birth, channelId, rechar
rechargeAmount, rechargeAmount,
channelId, channelId,
) )
if tag != -1 {
sql += fmt.Sprintf(" and `tag` = %d ", tag) sql += fmt.Sprintf(" and `tag` = %d ", tag)
}
if unRead {
sql += fmt.Sprintf(" and `status` = %d ", common.MailStatusNew)
}
if page > 0 || num > 0 {
count, err = c.QueryList(page, num, sql, "status,time desc", &common.Mail{}, &list) count, err = c.QueryList(page, num, sql, "status,time desc", &common.Mail{}, &list)
} else {
count, err = c.QueryList(0, 0, sql, "status,time desc", &common.Mail{}, &list)
}
if count > common.MailMaxCount { if count > common.MailMaxCount {
count = common.MailMaxCount count = common.MailMaxCount
} }

@ -20,6 +20,7 @@ type player struct {
} }
func (p *player) PushRedPoint() { func (p *player) PushRedPoint() {
call.PushRed(p.db.Id, pb.RedPointModule_RedPointFreeCash, uint32(1))
call.PushMailRed(p.db.Id) call.PushMailRed(p.db.Id)
} }

@ -9,7 +9,6 @@ import (
"server/db" "server/db"
"server/modules/web/app" "server/modules/web/app"
"server/modules/web/values" "server/modules/web/values"
"server/pb"
"server/util" "server/util"
"sort" "sort"
"strconv" "strconv"
@ -112,7 +111,7 @@ func GetPromotions(c *gin.Context) {
} }
} }
if num > 0 { if num > 0 {
call.PushRed(a.UID, pb.RedPointModule_RedPointTask, uint32(num)) //call.PushRed(a.UID, pb.RedPointModule_RedPointTask, uint32(num))
} }
} }
@ -673,7 +672,7 @@ func ActivityFirstRechargeBackInfo(c *gin.Context) {
} }
resp.Back = data.Reward resp.Back = data.Reward
if !resp.Draw { if !resp.Draw {
call.PushRed(a.UID, pb.RedPointModule_RedPointFirstRecharge, 1) //call.PushRed(a.UID, pb.RedPointModule_RedPointFirstRecharge, 1)
} }
} }
@ -722,7 +721,7 @@ func ActivityFirstRechargeBackDraw(c *gin.Context) {
} }
resp.Reward = val resp.Reward = val
call.UploadActivityData(a.UID, common.ActivityIDFirstRechargeBack, common.ActivityDataJoin, val) call.UploadActivityData(a.UID, common.ActivityIDFirstRechargeBack, common.ActivityDataJoin, val)
call.PushRed(a.UID, pb.RedPointModule_RedPointFirstRecharge, 0) //call.PushRed(a.UID, pb.RedPointModule_RedPointFirstRecharge, 0)
} }
// 幸运码活动 // 幸运码活动
@ -1195,7 +1194,7 @@ func ActivitySignNewInfo(c *gin.Context) {
num = 1 num = 1
} }
if num > 0 { if num > 0 {
call.PushRed(a.UID, pb.RedPointModule_RedPointSign, uint32(num)) //call.PushRed(a.UID, pb.RedPointModule_RedPointSign, uint32(num))
} }
a.Data = resp a.Data = resp
} }
@ -1279,7 +1278,7 @@ func ActivitySignNewDraw(c *gin.Context) {
} }
a.Data = values.ActivitySignDrawResp{Reward: reward, Day: day, Sign: newSign} a.Data = values.ActivitySignDrawResp{Reward: reward, Day: day, Sign: newSign}
call.UploadActivityData(a.UID, common.ActivityIDSign, common.ActivityDataJoin, reward) call.UploadActivityData(a.UID, common.ActivityIDSign, common.ActivityDataJoin, reward)
call.PushRed(a.UID, pb.RedPointModule_RedPointSign, uint32(0)) //call.PushRed(a.UID, pb.RedPointModule_RedPointSign, uint32(0))
} }
// 破产礼包活动 // 破产礼包活动
@ -1803,7 +1802,7 @@ func ActivityBetDrawInfo(c *gin.Context) {
if resp.Lucky >= item.Cost && vipInfo.Level >= item.VipUnlock && if resp.Lucky >= item.Cost && vipInfo.Level >= item.VipUnlock &&
drawInfo.SpinInfo.SpinNum < drawInfo.SpinInfo.SpinCount && drawInfo.SpinInfo.SpinNum < drawInfo.SpinInfo.SpinCount &&
now.Unix() >= drawInfo.SpinInfo.NextSpinTIme { now.Unix() >= drawInfo.SpinInfo.NextSpinTIme {
call.PushRed(a.UID, pb.RedPointModule_RedPointFreeSpin, uint32(1)) //call.PushRed(a.UID, pb.RedPointModule_RedPointFreeSpin, uint32(1))
break break
} }
} }
@ -1895,7 +1894,7 @@ func ActivityBetDrawDraw(c *gin.Context) {
drawInfo = common.ActivityBetDrawData{UID: a.UID} drawInfo = common.ActivityBetDrawData{UID: a.UID}
db.Mysql().Get(&drawInfo) db.Mysql().Get(&drawInfo)
call.PushRed(a.UID, pb.RedPointModule_RedPointFreeSpin, uint32(0)) //call.PushRed(a.UID, pb.RedPointModule_RedPointFreeSpin, uint32(0))
} }
func ActivityBetDrawHistory(c *gin.Context) { func ActivityBetDrawHistory(c *gin.Context) {

@ -33,7 +33,7 @@ func MailList(c *gin.Context) {
return return
} }
rechargeInfo := call.GetRechargeInfo(a.UID) rechargeInfo := call.GetRechargeInfo(a.UID)
count, err := db.Mysql().QueryMailList(a.UID, req.Page, req.Num, user.Birth, int64(user.ChannelID), rechargeInfo.TotalRecharge, req.Tag, &list) count, err := db.Mysql().QueryMailList(a.UID, req.Page, req.Num, user.Birth, int64(user.ChannelID), rechargeInfo.TotalRecharge, req.Tag, false, &list)
if err != nil { if err != nil {
a.Code = values.CodeRetry a.Code = values.CodeRetry
return return
@ -60,12 +60,11 @@ func ReadMail(c *gin.Context) {
if !a.S(req) { if !a.S(req) {
return return
} }
// id, err := strconv.Atoi(req.ID) if req.ID == 0 && req.All {
// if err != nil { a.Code = values.CodeRetry
// log.Error("err:%v", err) return
// a.Code = values.CodeRetry }
// return if req.ID > 0 {
// }
id := req.ID id := req.ID
one := &common.Mail{ID: id} one := &common.Mail{ID: id}
err := db.Mysql().Get(one) err := db.Mysql().Get(one)
@ -79,9 +78,17 @@ func ReadMail(c *gin.Context) {
a.Code = values.CodeRetry a.Code = values.CodeRetry
return return
} }
// call.UpsertRedPointAndNotify(a.UID, -1, call.ModuleMail)
a.Data = values.ReadMailResp{Mail: *one} a.Data = values.ReadMailResp{Mail: *one}
} else if req.All {
count, err := db.Mysql().UpdateRes(&common.Mail{Receiver: a.UID, Status: common.MailStatusNew}, map[string]interface{}{"status": common.MailStatusRead})
if count == 0 || err != nil {
log.Error("err:%v", err)
a.Code = values.CodeRetry
return
}
}
//call.UpsertRedPointAndNotify(a.UID, -1, call.ModuleMail)
return
} }
func DrawMail(c *gin.Context) { func DrawMail(c *gin.Context) {

@ -1,15 +1,13 @@
package handler package handler
import ( import (
"github.com/gin-gonic/gin"
"github.com/liangdas/mqant/log"
"server/call" "server/call"
"server/common" "server/common"
"server/db" "server/db"
"server/modules/web/app" "server/modules/web/app"
"server/modules/web/values" "server/modules/web/values"
"server/pb"
"github.com/gin-gonic/gin"
"github.com/liangdas/mqant/log"
) )
// Record 领奖进度,key为taskid,value为任务进度,小与0时表示已领取 // Record 领奖进度,key为taskid,value为任务进度,小与0时表示已领取
@ -32,7 +30,7 @@ func GetTaskInfo(c *gin.Context) {
} }
} }
if num > 0 { if num > 0 {
call.PushRed(a.UID, pb.RedPointModule_RedPointTask, uint32(num)) //call.PushRed(a.UID, pb.RedPointModule_RedPointTask, uint32(num))
} }
} }
@ -104,5 +102,5 @@ func DrawTask(c *gin.Context) {
num++ num++
} }
} }
call.PushRed(a.UID, pb.RedPointModule_RedPointTask, uint32(num)) //call.PushRed(a.UID, pb.RedPointModule_RedPointTask, uint32(num))
} }

@ -168,7 +168,7 @@ func GetVipInfo(c *gin.Context) {
db.ES().QueryList(common.ESIndexBalance, req.Page, req.Num, q, &resp.CashbackList, "time", false) db.ES().QueryList(common.ESIndexBalance, req.Page, req.Num, q, &resp.CashbackList, "time", false)
reset = !util.IsSameDayTimeStamp(now.Unix(), resp.Info.ProfitTime) reset = !util.IsSameDayTimeStamp(now.Unix(), resp.Info.ProfitTime)
if reset && resp.Info.Cashback > 0 { if reset && resp.Info.Cashback > 0 {
call.PushRed(a.UID, pb.RedPointModule_RedPointVipCashback, uint32(1)) call.PushRed(a.UID, pb.RedPointModule_RedPointVipReward, uint32(1))
} }
if hasVipBonus(resp.Info) { if hasVipBonus(resp.Info) {
call.PushRed(a.UID, pb.RedPointModule_RedPointVipReward, uint32(1)) call.PushRed(a.UID, pb.RedPointModule_RedPointVipReward, uint32(1))
@ -490,5 +490,5 @@ func DrawVipCashback(c *gin.Context) {
resp.NextCashback = util.GetNext5MinUnix() - now.Unix() resp.NextCashback = util.GetNext5MinUnix() - now.Unix()
} }
a.Data = resp a.Data = resp
call.PushRed(a.UID, pb.RedPointModule_RedPointVipCashback, uint32(0)) call.PushRed(a.UID, pb.RedPointModule_RedPointVipReward, uint32(0))
} }

@ -125,7 +125,8 @@ type MailListResp struct {
// ReadMailReq 读取一封邮件 // ReadMailReq 读取一封邮件
// ID 邮件id // ID 邮件id
type ReadMailReq struct { type ReadMailReq struct {
ID int `json:"id" binding:"required"` ID int `json:"id"`
All bool `json:"all"`
} }
// ReadMailResp 读取一封邮件 // ReadMailResp 读取一封邮件

@ -46,19 +46,31 @@ message LoginResponse{
uint32 user_id = 2; // UIDuid一致便UID返回了 uint32 user_id = 2; // UIDuid一致便UID返回了
} }
//enum RedPointModule{
// RedPointInvalid = 0;
// RedPointTask = 1;
// RedPointSign = 2;
// RedPointShare = 3; // *
// RedPointVipCashback = 4; //*
// RedPointMail = 5;// *
// RedPointFreeSpin = 6; //
// RedPointVipReward = 7; // vip升级奖励
// RedPointLoginAgain = 8; //
// RedPointWeekCard = 9; // *
// RedPointFirstRecharge = 10 ; //
// RedPointPdd = 11 ; //
//}
enum RedPointModule{ enum RedPointModule{
RedPointInvalid = 0; RedPointInvalid = 0;
RedPointTask = 1; RedPointMail = 1; //
RedPointSign = 2; RedPointVipReward = 2; // vip奖励
RedPointShare = 3; // * RedPointWithdraw = 3; //
RedPointVipCashback = 4; //* RedPointFreeCash = 4; //
RedPointMail = 5;// * RedPointShare = 5; //
RedPointFreeSpin = 6; // RedPointWeekCard = 6; //
RedPointVipReward = 7; // vip升级奖励 RedPointCashBack = 7; //
RedPointLoginAgain = 8; // RedPointPdd = 8; // pdd次数
RedPointWeekCard = 9; // *
RedPointFirstRecharge = 10 ; //
RedPointPdd = 11 ; //
} }
message RedInfo { message RedInfo {

Loading…
Cancel
Save