Commit 0877a9e4 authored by hujiebin's avatar hujiebin

fix:纪念日bugfux

parent 8bbb009e
...@@ -5,5 +5,7 @@ type AnniversaryItemType int ...@@ -5,5 +5,7 @@ type AnniversaryItemType int
const ( const (
AnniversaryItemTypeNormal AnniversaryItemType = 0 // 普通类型 AnniversaryItemTypeNormal AnniversaryItemType = 0 // 普通类型
AnniversaryItemTypeAvatar AnniversaryItemType = 1 // 头像类型 AnniversaryItemTypeAvatar AnniversaryItemType = 1 // 头像类型
AnniversaryItemTypeAnniversary AnniversaryItemType = 2 // 纪念日类型(一年一度,如生日/结婚纪念日) AnniversaryItemTypeBirthday1 AnniversaryItemType = 2 // user1的生日
AnniversaryItemTypeBirthday2 AnniversaryItemType = 3 // user2的生日
AnniversaryItemTypeAnniversary AnniversaryItemType = 4 // 纪念日
) )
...@@ -36,10 +36,10 @@ func InitCpAnniversary(model *domain.Model, cp CpRelation, lang string) error { ...@@ -36,10 +36,10 @@ func InitCpAnniversary(model *domain.Model, cp CpRelation, lang string) error {
if err := AddCpAnniversary(model, cp_e.AnniversaryItemTypeNormal, cp, GetTranslate(259, lang), time.Now().Unix(), true, 100, 259); err != nil { if err := AddCpAnniversary(model, cp_e.AnniversaryItemTypeNormal, cp, GetTranslate(259, lang), time.Now().Unix(), true, 100, 259); err != nil {
return err return err
} }
if err := AddCpAnniversary(model, cp_e.AnniversaryItemTypeAnniversary, cp, fmt.Sprintf(GetTranslate(260, lang), users[cp.UserId1].Nick), 0, true, 0, 260); err != nil { if err := AddCpAnniversary(model, cp_e.AnniversaryItemTypeBirthday1, cp, fmt.Sprintf(GetTranslate(260, lang), users[cp.UserId1].Nick), 0, true, 0, 260); err != nil {
return err return err
} }
if err := AddCpAnniversary(model, cp_e.AnniversaryItemTypeAnniversary, cp, fmt.Sprintf(GetTranslate(260, lang), users[cp.UserId2].Nick), 0, true, 0, 260); err != nil { if err := AddCpAnniversary(model, cp_e.AnniversaryItemTypeBirthday2, cp, fmt.Sprintf(GetTranslate(260, lang), users[cp.UserId2].Nick), 0, true, 0, 260); err != nil {
return err return err
} }
if err := AddCpAnniversary(model, cp_e.AnniversaryItemTypeNormal, cp, GetTranslate(261, lang), 0, true, 0, 261); err != nil { if err := AddCpAnniversary(model, cp_e.AnniversaryItemTypeNormal, cp, GetTranslate(261, lang), 0, true, 0, 261); err != nil {
...@@ -110,17 +110,14 @@ func GetAllCpAnniversary(model *domain.Model, userId mysql.ID, lang string) []Cp ...@@ -110,17 +110,14 @@ func GetAllCpAnniversary(model *domain.Model, userId mysql.ID, lang string) []Cp
} }
var userIds = []mysql.ID{relation.UserId1, relation.UserId2} var userIds = []mysql.ID{relation.UserId1, relation.UserId2}
users, _ := user_m.GetUserMapByIds(model, userIds) users, _ := user_m.GetUserMapByIds(model, userIds)
n := 0
for i, v := range res { for i, v := range res {
if v.CreatedTime.Equal(v.UpdatedTime) && v.MsgId > 0 { if v.CreatedTime.Equal(v.UpdatedTime) && v.MsgId > 0 {
res[i].Content = GetTranslate(v.MsgId, lang) if v.Type == cp_e.AnniversaryItemTypeBirthday1 {
if v.MsgId == 260 {
n++
if n == 1 {
res[i].Content = fmt.Sprintf(GetTranslate(v.MsgId, lang), users[relation.UserId1].Nick) res[i].Content = fmt.Sprintf(GetTranslate(v.MsgId, lang), users[relation.UserId1].Nick)
} else { } else if v.Type == cp_e.AnniversaryItemTypeBirthday2 {
res[i].Content = fmt.Sprintf(GetTranslate(v.MsgId, lang), users[relation.UserId2].Nick) res[i].Content = fmt.Sprintf(GetTranslate(v.MsgId, lang), users[relation.UserId2].Nick)
} } else {
res[i].Content = GetTranslate(v.MsgId, lang)
} }
} }
} }
......
...@@ -133,7 +133,7 @@ func PageAnniversary(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -133,7 +133,7 @@ func PageAnniversary(c *gin.Context) (*mycontext.MyContext, error) {
anniversary := cp_m.GetAllCpAnniversary(model, userId, lang) anniversary := cp_m.GetAllCpAnniversary(model, userId, lang)
for _, v := range anniversary { for _, v := range anniversary {
timestamp := v.Timestamp timestamp := v.Timestamp
if v.Type == cp_e.AnniversaryItemTypeAnniversary && timestamp > 0 { if v.Type >= cp_e.AnniversaryItemTypeBirthday1 && timestamp > 0 {
timestamp = cp_m.CalcNextAnniversary(timestamp, loc) timestamp = cp_m.CalcNextAnniversary(timestamp, loc)
} }
// 客户端只认识0 1 // 客户端只认识0 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment