85 lines
2.8 KiB
Go
85 lines
2.8 KiB
Go
package logic
|
|
|
|
//type PlayerMail struct {
|
|
// Id uint64 `bson:"id" key:"1"`
|
|
// Type uint32 `bson:"type"`
|
|
// Title string `bson:"title"`
|
|
// Content string `bson:"content"`
|
|
// Args []string `bson:"args"`
|
|
// Status uint32 `bson:"status"`
|
|
// ItemId []uint32 `bson:"item_id"`
|
|
// ItemNum []uint32 `bson:"item_num"`
|
|
// CreateTime int64 `bson:"create_time"`
|
|
// Expiration int64 `bson:"expiration"`
|
|
//}
|
|
//
|
|
//func (this *PlayerMail) BuildMsgMail() *proto.Mail {
|
|
// var itemList []*proto.ItemPair
|
|
// for i, itemId := range this.ItemId {
|
|
// itemList = append(itemList, &proto.ItemPair{ItemId: itemId, ItemNum: this.ItemNum[i]})
|
|
// }
|
|
// return &proto.Mail{
|
|
// Id: this.Id,
|
|
// Type: this.Type,
|
|
// Title: this.Title,
|
|
// Content: this.Content,
|
|
// Args: this.Args,
|
|
// Status: this.Status,
|
|
// ItemList: itemList,
|
|
// CreateTime: this.CreateTime,
|
|
// Expiration: this.Expiration,
|
|
// }
|
|
//}
|
|
//
|
|
//func (this *Player) AddMail(tipe proto.MailType, title, content string, args []string, itemId, itemNum []uint32, createTime int64, expiration ...int64) {
|
|
// counter, err := this.manager.mongoClient.Counter("mail_id", 1)
|
|
// if err != nil {
|
|
// this.manager.logger.Error("Get counter failed, ", err)
|
|
// return
|
|
// }
|
|
//
|
|
// this.addMail(util.EncryptUid(counter), tipe, title, content, args, itemId, itemNum, createTime, expiration...)
|
|
//}
|
|
//
|
|
//func (this *Player) addMail(mailId uint64, tipe proto.MailType, title, content string, args []string, itemId, itemNum []uint32, createTime int64, expiration ...int64) {
|
|
// var mail = &PlayerMail{
|
|
// Id: mailId,
|
|
// Type: uint32(tipe),
|
|
// Title: title,
|
|
// Content: content,
|
|
// Args: args,
|
|
// Status: uint32(proto.MailStatusUnread),
|
|
// ItemId: itemId,
|
|
// ItemNum: itemNum,
|
|
// CreateTime: createTime,
|
|
// }
|
|
//
|
|
// if len(expiration) > 0 {
|
|
// mail.Expiration = expiration[0]
|
|
// } else {
|
|
// mail.Expiration = mail.CreateTime + util.DayTotalSeconds*30
|
|
// }
|
|
//
|
|
// this.Mail[mail.Id] = mail
|
|
// this.SaveModel(mail)
|
|
//
|
|
// _ = this.Send(proto.ModIdMail, proto.MsgIdMailSend, &proto.MsgMailSendAck{Mail: mail.BuildMsgMail()})
|
|
//
|
|
// this.manager.eventManager.PlayerMailLog(this, LogTypeMailGet, mail.Id, mail.Type, 0, mail.Title, mail.Content, mail.ItemId, mail.ItemNum, 0, mail.CreateTime)
|
|
//}
|
|
//
|
|
//func (this *Player) BuildMsgMailListAck() *proto.MsgMailListAck {
|
|
// var mailList []*proto.Mail
|
|
// for _, mail := range this.Mail {
|
|
// if proto.MailStatus(mail.Status) >= proto.MailStatusDeleted {
|
|
// continue
|
|
// }
|
|
// var itemList []*proto.ItemPair
|
|
// for i := range mail.ItemId {
|
|
// itemList = append(itemList, &proto.ItemPair{ItemId: mail.ItemId[i], ItemNum: mail.ItemNum[i]})
|
|
// }
|
|
// mailList = append(mailList, mail.BuildMsgMail())
|
|
// }
|
|
// return &proto.MsgMailListAck{List: mailList}
|
|
//}
|