This commit is contained in:
aozhiwei 2024-02-12 19:59:39 +08:00
parent 860711a093
commit 819a77fe4c
5 changed files with 35 additions and 91 deletions

View File

@ -8,14 +8,37 @@ type App interface {
} }
type Player interface { type Player interface {
Lock()
UnLock()
GetAccountId() string GetAccountId() string
GetRegisterTime() int32 GetRegisterTime() int32
IsUnreadMail(int64) bool FillMailList(mailList *[]MailDto)
IsDeletedMail(int64) bool ReadMails(mailIds []int64)
GetUnreadMailCnt() int32
GetMailById(mailId int64) *MailDto
GetAttachments(mailIds []int64)
DeleteMails(mailIds []int64)
IsDeletedMail(mailId int64)
IsReadedMail(mailId int64)
} }
type PlayerMgr interface{} type PlayerMgr interface{}
type Mail interface{}
type AttachmentDto struct {
ItemId int32 `json:"itemid"`
ItemNum int32 `json:"itemnum"`
}
type MailDto struct {
MailId string `json:"mailid"`
Subject string `json:"subject"`
Content string `json:"content"`
Flags int32 `json:"flags"`
SendTime int32 `json:"sendtime"`
ExpireTime int32 `json:"expiretime""`
Attachments []AttachmentDto `json:"attachments""`
}
type MailMgr interface{} type MailMgr interface{}
type ControllerMgr interface{} type ControllerMgr interface{}

View File

@ -11,6 +11,7 @@ func mail_getMailList(c *gin.Context) {
var msg struct { var msg struct {
ErrCode int32 `json:"errcode"` ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"` ErrMsg string `json:"errmsg"`
MailList []common.MailDto `json:"maillist""`
} }
msg.ErrCode = 0 msg.ErrCode = 0
msg.ErrMsg = hum.GetAccountId() msg.ErrMsg = hum.GetAccountId()

View File

@ -1,11 +1,10 @@
package mail package mail
import ( import (
"main/common" //"main/common"
"main/constant" //"main/constant"
"q5" //"q5"
"strings" //"strings"
"time"
) )
type Attachment struct { type Attachment struct {
@ -57,6 +56,7 @@ func NewMail() *Mail {
return m return m
} }
/*
func (m *Mail) ParseAttachments(attachmentsStr string) { func (m *Mail) ParseAttachments(attachmentsStr string) {
if len(attachmentsStr) <= 0 { if len(attachmentsStr) <= 0 {
m.ATT = make([]*Attachment, 0) m.ATT = make([]*Attachment, 0)
@ -80,32 +80,4 @@ func (m *Mail) ParseAttachments(attachmentsStr string) {
m.ATT = append(m.ATT, attachment) m.ATT = append(m.ATT, attachment)
} }
} }
*/
func (m *Mail) FillMutableXObject() {}
func (m *Mail) GMFillMutableXObject() {}
func (m *Mail) HasAttachment() bool {
return len(m.ATT) > 0
}
func (m *Mail) IsReadableMail(accountObj common.Player) bool {
if m.MailType == constant.MAIL_TYPE_GROUP {
if m.UserType == 1 {
// 只有在邮件发送时间之前注册的用户可以读
if accountObj.GetRegisterTime() > m.SendTime {
return false
}
} else if m.UserType == 2 {
// 只有在邮件发送时间之后注册的用户可以读
if accountObj.GetRegisterTime() < m.SendTime {
return false
}
}
}
nowUnixSec := int32(time.Now().Unix())
if m.ExpireTime > nowUnixSec && m.SendTime <= nowUnixSec && !accountObj.IsDeletedMail(m.MailId) {
return true
}
return false
}

View File

@ -184,6 +184,7 @@ func (this *MailMgr) GetGMMailList(gameId int) []*GMMail {
return resMailList return resMailList
} }
/*
func (this *MailMgr) GetMailList(player common.Player) []*Mail { func (this *MailMgr) GetMailList(player common.Player) []*Mail {
gameMailList := this.gameMailHash[constant.GAMEID] gameMailList := this.gameMailHash[constant.GAMEID]
playerMailList := this.playerMailHash[player.GetAccountId()] playerMailList := this.playerMailHash[player.GetAccountId()]
@ -230,32 +231,4 @@ func (this *MailMgr) GetMailList(player common.Player) []*Mail {
} }
return resMailList return resMailList
} }
*/
func (this *MailMgr) markMail(accountObj common.Player) {
}
func (this *MailMgr) GetUnreadMailCount(accountObj common.Player) int {
mailCnt := 0
if gameMails, ok := this.gameMailHash[constant.GAMEID]; ok {
for _, mailObj := range gameMails {
if mailObj.IsReadableMail(accountObj) {
mailCnt++
}
}
}
if playerMails, ok := this.playerMailHash[accountObj.GetAccountId()]; ok {
for _, mailObj := range playerMails {
if mailObj.IsReadableMail(accountObj) {
mailCnt++
}
}
}
return mailCnt
}
func (this *MailMgr) getAttachment(accountObj common.Player) {
}
func (this *MailMgr) deleteMails(accountObj common.Player) {
}

View File

@ -109,31 +109,6 @@ func (p *Player) DeleteMails(mailIds string) {
p.MarkDirty() p.MarkDirty()
} }
func (p *Player) AddToReadList() {}
func (p *Player) GetAttachment(mailIds string) []interface{} {
attachments := make([]interface{}, 0)
mailMgrPtr := global.GetMailMgr().(*mail.MailMgr)
mailIdStrings := strings.Split(mailIds, ",")
for _, _mailId := range mailIdStrings {
if len(_mailId) <= 0 {
continue
}
mailId := q5.ToInt64(_mailId)
mailObj := mailMgrPtr.GetMail(mailId)
if mailObj == nil || !mailObj.HasAttachment() || p.IsDeletedMail(mailId) {
continue
}
for _, mailATT := range mailObj.ATT {
attachments = append(attachments, mailATT)
}
p.DeleteMails(_mailId)
}
return attachments
}
/* /*
func (p *Player) Deserialize(accountPB *ss.MFAccountData) { func (p *Player) Deserialize(accountPB *ss.MFAccountData) {
var nextDaySec int32 = 3600 * 24 var nextDaySec int32 = 3600 * 24