Commit 60a74411 authored by hujiebin's avatar hujiebin

获取cp当天需要提醒的纪念日

parent a28d20cf
...@@ -4,7 +4,6 @@ import ( ...@@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/config" "git.hilo.cn/hilo-common/resource/config"
"git.hilo.cn/hilo-common/sdk/tencentyun"
"github.com/robfig/cron" "github.com/robfig/cron"
"hilo-user/domain/model/cp_m" "hilo-user/domain/model/cp_m"
"hilo-user/domain/model/user_m" "hilo-user/domain/model/user_m"
...@@ -41,12 +40,13 @@ func CpAnniversaryNotice() { ...@@ -41,12 +40,13 @@ func CpAnniversaryNotice() {
Content: v.Content, Content: v.Content,
Timestamp: v.Timestamp, Timestamp: v.Timestamp,
}) })
if err := tencentyun.BatchSendCustomMsg(model, 1, users[0].ExternalId, []string{users[1].ExternalId}, string(data), "cp纪念日"); err != nil { println(data) // todo 小助手
model.Log.Errorf("BatchSendCustomMsg fail:%v", err) //if err := tencentyun.BatchSendCustomMsg(model, 1, users[0].ExternalId, []string{users[1].ExternalId}, string(data), "cp纪念日"); err != nil {
} // model.Log.Errorf("BatchSendCustomMsg fail:%v", err)
if err := tencentyun.BatchSendCustomMsg(model, 1, users[1].ExternalId, []string{users[0].ExternalId}, string(data), "cp纪念日"); err != nil { //}
model.Log.Errorf("BatchSendCustomMsg fail:%v", err) //if err := tencentyun.BatchSendCustomMsg(model, 1, users[1].ExternalId, []string{users[0].ExternalId}, string(data), "cp纪念日"); err != nil {
} // model.Log.Errorf("BatchSendCustomMsg fail:%v", err)
//}
if err := cp_m.UpdateCpAnniversaryReminded(model, v.ID); err != nil { if err := cp_m.UpdateCpAnniversaryReminded(model, v.ID); err != nil {
model.Log.Errorf("UpdateCpAnniversaryReminded fail:%v", err) model.Log.Errorf("UpdateCpAnniversaryReminded fail:%v", err)
} }
......
...@@ -52,10 +52,11 @@ type CvPrivilege struct { ...@@ -52,10 +52,11 @@ type CvPrivilege struct {
// cp空间页 // cp空间页
type CvSpace struct { type CvSpace struct {
CpInfo CvCpInfo `json:"cpInfo"` // cp信息 CpInfo CvCpInfo `json:"cpInfo"` // cp信息
CpLevel CvCpLevel `json:"cpLevel"` // cp等级 CpLevel CvCpLevel `json:"cpLevel"` // cp等级
ResLevelList []CvResLevel `json:"resLevelList"` // 资源等级列表,无称号/恋爱CP/甜蜜CP/忠诚CP/炽热CP/荣耀CP ResLevelList []CvResLevel `json:"resLevelList"` // 资源等级列表,无称号/恋爱CP/甜蜜CP/忠诚CP/炽热CP/荣耀CP
PrivilegeList [][]CvPrivilege `json:"privilegeList"` // 等级特权 PrivilegeList [][]CvPrivilege `json:"privilegeList"` // 等级特权
CpAnniversary []CvCpAnniversary `json:"cpAnniversary"` // 提醒的纪念日
} }
var CvResLevelList = []CvResLevel{ var CvResLevelList = []CvResLevel{
......
...@@ -98,7 +98,8 @@ func GetAllCpAnniversary(model *domain.Model, userId mysql.ID) []CpAnniversary { ...@@ -98,7 +98,8 @@ func GetAllCpAnniversary(model *domain.Model, userId mysql.ID) []CpAnniversary {
func GetNeedRemindCpAnniversary(model *domain.Model) []CpAnniversary { func GetNeedRemindCpAnniversary(model *domain.Model) []CpAnniversary {
var res []CpAnniversary var res []CpAnniversary
if err := model.DB().Model(CpAnniversary{}). if err := model.DB().Model(CpAnniversary{}).
Where("`timestamp` > ?", time.Now().Unix()). Where("`timestamp` >= ?", time.Now().Unix()-86400).
Where("`timestamp` < ?", time.Now().Unix()).
Where("is_remind = 1"). Where("is_remind = 1").
Where("reminded = ?", mysql.NO). Where("reminded = ?", mysql.NO).
Find(&res).Error; err != nil { Find(&res).Error; err != nil {
...@@ -107,6 +108,20 @@ func GetNeedRemindCpAnniversary(model *domain.Model) []CpAnniversary { ...@@ -107,6 +108,20 @@ func GetNeedRemindCpAnniversary(model *domain.Model) []CpAnniversary {
return res return res
} }
// 获取cp当天需要提醒的纪念日
func GetUserTodayCpAnniversary(model *domain.Model, cpId mysql.ID) []CpAnniversary {
var res []CpAnniversary
if err := model.DB().Model(CpAnniversary{}).
Where("`timestamp` >= ?", time.Now().Unix()-86400).
Where("`timestamp` < ?", time.Now().Unix()).
Where("is_remind = 1").
Where("cp_id = ?", cpId).
Find(&res).Error; err != nil {
model.Log.Errorf("GetUserTodayCpAnniversary fail:%v", err)
}
return res
}
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("reminded", mysql.YES).Error
} }
...@@ -128,6 +128,17 @@ func CpSpace(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -128,6 +128,17 @@ func CpSpace(c *gin.Context) (*mycontext.MyContext, error) {
if cpUserInfo != nil { if cpUserInfo != nil {
response.CpInfo.CpUserInfo = user_cv.UserToTiny(*cpUserInfo) response.CpInfo.CpUserInfo = user_cv.UserToTiny(*cpUserInfo)
} }
// 需要提醒的纪念日
if exists && (userId == cpRelation.UserId1 || userId == cpRelation.UserId2) {
anniversary := cp_m.GetUserTodayCpAnniversary(model, cpRelation.ID)
for _, a := range anniversary {
response.CpAnniversary = append(response.CpAnniversary, cp_cv.CvCpAnniversary{
Id: a.ID,
Content: a.Content,
Timestamp: a.Timestamp,
})
}
}
resp.ResponseOk(c, response) resp.ResponseOk(c, response)
return myContext, nil return myContext, nil
} }
......
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