From 4fb4b9283f4853cd723bb4c8b92c46014bf0b6df Mon Sep 17 00:00:00 2001 From: hujiebin Date: Fri, 16 Jun 2023 10:13:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BF=BB=E8=AF=91o=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cron/cp_cron/anniversary.go | 18 ++++++++++++++---- domain/model/cp_m/level.go | 10 +++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/cron/cp_cron/anniversary.go b/cron/cp_cron/anniversary.go index 9d31966..7b54887 100644 --- a/cron/cp_cron/anniversary.go +++ b/cron/cp_cron/anniversary.go @@ -7,6 +7,7 @@ import ( "github.com/robfig/cron" "hilo-user/domain/model/cp_m" "hilo-user/domain/model/msg_m" + "hilo-user/domain/model/user_m" ) // 纪念日 @@ -27,11 +28,20 @@ func CpAnniversaryNotice() { _ = c.AddFunc(spec, func() { var model = domain.CreateModelNil() anniversary := cp_m.GetNeedRemindCpAnniversary(model) + var userIds []uint64 for _, v := range anniversary { - var userIds []uint64 - userIds = append(userIds, v.UserId1, v.UserId2) - record1 := msg_m.NewUserRecord(model, v.UserId1, msg_e.CpAnniversaryNotice, v.Content, 0, "", "", "", "", "") - record2 := msg_m.NewUserRecord(model, v.UserId2, msg_e.CpAnniversaryNotice, v.Content, 0, "", "", "", "", "") + userIds = append(userIds, v.UserId1) + userIds = append(userIds, v.UserId2) + } + users, err := user_m.GetUserMapByIds(model, userIds) + if err != nil { + model.Log.Errorf("GetUserMapByIds fail:%v", err) + } + for _, v := range anniversary { + content1 := cp_m.GetTranslate(285, users[v.UserId1].Language) + content2 := cp_m.GetTranslate(285, users[v.UserId2].Language) + record1 := msg_m.NewUserRecord(model, v.UserId1, msg_e.CpAnniversaryNotice, content1, 0, "", "", "", "", "") + record2 := msg_m.NewUserRecord(model, v.UserId2, msg_e.CpAnniversaryNotice, content2, 0, "", "", "", "", "") err1, err2 := record1.Persistent(), record2.Persistent() if err1 != nil || err2 != nil { model.Log.Errorf("NewUserRecord fail:%v-%v", err1, err2) diff --git a/domain/model/cp_m/level.go b/domain/model/cp_m/level.go index ea6c5a6..55fe3c4 100644 --- a/domain/model/cp_m/level.go +++ b/domain/model/cp_m/level.go @@ -294,7 +294,15 @@ func AddCpLevelPoints(model *domain.Model, cpRelation CpRelation, points mysql.N model.Log.Errorf("") return } - if err := rpc.SendCpUpgrade(users[userId1].Nick, users[userId2].Nick, users[userId1].Avatar, users[userId2].Avatar, uint32(cpLevel.Level), "成为 todo"); err != nil { + levelMsgIdMap := map[cp_e.CpLevel]uint{ + cp_e.CpLevel1: 252, + cp_e.CpLevel2: 253, + cp_e.CpLevel3: 254, + cp_e.CpLevel4: 255, + cp_e.CpLevel5: 256, + } + content := fmt.Sprintf(GetTranslate(286, users[userId1].Language), GetTranslate(levelMsgIdMap[cpLevel.Level], users[userId1].Language)) + if err := rpc.SendCpUpgrade(users[userId1].Nick, users[userId2].Nick, users[userId1].Avatar, users[userId2].Avatar, uint32(cpLevel.Level), content); err != nil { model.Log.Errorf("SendCpUpgrade fail:%v", err) } }() -- 2.22.0