Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-common
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
hujiebin
hilo-common
Commits
0ad91afc
Commit
0ad91afc
authored
Sep 01, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 处理并发
parent
898a0b58
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
9 deletions
+19
-9
userNoble.go
internal/model/noble_m/userNoble.go
+6
-0
fruit_day_award.go
script/fruit_day_award.go
+2
-2
noble.go
txop/noble_tx/noble.go
+11
-7
No files found.
internal/model/noble_m/userNoble.go
View file @
0ad91afc
...
...
@@ -22,6 +22,12 @@ func (ub *UserNoble) UpdateEndTime(db *gorm.DB, endTime time.Time) (int64, error
return
r
.
RowsAffected
,
r
.
Error
}
// 延长贵族
func
(
ub
*
UserNoble
)
ExtenedEndTime
(
db
*
gorm
.
DB
,
day
int
)
(
int64
,
error
)
{
r
:=
db
.
Model
(
&
UserNoble
{})
.
Where
(
ub
)
.
Update
(
"end_time"
,
gorm
.
Expr
(
"DATE_ADD(end_time,INTERVAL ? day)"
,
day
))
return
r
.
RowsAffected
,
r
.
Error
}
// 查询用户未过期的贵族
func
(
ub
*
UserNoble
)
Find
(
db
*
gorm
.
DB
)
([]
UserNoble
,
error
)
{
rows
:=
make
([]
UserNoble
,
0
)
...
...
script/fruit_day_award.go
View file @
0ad91afc
...
...
@@ -41,7 +41,7 @@ func ats32(a interface{}) string {
}
func
main
()
{
url
:=
"https://apiv2.faceline.live/v1/fruitMachine/rank/award?lang=zh-cn&pageIndex=1&pageSize=5000&beginDate=2023-08-3
0&endDate=2023-08-30
&userCode=&timezone=1"
url
:=
"https://apiv2.faceline.live/v1/fruitMachine/rank/award?lang=zh-cn&pageIndex=1&pageSize=5000&beginDate=2023-08-3
1&endDate=2023-08-31
&userCode=&timezone=1"
method
:=
"GET"
client
:=
&
http
.
Client
{}
...
...
@@ -95,7 +95,7 @@ func main() {
for
_
,
v
:=
range
svips
{
svipMap
[
v
.
Code
]
=
v
.
Level
}
excelFileName
:=
fmt
.
Sprintf
(
"./083
0
水果机中奖榜.xlsx"
)
excelFileName
:=
fmt
.
Sprintf
(
"./083
1
水果机中奖榜.xlsx"
)
xlFile
:=
xlsx
.
NewFile
()
sheet
,
_
:=
xlFile
.
AddSheet
(
"charge"
)
row
:=
sheet
.
AddRow
()
...
...
txop/noble_tx/noble.go
View file @
0ad91afc
...
...
@@ -21,7 +21,7 @@ func SendNoble(model *domain.Model, receiverUserId mysql.ID, level uint16, days
return
fmt
.
Errorf
(
"level is 0"
)
}
cfg
,
err
:=
noble_m
.
GetConfigByLevel
(
model
.
D
b
,
level
)
cfg
,
err
:=
noble_m
.
GetConfigByLevel
(
model
.
D
B
()
,
level
)
if
err
!=
nil
{
return
err
}
...
...
@@ -29,7 +29,7 @@ func SendNoble(model *domain.Model, receiverUserId mysql.ID, level uint16, days
return
fmt
.
Errorf
(
"level is 0"
)
}
n
:=
noble_m
.
UserNoble
{
UserId
:
receiverUserId
,
Level
:
level
}
records
,
err
:=
n
.
FindAll
(
model
.
D
b
)
records
,
err
:=
n
.
FindAll
(
model
.
D
B
()
)
if
err
!=
nil
{
return
err
}
...
...
@@ -42,7 +42,7 @@ func SendNoble(model *domain.Model, receiverUserId mysql.ID, level uint16, days
// 新增贵族
endTime
:=
time
.
Now
()
.
AddDate
(
0
,
0
,
int
(
days
))
n
=
noble_m
.
UserNoble
{
UserId
:
receiverUserId
,
Level
:
level
,
EndTime
:
endTime
}
err
=
n
.
Create
(
model
.
D
b
)
err
=
n
.
Create
(
model
.
D
B
()
)
if
err
!=
nil
{
return
err
}
...
...
@@ -55,7 +55,7 @@ func SendNoble(model *domain.Model, receiverUserId mysql.ID, level uint16, days
SrcType
:
noble_m
.
SRC_APP
,
NewEndTime
:
endTime
,
}
err
=
nbl
.
Create
(
model
.
D
b
)
err
=
nbl
.
Create
(
model
.
D
B
()
)
if
err
!=
nil
{
return
err
}
...
...
@@ -71,12 +71,16 @@ func SendNoble(model *domain.Model, receiverUserId mysql.ID, level uint16, days
Entity
:
mysql
.
Entity
{
ID
:
n
.
ID
,
UpdatedTime
:
n
.
UpdatedTime
},
}
af
,
err
:=
nn
.
UpdateEndTime
(
model
.
D
b
,
endTime
)
af
,
err
:=
nn
.
UpdateEndTime
(
model
.
D
B
()
,
endTime
)
if
err
!=
nil
{
return
err
}
if
af
<=
0
{
return
fmt
.
Errorf
(
"bizerr.TransactionFailed"
)
if
af2
,
err
:=
nn
.
ExtenedEndTime
(
model
.
DB
(),
days
);
err
!=
nil
{
return
err
}
else
if
af2
<=
0
{
return
fmt
.
Errorf
(
"bizerr.TransactionFailed rows 0"
)
}
}
nbl
:=
noble_m
.
UserNobleLog
{
...
...
@@ -88,7 +92,7 @@ func SendNoble(model *domain.Model, receiverUserId mysql.ID, level uint16, days
OldEndTime
:
n
.
EndTime
,
NewEndTime
:
endTime
,
}
err
=
nbl
.
Create
(
model
.
D
b
)
err
=
nbl
.
Create
(
model
.
D
B
()
)
if
err
!=
nil
{
return
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