Commit eb7ea01b authored by hujiebin's avatar hujiebin

feat:利用last_remind_time

parent 8c40c987
...@@ -21,7 +21,7 @@ type CpAnniversary struct { ...@@ -21,7 +21,7 @@ type CpAnniversary struct {
Content string Content string
Timestamp int64 Timestamp int64
IsRemind bool IsRemind bool
Reminded mysql.YesNo LastRemindTime int64
Sort int Sort int
} }
...@@ -77,7 +77,7 @@ func AddCpAnniversary(model *domain.Model, Type cp_e.AnniversaryItemType, cp CpR ...@@ -77,7 +77,7 @@ func AddCpAnniversary(model *domain.Model, Type cp_e.AnniversaryItemType, cp CpR
Content: content, Content: content,
Timestamp: ts, Timestamp: ts,
IsRemind: isRemind, IsRemind: isRemind,
Reminded: mysql.NO, LastRemindTime: 0,
Sort: sort, Sort: sort,
}).Error }).Error
} }
...@@ -116,7 +116,7 @@ func GetNeedRemindCpAnniversary(model *domain.Model) []CpAnniversary { ...@@ -116,7 +116,7 @@ func GetNeedRemindCpAnniversary(model *domain.Model) []CpAnniversary {
Where("`timestamp` >= ?", time.Now().Unix()-86400). Where("`timestamp` >= ?", time.Now().Unix()-86400).
Where("`timestamp` < ?", time.Now().Unix()). Where("`timestamp` < ?", time.Now().Unix()).
Where("is_remind = 1"). Where("is_remind = 1").
Where("reminded = ?", mysql.NO). Where("last_remind_time < ?", time.Now().AddDate(-1, 0, 0).Unix()). // 一年前提醒过
Find(&res).Error; err != nil { Find(&res).Error; err != nil {
model.Log.Errorf("GetNeedRemindCpAnniversary fail:%v", err) model.Log.Errorf("GetNeedRemindCpAnniversary fail:%v", err)
} }
...@@ -138,5 +138,5 @@ func GetUserTodayCpAnniversary(model *domain.Model, cpId mysql.ID) []CpAnniversa ...@@ -138,5 +138,5 @@ func GetUserTodayCpAnniversary(model *domain.Model, cpId mysql.ID) []CpAnniversa
} }
func UpdateCpAnniversaryReminded(model *domain.Model, id mysql.ID) error { 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
} }
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