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
92b6d007
Commit
92b6d007
authored
Jun 05, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cp
parent
1f3e3ad1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
19 deletions
+61
-19
cp_relation.go
domain/model/cp_m/cp_relation.go
+20
-6
user.go
domain/model/user_m/user.go
+29
-0
cp_relation.go
domain/service/cp_s/cp_relation.go
+2
-2
cp_relation.go
route/cp_r/cp_relation.go
+10
-11
No files found.
domain/model/cp_m/cp_relation.go
View file @
92b6d007
...
...
@@ -5,6 +5,7 @@ import (
"git.hilo.cn/hilo-common/utils"
"gorm.io/gorm"
"hilo-user/_const/enum/cp_e"
"hilo-user/domain/model/user_m"
"hilo-user/myerr/bizerr"
"time"
)
...
...
@@ -24,13 +25,26 @@ type CpInvite struct {
Status
cp_e
.
CpInviteStatus
`json:"status"`
}
// 发送私信
// 发送私信
-发起邀请
type
CpInviteMessage
struct
{
Identifier
string
`json:"identifier"`
Msg
string
`json:"msg"`
Status
uint8
`json:"status"`
//1.发起邀请2.接受3.拒接
Avatar1
string
`json:"avatar1"`
Avatar2
string
`json:"avatar2"`
Identifier
string
`json:"identifier"`
Msg
string
`json:"msg"`
Sender
*
user_m
.
UserTiny
`json:"sender"`
}
// 发送私信-接受邀请
type
CpAcceptInviteMessage
struct
{
Identifier
string
`json:"identifier"`
Msg
string
`json:"msg"`
Sender
*
user_m
.
UserTiny
`json:"sender"`
Receiver
*
user_m
.
UserTiny
`json:"receiver"`
}
// 发送私信-拒绝邀请
type
CpDenyInviteMessage
struct
{
Identifier
string
`json:"identifier"`
Msg
string
`json:"msg"`
Sender
*
user_m
.
UserTiny
`json:"sender"`
}
type
CpCancel
struct
{
...
...
domain/model/user_m/user.go
View file @
92b6d007
...
...
@@ -6,6 +6,7 @@ import (
"hilo-user/_const/enum/user_e"
"hilo-user/myerr"
"hilo-user/myerr/bizerr"
"time"
)
//用户信息
...
...
@@ -106,3 +107,31 @@ func GetUserByExtId(model *domain.Model, externalId string) (*User, error) {
user
.
Model
=
model
return
&
user
,
nil
}
func
ToUserTiny
(
user
*
User
)
*
UserTiny
{
return
&
UserTiny
{
ID
:
user
.
ID
,
ExternalId
:
user
.
ExternalId
,
Avatar
:
user
.
Avatar
,
Nick
:
user
.
Nick
,
Sex
:
user
.
Sex
,
Code
:
user
.
Code
,
Description
:
user
.
Description
,
Country
:
user
.
Country
,
CountryIcon
:
user
.
CountryIcon
,
IsPrettyCode
:
user
.
IsPrettyCode
(),
IsLogout
:
IfLogout
(
user
.
LogoutTime
),
Birthday
:
BirthdayToUint64
(
&
user
.
Birthday
),
}
}
func
IfLogout
(
logoutTime
int64
)
bool
{
return
logoutTime
>
0
&&
time
.
Now
()
.
Unix
()
>
logoutTime
}
func
BirthdayToUint64
(
birthday
*
mysql
.
Timestamp
)
*
uint64
{
if
*
birthday
==
0
{
return
nil
}
return
(
*
uint64
)(
birthday
)
}
domain/service/cp_s/cp_relation.go
View file @
92b6d007
...
...
@@ -67,11 +67,11 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
model
.
Log
.
Errorf
(
"InviteCpRelation myUserId:%d, err:%v"
,
myUserId
,
err
)
return
err
}
// 发送私信
// 发送私信
-邀请
data
,
_
:=
json
.
Marshal
(
cp_m
.
CpInviteMessage
{
Identifier
:
"CpInviteMessage"
,
Msg
:
"Do you want to be CP with me?"
,
S
tatus
:
uint8
(
cp_e
.
CpInvite
),
S
ender
:
user_m
.
ToUserTiny
(
user
),
})
if
err
:=
tencentyun
.
BatchSendCustomMsg
(
model
,
1
,
user
.
ExternalId
,
[]
string
{
userInvite
.
ExternalId
},
string
(
data
),
"cp邀请"
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"BatchSendCustomMsg fail:%v"
,
err
)
...
...
route/cp_r/cp_relation.go
View file @
92b6d007
...
...
@@ -188,26 +188,25 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) {
// model.Log.Errorf("ReplyCpInvite userSender:%d, user:%d, status:%d, err:%v", userSender.ID, user.ID, updateStatus, err)
// return err
//}
// 私信
msgData
,
_
=
json
.
Marshal
(
cp_m
.
CpInviteMessage
{
Identifier
:
"CpInviteMessage"
,
// 私信
-接受
msgData
,
_
=
json
.
Marshal
(
cp_m
.
Cp
Accept
InviteMessage
{
Identifier
:
"Cp
Accept
InviteMessage"
,
Msg
:
"We are already CP!"
,
Status
:
uint8
(
cp_e
.
CpInviteAccept
),
Avatar1
:
userSender
.
Avatar
,
Avatar2
:
user
.
Avatar
,
Sender
:
user_m
.
ToUserTiny
(
userSender
),
Receiver
:
user_m
.
ToUserTiny
(
user
),
})
}
else
{
// 拒
接
}
else
{
// 拒
绝
// 退费
err
=
diamond_m
.
ChangeDiamondAccountDetail
(
model
,
diamond_e
.
CpInviteRefund
,
cpRecord
.
Id
,
cpRecord
.
UserId
,
cpRecord
.
DiamondNum
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"ReplyCpInvite UserId:%d, err:%v"
,
cpRecord
.
UserId
,
err
)
return
err
}
// 私信
msgData
,
_
=
json
.
Marshal
(
cp_m
.
CpInviteMessage
{
Identifier
:
"CpInviteMessage"
,
// 私信
-拒绝
msgData
,
_
=
json
.
Marshal
(
cp_m
.
Cp
Deny
InviteMessage
{
Identifier
:
"Cp
Deny
InviteMessage"
,
Msg
:
fmt
.
Sprintf
(
"%s have declined the CP invitation"
,
user
.
Nick
),
S
tatus
:
uint8
(
cp_e
.
CpInviteRefuse
),
S
ender
:
user_m
.
ToUserTiny
(
user
),
})
}
if
err
:=
tencentyun
.
BatchSendCustomMsg
(
model
,
1
,
userSender
.
ExternalId
,
[]
string
{
user
.
ExternalId
},
string
(
msgData
),
"cp邀请"
);
err
!=
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