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
ddef0d55
Commit
ddef0d55
authored
Jun 28, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
邀请派对
parent
a3ae4ca1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
7 deletions
+56
-7
invite_apply.go
domain/model/invite_m/invite_apply.go
+2
-2
promotion_info.go
domain/model/promotion_m/promotion_info.go
+37
-0
party_invite.go
route/invite_r/party_invite.go
+17
-5
No files found.
domain/model/invite_m/invite_apply.go
View file @
ddef0d55
...
...
@@ -28,8 +28,8 @@ func CreateInviteApply(model *domain.Model, userId, newUserId uint64, platform,
return
nil
}
func
GetApplyList
(
model
*
domain
.
Model
,
userId
uint64
,
pageIndex
,
pageSize
,
gType
int
,
beginTime
,
endTime
time
.
Time
)
([]
*
InviteApply
,
int64
,
error
)
{
db
:=
model
.
DB
()
.
Model
(
InviteApply
{})
.
Where
(
"user_id
= ?"
,
userId
)
.
Where
(
"created_time >= ? and created_time <= ?"
,
beginTime
,
endTime
)
func
GetApplyList
(
model
*
domain
.
Model
,
userId
s
[]
uint64
,
pageIndex
,
pageSize
,
gType
int
,
beginTime
,
endTime
time
.
Time
)
([]
*
InviteApply
,
int64
,
error
)
{
db
:=
model
.
DB
()
.
Model
(
InviteApply
{})
.
Where
(
"user_id
in (?)"
,
userIds
)
.
Where
(
"created_time >= ? and created_time <= ?"
,
beginTime
,
endTime
)
switch
gType
{
// 1.已申请2.待审核3.已通过4.已拒绝
case
2
:
db
=
db
.
Where
(
"`status` = ?"
,
0
)
...
...
domain/model/promotion_m/promotion_info.go
View file @
ddef0d55
...
...
@@ -37,6 +37,43 @@ func IsPromotionInvitee(model *domain.Model, userId mysql.ID) (bool, error) {
return
true
,
nil
}
// 检查是否推广经理
func
IsPromotionManager
(
model
*
domain
.
Model
,
userId
mysql
.
ID
)
bool
{
var
promotionAgent
PromotionAgent
if
err
:=
model
.
Db
.
Model
(
PromotionAgent
{})
.
Where
(
"manager_id = ?"
,
userId
)
.
First
(
&
promotionAgent
)
.
Error
;
err
!=
nil
{
if
err
!=
gorm
.
ErrRecordNotFound
{
model
.
Log
.
Errorf
(
"IsPromotionManager fail:%v"
,
err
)
}
}
else
if
promotionAgent
.
ID
>
0
{
return
true
}
return
false
}
// 检查是否我的推广经理
func
IsMyPromotionManager
(
model
*
domain
.
Model
,
userId
,
myUserId
mysql
.
ID
)
bool
{
var
promotionAgent
PromotionAgent
if
err
:=
model
.
Db
.
Model
(
PromotionAgent
{})
.
Where
(
"manager_id = ? and agent_id = ?"
,
userId
,
myUserId
)
.
First
(
&
promotionAgent
)
.
Error
;
err
!=
nil
{
if
err
!=
gorm
.
ErrRecordNotFound
{
model
.
Log
.
Errorf
(
"IsMyPromotionManager fail:%v"
,
err
)
}
}
else
if
promotionAgent
.
ID
>
0
{
return
true
}
return
false
}
// 获取推广经理拥有的所有推广员,包含自己
func
GetPromotionManagerAgentList
(
model
*
domain
.
Model
,
userId
mysql
.
ID
)
([]
uint64
,
error
)
{
uids
:=
make
([]
uint64
,
0
)
if
err
:=
model
.
Db
.
Model
(
PromotionAgent
{})
.
Where
(
"manager_id = ?"
,
userId
)
.
Select
(
"agent_id"
)
.
Pluck
(
"agent_id"
,
&
uids
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"IsPromotionManager fail:%v"
,
err
)
return
nil
,
err
}
return
uids
,
nil
}
// 添加推广邀请关系
func
AddPromotionInvite
(
model
*
domain
.
Model
,
managerId
,
agentId
,
invitee
mysql
.
ID
,
platform
,
platformId
,
reason
,
inviteDate
string
)
error
{
if
err
:=
model
.
Db
.
Create
(
&
PromotionInvite
{
...
...
route/invite_r/party_invite.go
View file @
ddef0d55
...
...
@@ -37,10 +37,10 @@ func InviteApply(c *gin.Context) (*mycontext.MyContext, error) {
VideoUrl
string
`form:"videoUrl" binding:"required"`
}
//
myUserId, err := req.GetUserId(c)
//
if err != nil {
//
return myCtx, err
//
}
myUserId
,
err
:=
req
.
GetUserId
(
c
)
if
err
!=
nil
{
return
myCtx
,
err
}
var
param
paramStr
if
err
:=
c
.
ShouldBind
(
&
param
);
err
!=
nil
{
...
...
@@ -74,6 +74,10 @@ func InviteApply(c *gin.Context) (*mycontext.MyContext, error) {
model
.
Log
.
Errorf
(
"InviteApply param:%v"
,
param
)
return
myCtx
,
bizerr
.
InvalidParameter
}
if
user
.
ID
!=
myUserId
&&
!
promotion_m
.
IsMyPromotionManager
(
model
,
user
.
ID
,
myUserId
)
{
model
.
Log
.
Errorf
(
"InviteApply 没有邀请资格 param:%v"
,
param
)
return
myCtx
,
bizerr
.
InviteApplyNoPermission
}
// 邀请人是否有资格邀请
if
!
promotion_m
.
IsPromotionAgent
(
model
,
user
.
ID
)
{
model
.
Log
.
Errorf
(
"InviteApply 没有邀请资格 param:%v"
,
param
)
...
...
@@ -144,7 +148,15 @@ func InviteApplyList(c *gin.Context) (*mycontext.MyContext, error) {
var
model
=
domain
.
CreateModelContext
(
myCtx
)
list
,
total
,
err
:=
invite_m
.
GetApplyList
(
model
,
userId
,
param
.
PageIndex
,
param
.
PageSize
,
param
.
Type
,
beginTime
,
endTime
)
agentIds
:=
[]
uint64
{
userId
}
if
promotion_m
.
IsPromotionManager
(
model
,
userId
)
{
agentIds
,
err
=
promotion_m
.
GetPromotionManagerAgentList
(
model
,
userId
)
if
err
!=
nil
{
return
myCtx
,
err
}
}
list
,
total
,
err
:=
invite_m
.
GetApplyList
(
model
,
agentIds
,
param
.
PageIndex
,
param
.
PageSize
,
param
.
Type
,
beginTime
,
endTime
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetApplyList param:%v, err:%v"
,
param
,
err
)
return
myCtx
,
err
...
...
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