From eb7ea01b505b1c0f23ae5dcf1d71b4a87ef7358a Mon Sep 17 00:00:00 2001 From: hujiebin Date: Wed, 14 Jun 2023 10:21:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=88=A9=E7=94=A8last=5Fremind=5Ftime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- domain/model/cp_m/anniversary.go | 40 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/domain/model/cp_m/anniversary.go b/domain/model/cp_m/anniversary.go index 958498d..13a7eec 100644 --- a/domain/model/cp_m/anniversary.go +++ b/domain/model/cp_m/anniversary.go @@ -14,15 +14,15 @@ import ( // CpAnniversary cp纪念日 type CpAnniversary struct { mysql.Entity - Type cp_e.AnniversaryItemType - CpId mysql.ID - UserId1 mysql.ID - UserId2 mysql.ID - Content string - Timestamp int64 - IsRemind bool - Reminded mysql.YesNo - Sort int + Type cp_e.AnniversaryItemType + CpId mysql.ID + UserId1 mysql.ID + UserId2 mysql.ID + Content string + Timestamp int64 + IsRemind bool + LastRemindTime int64 + Sort int } // 初始化6个cp纪念日 @@ -70,15 +70,15 @@ func GetTranslate(msgId uint, lang string) string { // 添加cp纪念日 func AddCpAnniversary(model *domain.Model, Type cp_e.AnniversaryItemType, cp CpRelationTmp, content string, ts int64, isRemind bool, sort int) error { return model.DB().Model(CpAnniversary{}).Create(&CpAnniversary{ - CpId: cp.ID, - Type: Type, - UserId1: cp.UserId1, - UserId2: cp.UserId2, - Content: content, - Timestamp: ts, - IsRemind: isRemind, - Reminded: mysql.NO, - Sort: sort, + CpId: cp.ID, + Type: Type, + UserId1: cp.UserId1, + UserId2: cp.UserId2, + Content: content, + Timestamp: ts, + IsRemind: isRemind, + LastRemindTime: 0, + Sort: sort, }).Error } @@ -116,7 +116,7 @@ func GetNeedRemindCpAnniversary(model *domain.Model) []CpAnniversary { Where("`timestamp` >= ?", time.Now().Unix()-86400). Where("`timestamp` < ?", time.Now().Unix()). Where("is_remind = 1"). - Where("reminded = ?", mysql.NO). + Where("last_remind_time < ?", time.Now().AddDate(-1, 0, 0).Unix()). // 一年前提醒过 Find(&res).Error; err != nil { model.Log.Errorf("GetNeedRemindCpAnniversary fail:%v", err) } @@ -138,5 +138,5 @@ func GetUserTodayCpAnniversary(model *domain.Model, cpId mysql.ID) []CpAnniversa } func UpdateCpAnniversaryReminded(model *domain.Model, id mysql.ID) error { - return model.DB().Model(CpAnniversary{}).Where("id = ?", id).Update("reminded", mysql.YES).Error + return model.DB().Model(CpAnniversary{}).Where("id = ?", id).Update("last_remind_time", time.Now().Unix()).Error } -- 2.22.0