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
4771b478
Commit
4771b478
authored
Jun 27, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/promotion' into feature/party_reply
parents
d443f80a
c8820000
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
0 deletions
+93
-0
model.go
domain/model/promotion_m/model.go
+30
-0
promotion_info.go
domain/model/promotion_m/promotion_info.go
+63
-0
No files found.
domain/model/promotion_m/model.go
0 → 100644
View file @
4771b478
package
promotion_m
import
"git.hilo.cn/hilo-common/resource/mysql"
// 推广员
type
PromotionAgent
struct
{
mysql
.
Entity
ManagerId
mysql
.
ID
AgentId
mysql
.
ID
}
// 邀请关系
type
PromotionInvite
struct
{
mysql
.
Entity
ManagerId
mysql
.
ID
AgentId
mysql
.
ID
Invitee
mysql
.
ID
Platform
string
PlatformId
string
Reason
string
InviteDate
string
}
// 邀请关系日志
type
PromotionInviteLog
struct
{
mysql
.
Entity
AgentId
mysql
.
ID
Invitee
mysql
.
ID
AddReduce
mysql
.
AddReduce
}
domain/model/promotion_m/promotion_info.go
0 → 100644
View file @
4771b478
package
promotion_m
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
)
// 获取推广员平台
func
GetPromotionPlatforms
(
model
*
domain
.
Model
)
[]
string
{
return
[]
string
{
"Falla"
,
"Yalla"
,
"Whisper"
,
"Ahlan"
,
"Mashi"
,
"YoYo"
,
"Yoho"
,
"Echo"
,
"Hawa"
,
"Yalla Ludo"
,
"Hafla"
}
}
// 检查是否推广员
func
IsPromotionAgent
(
model
*
domain
.
Model
,
userId
mysql
.
ID
)
bool
{
var
promotionAgent
PromotionAgent
if
err
:=
model
.
Db
.
Model
(
PromotionAgent
{})
.
Where
(
"agent_id = ?"
,
userId
)
.
First
(
&
promotionAgent
)
.
Error
;
err
!=
nil
{
if
err
!=
gorm
.
ErrRecordNotFound
{
model
.
Log
.
Errorf
(
"IsPromotionAgent fail:%v"
,
err
)
}
}
else
if
promotionAgent
.
ID
>
0
{
return
true
}
return
false
}
// 检查被邀请人是否存在
func
IsPromotionInvitee
(
model
*
domain
.
Model
,
userId
mysql
.
ID
)
(
bool
,
error
)
{
var
promotionInvite
PromotionInvite
if
err
:=
model
.
Db
.
Model
(
PromotionInvite
{})
.
Where
(
"invitee = ?"
,
userId
)
.
First
(
&
promotionInvite
)
.
Error
;
err
!=
nil
{
if
err
!=
gorm
.
ErrRecordNotFound
{
return
false
,
err
}
return
false
,
nil
}
// err == nil, record exists
return
true
,
nil
}
// 添加推广邀请关系
func
AddPromotionInvite
(
model
*
domain
.
Model
,
managerId
,
agentId
,
invitee
mysql
.
ID
,
platform
,
platformId
,
reason
,
inviteDate
string
)
error
{
if
err
:=
model
.
Db
.
Create
(
&
PromotionInvite
{
ManagerId
:
managerId
,
AgentId
:
agentId
,
Invitee
:
invitee
,
Platform
:
platform
,
PlatformId
:
platformId
,
Reason
:
reason
,
InviteDate
:
inviteDate
,
})
.
Error
;
err
!=
nil
{
return
err
}
return
addPromotionInviteLog
(
model
,
agentId
,
invitee
,
mysql
.
ADD
)
}
// 添加推广邀请关系-日志
func
addPromotionInviteLog
(
model
*
domain
.
Model
,
agentId
,
invitee
mysql
.
ID
,
addReduce
mysql
.
AddReduce
)
error
{
return
model
.
Db
.
Create
(
&
PromotionInviteLog
{
AgentId
:
agentId
,
Invitee
:
invitee
,
AddReduce
:
addReduce
,
})
.
Error
}
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