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
d3cfb084
Commit
d3cfb084
authored
May 29, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cp邀请
parent
48e5c656
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
0 deletions
+49
-0
cp_relation.go
_const/enum/cp_e/cp_relation.go
+10
-0
cp_relation.go
domain/model/cp_m/cp_relation.go
+19
-0
3.9.0.sql
mysql/3.9.0.sql
+15
-0
cp_relation.go
route/cp_r/cp_relation.go
+5
-0
No files found.
_const/enum/cp_e/cp_relation.go
View file @
d3cfb084
package
cp_e
import
"git.hilo.cn/hilo-common/resource/mysql"
type
CpInviteStatus
mysql
.
Type
const
(
//新用户
CpRelationInviteDiamond
=
18888
//1.未接受2.已接受3.拒接导致退费4.过期导致退费
CpInvite
CpInviteStatus
=
1
CpInviteAccept
CpInviteStatus
=
2
CpInviteRefuse
CpInviteStatus
=
3
CpInviteExpired
CpInviteStatus
=
4
)
domain/model/cp_m/cp_relation.go
View file @
d3cfb084
...
...
@@ -2,7 +2,9 @@ package cp_m
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
"hilo-user/_const/enum/cp_e"
"hilo-user/myerr/bizerr"
"time"
)
...
...
@@ -14,6 +16,14 @@ type CpRelation struct {
CreatedTime
time
.
Time
`json:"createdTime"`
}
type
CpInvite
struct
{
Id
uint64
`json:"id"`
UserId
uint64
`json:"userId"`
InviteUserId
uint64
`json:"inviteUserId"`
DiamondNum
uint32
`json:"diamondNum"`
Status
mysql
.
Type
`json:"status"`
}
func
CreateCp
(
model
*
domain
.
Model
,
userId1
,
userId2
uint64
)
error
{
userIds
:=
[]
uint64
{
userId1
,
userId2
}
result
:=
model
.
DB
()
.
Exec
(
"insert into cp_relation(user_id1, user_id2) values(?,?) where not exists (select user_id1 from cp_relation where user_id1 in (?) or user_id2 in (?));"
,
userId1
,
userId2
,
userIds
,
userIds
)
...
...
@@ -39,3 +49,12 @@ func GetCp(model *domain.Model, userId uint64) (*CpRelation, error) {
}
return
res
,
nil
}
func
CreateCpInvite
(
model
*
domain
.
Model
,
userId
,
userIdInvite
uint64
,
diamondNum
uint32
)
error
{
err
:=
model
.
DB
()
.
Model
(
CpInvite
{})
.
Create
(
CpInvite
{
UserId
:
userId
,
InviteUserId
:
userIdInvite
,
DiamondNum
:
diamondNum
,
Status
:
mysql
.
Type
(
cp_e
.
CpInvite
)})
.
Error
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"CreateCpInvite user1:%d, user2:%d, diamondNum:%d, err:%v"
,
userId
,
userIdInvite
,
diamondNum
,
err
)
return
err
}
return
nil
}
mysql/3.9.0.sql
View file @
d3cfb084
...
...
@@ -13,3 +13,18 @@ CREATE TABLE `cp_relation` (
INSERT
INTO
hilo
.
diamond_operate_set
(
diamond_num
,
frequency_num
,
frequency_day
,
diamond_max_num
,
add_reduce
,
`type`
,
name
,
status
,
diamond_type
)
VALUES
(
-
1
,
-
1
,
-
1
,
-
1
,
2
,
94
,
'cp邀请扣费'
,
1
,
1
),
(
-
1
,
-
1
,
-
1
,
-
1
,
1
,
95
,
'cp邀请退费'
,
1
,
1
);
CREATE
TABLE
`cp_invite`
(
`id`
bigint
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'id'
,
`user_id`
bigint
NOT
NULL
COMMENT
'发起邀请者'
,
`invite_user_id`
bigint
NOT
NULL
COMMENT
'被邀请的人'
,
`diamond_num`
int
unsigned
NOT
NULL
COMMENT
'邀请者花费的钻石'
,
`status`
tinyint
unsigned
NOT
NULL
COMMENT
'状态1.未接受2.已接受3.拒接导致退费4.过期导致退费'
,
`created_time`
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
`updated_time`
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
,
PRIMARY
KEY
(
`id`
),
KEY
`uid_idx`
(
`user_id`
)
USING
BTREE
,
KEY
`uid2_idx`
(
`invite_user_id`
)
USING
BTREE
,
KEY
`status_idx`
(
`status`
)
USING
BTREE
,
KEY
`created_time`
(
`created_time`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_0900_ai_ci
COMMENT
=
'cp邀请发起记录'
;
\ No newline at end of file
route/cp_r/cp_relation.go
View file @
d3cfb084
...
...
@@ -98,6 +98,11 @@ func InviteCpRelation(c *gin.Context) (*mycontext.MyContext, error) {
model
.
Log
.
Errorf
(
"InviteCpRelation myUserId:%d, err:%v"
,
myUserId
,
err
)
return
err
}
err
=
cp_m
.
CreateCpInvite
(
model
,
myUserId
,
userInvite
.
ID
,
cp_e
.
CpRelationInviteDiamond
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"InviteCpRelation myUserId:%d, err:%v"
,
myUserId
,
err
)
return
err
}
// 发送私信
type
CpInviteMessage
struct
{
Identifier
string
`json:"identifier"`
...
...
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