Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-user
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenweijian
hilo-user
Commits
60a74411
Commit
60a74411
authored
Jun 08, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取cp当天需要提醒的纪念日
parent
a28d20cf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
12 deletions
+39
-12
anniversary.go
cron/cp_cron/anniversary.go
+7
-7
space.go
cv/cp_cv/space.go
+5
-4
anniversary.go
domain/model/cp_m/anniversary.go
+16
-1
space.go
route/cp_r/space.go
+11
-0
No files found.
cron/cp_cron/anniversary.go
View file @
60a74411
...
...
@@ -4,7 +4,6 @@ import (
"encoding/json"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/config"
"git.hilo.cn/hilo-common/sdk/tencentyun"
"github.com/robfig/cron"
"hilo-user/domain/model/cp_m"
"hilo-user/domain/model/user_m"
...
...
@@ -41,12 +40,13 @@ func CpAnniversaryNotice() {
Content
:
v
.
Content
,
Timestamp
:
v
.
Timestamp
,
})
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
)
}
println
(
data
)
// todo 小助手
//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
:=
cp_m
.
UpdateCpAnniversaryReminded
(
model
,
v
.
ID
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"UpdateCpAnniversaryReminded fail:%v"
,
err
)
}
...
...
cv/cp_cv/space.go
View file @
60a74411
...
...
@@ -52,10 +52,11 @@ type CvPrivilege struct {
// cp空间页
type
CvSpace
struct
{
CpInfo
CvCpInfo
`json:"cpInfo"`
// cp信息
CpLevel
CvCpLevel
`json:"cpLevel"`
// cp等级
ResLevelList
[]
CvResLevel
`json:"resLevelList"`
// 资源等级列表,无称号/恋爱CP/甜蜜CP/忠诚CP/炽热CP/荣耀CP
PrivilegeList
[][]
CvPrivilege
`json:"privilegeList"`
// 等级特权
CpInfo
CvCpInfo
`json:"cpInfo"`
// cp信息
CpLevel
CvCpLevel
`json:"cpLevel"`
// cp等级
ResLevelList
[]
CvResLevel
`json:"resLevelList"`
// 资源等级列表,无称号/恋爱CP/甜蜜CP/忠诚CP/炽热CP/荣耀CP
PrivilegeList
[][]
CvPrivilege
`json:"privilegeList"`
// 等级特权
CpAnniversary
[]
CvCpAnniversary
`json:"cpAnniversary"`
// 提醒的纪念日
}
var
CvResLevelList
=
[]
CvResLevel
{
...
...
domain/model/cp_m/anniversary.go
View file @
60a74411
...
...
@@ -98,7 +98,8 @@ func GetAllCpAnniversary(model *domain.Model, userId mysql.ID) []CpAnniversary {
func
GetNeedRemindCpAnniversary
(
model
*
domain
.
Model
)
[]
CpAnniversary
{
var
res
[]
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
(
"reminded = ?"
,
mysql
.
NO
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
...
...
@@ -107,6 +108,20 @@ func GetNeedRemindCpAnniversary(model *domain.Model) []CpAnniversary {
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
{
return
model
.
DB
()
.
Model
(
CpAnniversary
{})
.
Where
(
"id = ?"
,
id
)
.
Update
(
"reminded"
,
mysql
.
YES
)
.
Error
}
route/cp_r/space.go
View file @
60a74411
...
...
@@ -128,6 +128,17 @@ func CpSpace(c *gin.Context) (*mycontext.MyContext, error) {
if
cpUserInfo
!=
nil
{
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
)
return
myContext
,
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment