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
2d562c8f
Commit
2d562c8f
authored
Jun 13, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cp翻译
parent
20afbb54
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
221 additions
and
27 deletions
+221
-27
cp_relation.go
_const/enum/cp_e/cp_relation.go
+1
-1
cp.go
corn/cp_corn/cp.go
+2
-4
cp_relation.go
domain/service/cp_s/cp_relation.go
+28
-9
3.9.0.sql
mysql/3.9.0.sql
+153
-1
cp_relation.go
route/cp_r/cp_relation.go
+36
-11
bag.go
route/user_r/bag.go
+1
-1
No files found.
_const/enum/cp_e/cp_relation.go
View file @
2d562c8f
...
...
@@ -7,7 +7,7 @@ type CpCancelStatus mysql.Type
const
(
//新用户
CpRelationInviteDiamond
=
18888
CpRelationInviteDiamond
=
18888
// cwj----
//1.未接受2.已接受3.拒接导致退费4.过期导致退费
CpInvite
CpInviteStatus
=
1
...
...
corn/cp_corn/cp.go
View file @
2d562c8f
...
...
@@ -30,8 +30,7 @@ func CpInviteCancelInit() {
defer
utils
.
CheckGoPanic
()
model
:=
domain
.
CreateModelNil
()
// 获取超过24小时没被处理的cp邀请
//inviteList, err := cp_m.GetCpInviteByTime(model, time.Now().AddDate(0, 0, -1)) cwj----
inviteList
,
err
:=
cp_m
.
GetCpInviteByTime
(
model
,
time
.
Now
()
.
Add
(
-
time
.
Minute
*
10
))
// cwj----
inviteList
,
err
:=
cp_m
.
GetCpInviteByTime
(
model
,
time
.
Now
()
.
AddDate
(
0
,
0
,
-
1
))
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"CpInviteCancelInit err:%v"
,
err
)
return
...
...
@@ -61,8 +60,7 @@ func CpInviteCancelInit() {
}
// 获取超过24小时没被处理的cp解除申请
//cancelList, err := cp_m.GetCpCancelByTime(model, time.Now().AddDate(0, 0, -1)) cwj----
cancelList
,
err
:=
cp_m
.
GetCpCancelByTime
(
model
,
time
.
Now
()
.
Add
(
-
time
.
Minute
*
10
))
// cwj----
cancelList
,
err
:=
cp_m
.
GetCpCancelByTime
(
model
,
time
.
Now
()
.
AddDate
(
0
,
0
,
-
1
))
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"CpInviteCancelInit err:%v"
,
err
)
return
...
...
domain/service/cp_s/cp_relation.go
View file @
2d562c8f
...
...
@@ -2,6 +2,7 @@ package cp_s
import
(
"encoding/json"
"git.hilo.cn/hilo-common/_const/common"
"git.hilo.cn/hilo-common/_const/enum/diamond_e"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext"
...
...
@@ -13,6 +14,7 @@ import (
"hilo-user/domain/model/cp_m"
"hilo-user/domain/model/diamond_m"
"hilo-user/domain/model/user_m"
"hilo-user/myerr"
"hilo-user/myerr/bizerr"
)
...
...
@@ -37,7 +39,7 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
return
err
}
if
myCp
.
Id
>
0
{
return
msg
.
GetErrByLanguage
(
model
,
0
,
lang
,
comerr
.
InvalidParameter
)
return
msg
.
GetErrByLanguage
(
model
,
common
.
MSG_ID_ALREADY_HAS_CP
,
lang
,
comerr
.
AlreadyHasCp
)
}
// 对方是否已经有cp了
inviCp
,
err
:=
cp_m
.
GetCp
(
model
,
userInvite
.
ID
)
...
...
@@ -45,7 +47,7 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
return
err
}
if
inviCp
.
Id
>
0
{
return
msg
.
GetErrByLanguage
(
model
,
0
,
lang
,
comerr
.
InvalidParameter
)
return
msg
.
GetErrByLanguage
(
model
,
common
.
MSG_ID_ALREADY_HAS_CP
,
lang
,
comerr
.
AlreadyHasCp
)
}
// 我是否发起过cp邀请,且还未被处理
...
...
@@ -58,6 +60,14 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
return
bizerr
.
CpAlreadyInvite
}
content
,
err
:=
msg
.
GetResMultiTextBy
(
model
,
common
.
MSG_ID_WANT_BE_YOUR_CP
,
lang
)
if
err
!=
nil
{
return
err
}
tip
,
err
:=
msg
.
GetResMultiTextBy
(
model
,
common
.
MSG_ID_EXPIRES_AFTER_24_H
,
lang
)
if
err
!=
nil
{
return
err
}
err
=
model
.
Transaction
(
func
(
model
*
domain
.
Model
)
error
{
// 创建邀请记录
cpInvId
,
err
:=
cp_m
.
CreateCpInvite
(
model
,
myUserId
,
userInvite
.
ID
,
cp_e
.
CpRelationInviteDiamond
)
...
...
@@ -74,8 +84,8 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
// 发送私信-邀请
data
,
_
:=
json
.
Marshal
(
cp_m
.
CpInviteMessage
{
Identifier
:
"CpInviteMessage"
,
Msg
:
"Do you want to be CP with me?"
,
Tip
:
"24 hours automatic expiration"
,
Msg
:
content
,
Tip
:
tip
,
Sender
:
user_m
.
ToUserTiny
(
user
),
})
if
err
:=
tencentyun
.
BatchSendCustomMsg
(
model
,
1
,
user
.
ExternalId
,
[]
string
{
userInvite
.
ExternalId
},
string
(
data
),
"cp邀请"
);
err
!=
nil
{
...
...
@@ -89,7 +99,7 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
return
err
}
// socket 推送弹窗
go
rpc
.
SendCpInviteNotice
(
userInvite
.
ID
,
user
.
Code
,
user
.
Nick
,
user
.
Avatar
,
"Do you want to be CP with me?"
,
user
.
ExternalId
)
go
rpc
.
SendCpInviteNotice
(
userInvite
.
ID
,
user
.
Code
,
user
.
Nick
,
user
.
Avatar
,
content
,
user
.
ExternalId
)
return
nil
}
...
...
@@ -109,13 +119,22 @@ func CancelCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
return
bizerr
.
InvalidParameter
}
tip
,
err
:=
msg
.
GetResMultiTextBy
(
model
,
common
.
MSG_ID_EXPIRES_AFTER_24_H
,
lang
)
if
err
!=
nil
{
return
err
}
content
,
err
:=
msg
.
GetResMultiTextBy
(
model
,
common
.
MSG_ID_WANT_UNBIND_CP
,
lang
)
if
err
!=
nil
{
return
err
}
// 自己没有cp了
myCp
,
err
:=
cp_m
.
GetCp
(
model
,
myUserId
)
if
err
!=
nil
{
return
err
}
if
myCp
.
Id
==
0
{
return
m
sg
.
GetErrByLanguage
(
model
,
0
,
lang
,
com
err
.
InvalidParameter
)
return
m
yerr
.
WrapErr
(
biz
err
.
InvalidParameter
)
}
// 对方没有cp了
inviCp
,
err
:=
cp_m
.
GetCp
(
model
,
userRec
.
ID
)
...
...
@@ -123,7 +142,7 @@ func CancelCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
return
err
}
if
inviCp
.
Id
==
0
{
return
m
sg
.
GetErrByLanguage
(
model
,
0
,
lang
,
com
err
.
InvalidParameter
)
return
m
yerr
.
WrapErr
(
biz
err
.
InvalidParameter
)
}
// 是否有关于我的cp解除申请,且还未被处理
...
...
@@ -146,8 +165,8 @@ func CancelCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
// 发送私信-发起解除
data
,
_
:=
json
.
Marshal
(
cp_m
.
CpCancelMessage
{
Identifier
:
"CpCancelMessage"
,
Msg
:
"I want to unbind the CP relationship"
,
Tip
:
"24 hours automatic expiration"
,
Msg
:
content
,
Tip
:
tip
,
Sender
:
user_m
.
ToUserTiny
(
user
),
})
if
err
:=
tencentyun
.
BatchSendCustomMsg
(
model
,
1
,
user
.
ExternalId
,
[]
string
{
userRec
.
ExternalId
},
string
(
data
),
"cp解除"
);
err
!=
nil
{
...
...
mysql/3.9.0.sql
View file @
2d562c8f
This diff is collapsed.
Click to expand it.
route/cp_r/cp_relation.go
View file @
2d562c8f
...
...
@@ -3,6 +3,7 @@ package cp_r
import
(
"encoding/json"
"fmt"
"git.hilo.cn/hilo-common/_const/common"
"git.hilo.cn/hilo-common/_const/enum/diamond_e"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext"
...
...
@@ -61,10 +62,14 @@ func CheckUserCpRelation(c *gin.Context) (*mycontext.MyContext, error) {
return
myCtx
,
err
}
if
cp
.
Id
>
0
{
return
myCtx
,
msg
.
GetErrByLanguage
(
model
,
0
,
lang
,
comerr
.
InvalidParameter
)
// cwj----
return
myCtx
,
msg
.
GetErrByLanguage
(
model
,
common
.
MSG_ID_ALREADY_HAS_CP
,
lang
,
comerr
.
AlreadyHasCp
)
}
msg
,
err
:=
msg
.
GetResMultiTextBy
(
model
,
common
.
MSG_ID_INVITE_CP
,
lang
)
if
err
!=
nil
{
return
myCtx
,
err
}
resp
.
ResponseOk
(
c
,
cp_cv
.
CheckCpRelationRes
{
Diamond
:
cp_e
.
CpRelationInviteDiamond
,
Msg
:
"Do you want to be CP with me?"
})
resp
.
ResponseOk
(
c
,
cp_cv
.
CheckCpRelationRes
{
Diamond
:
cp_e
.
CpRelationInviteDiamond
,
Msg
:
msg
})
return
myCtx
,
nil
}
...
...
@@ -161,7 +166,7 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) {
return
myCtx
,
err
}
if
myCp
.
Id
>
0
{
return
myCtx
,
msg
.
GetErrByLanguage
(
model
,
0
,
lang
,
comerr
.
InvalidParameter
)
return
myCtx
,
msg
.
GetErrByLanguage
(
model
,
common
.
MSG_ID_ALREADY_HAS_CP
,
lang
,
comerr
.
AlreadyHasCp
)
}
// 对方是否已经有cp了
senderCp
,
err
:=
cp_m
.
GetCp
(
model
,
userSender
.
ID
)
...
...
@@ -169,7 +174,7 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) {
return
myCtx
,
err
}
if
senderCp
.
Id
>
0
{
return
myCtx
,
msg
.
GetErrByLanguage
(
model
,
0
,
lang
,
comerr
.
InvalidParameter
)
return
myCtx
,
msg
.
GetErrByLanguage
(
model
,
common
.
MSG_ID_ALREADY_HAS_CP
,
lang
,
comerr
.
AlreadyHasCp
)
}
}
err
=
model
.
Transaction
(
func
(
model
*
domain
.
Model
)
error
{
...
...
@@ -206,7 +211,7 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) {
model
.
Log
.
Errorf
(
"ReplyCpInvite InitCpAnniversary fail:%v-%v-%v"
,
userSender
.
ID
,
user
.
ID
,
err
)
return
err
}
// 发放告白礼物
cwj----
// 发放告白礼物
if
_
,
err
=
bag_tx
.
SendUserBag
(
model
,
userSender
.
ID
,
1
,
cp_e
.
CpConfessionGiftId
,
1
,
3
,
"告白礼物"
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"ReplyCpInvite userSender:%d, user:%d, status:%d, err:%v"
,
userSender
.
ID
,
user
.
ID
,
updateStatus
,
err
)
return
err
...
...
@@ -221,10 +226,18 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) {
// return err
//}
// 私信-接受
content
,
err
:=
msg
.
GetResMultiTextBy
(
model
,
common
.
MSG_ID_BIND_CP_SUCCEED
,
lang
)
if
err
!=
nil
{
return
err
}
tip
,
err
:=
msg
.
GetResMultiTextBy
(
model
,
common
.
MSG_ID_SEND_CP_GIFT
,
lang
)
if
err
!=
nil
{
return
err
}
msgData
,
_
=
json
.
Marshal
(
cp_m
.
CpAcceptInviteMessage
{
Identifier
:
"CpAcceptInviteMessage"
,
Msg
:
"We are already CP!"
,
Tip
:
fmt
.
Sprintf
(
"Celebration gifts have been sent to %s's backpack"
,
userSender
.
Code
),
Msg
:
content
,
Tip
:
fmt
.
Sprintf
(
tip
,
userSender
.
Code
),
Sender
:
user_m
.
ToUserTiny
(
userSender
),
Receiver
:
user_m
.
ToUserTiny
(
user
),
})
...
...
@@ -236,9 +249,13 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) {
return
err
}
// 私信-拒绝
content
,
err
:=
msg
.
GetResMultiTextBy
(
model
,
common
.
MSG_ID_REJECTED_CP_INVITE
,
lang
)
if
err
!=
nil
{
return
err
}
msgData
,
_
=
json
.
Marshal
(
cp_m
.
CpDenyInviteMessage
{
Identifier
:
"CpDenyInviteMessage"
,
Msg
:
fmt
.
Sprintf
(
"%s have declined the CP invitation"
,
user
.
Nick
),
Msg
:
fmt
.
Sprintf
(
content
,
user
.
Nick
),
Sender
:
user_m
.
ToUserTiny
(
user
),
})
}
...
...
@@ -274,7 +291,7 @@ func ReplyCpCancel(c *gin.Context) (*mycontext.MyContext, error) {
return
myCtx
,
bizerr
.
InvalidParameter
}
myUserId
,
_
,
err
:=
req
.
GetUserIdLang
(
c
,
myCtx
)
myUserId
,
lang
,
err
:=
req
.
GetUserIdLang
(
c
,
myCtx
)
if
err
!=
nil
{
return
myCtx
,
err
}
...
...
@@ -327,9 +344,13 @@ func ReplyCpCancel(c *gin.Context) (*mycontext.MyContext, error) {
var
msgData
[]
byte
if
optType
==
1
{
// 撤销解除
// 私信
//content, err := msg.GetResMultiTextBy(model, common.MSG_ID_UNBIND_CP_SUCCEED, lang)
//if err != nil {
// return err
//}
msgData
,
_
=
json
.
Marshal
(
cp_m
.
CpDealCancelMessage
{
Identifier
:
"CpDealCancelMessage"
,
Msg
:
fmt
.
Sprintf
(
"%s withdrew my application to lift CP"
,
myUser
.
Nick
),
Msg
:
fmt
.
Sprintf
(
"%s withdrew my application to lift CP"
,
myUser
.
Nick
),
// cwj----
Status
:
1
,
})
}
else
{
// 接受解除
...
...
@@ -340,9 +361,13 @@ func ReplyCpCancel(c *gin.Context) (*mycontext.MyContext, error) {
return
err
}
// 私信-接受解除
content
,
err
:=
msg
.
GetResMultiTextBy
(
model
,
common
.
MSG_ID_UNBIND_CP_SUCCEED
,
lang
)
if
err
!=
nil
{
return
err
}
msgData
,
_
=
json
.
Marshal
(
cp_m
.
CpDealCancelMessage
{
Identifier
:
"CpDealCancelMessage"
,
Msg
:
"The CP relationship has been unbound, the CP value has been cleared, and the CP privilege has disappeared"
,
Msg
:
content
,
Status
:
2
,
})
}
...
...
route/user_r/bag.go
View file @
2d562c8f
...
...
@@ -57,7 +57,7 @@ func UserBag(c *gin.Context) (*mycontext.MyContext, error) {
Count
:
bagGift
.
Count
,
RemainDays
:
int
(
bagGift
.
EndTime
.
Sub
(
time
.
Now
())
.
Hours
()
/
24
),
}
if
gift
.
ID
==
cp_e
.
CpConfessionGiftId
{
//
cwj----
如果是cp告白礼物
if
gift
.
ID
==
cp_e
.
CpConfessionGiftId
{
// 如果是cp告白礼物
info
.
TextStyleList
=
make
([]
*
user_cv
.
TextStyle
,
0
,
2
)
info
.
TextStyleList
=
append
(
info
.
TextStyleList
,
&
user_cv
.
TextStyle
{
TextColor
:
"#ce0083"
,
TextSize
:
20
,
TextKey
:
"sender_name"
},
...
...
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