Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
admin-backend
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
Odysseus
admin-backend
Commits
f211ebb5
Commit
f211ebb5
authored
Jun 05, 2024
by
brent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify startRevenue
parent
42202bd0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
1 deletion
+24
-1
.DS_Store
.DS_Store
+0
-0
client.go
controllers/client.go
+19
-0
cronjob.go
libs/cronjob/cronjob.go
+5
-1
No files found.
.DS_Store
View file @
f211ebb5
No preview for this file type
controllers/client.go
View file @
f211ebb5
...
@@ -367,6 +367,23 @@ func weiToAGI(wei *big.Int) *big.Float {
...
@@ -367,6 +367,23 @@ func weiToAGI(wei *big.Int) *big.Float {
return
agi
return
agi
}
}
func
removeDuplicates
(
arr
[]
models
.
WeiStruct
)
[]
models
.
WeiStruct
{
// 创建一个 map 来存储数组中的元素
elementMap
:=
make
(
map
[
time
.
Time
]
bool
)
result
:=
[]
models
.
WeiStruct
{}
// 遍历数组,将每个元素添加到 map 中
for
_
,
elem
:=
range
arr
{
// 如果 map 中不存在该元素,则将其添加到结果数组中
if
!
elementMap
[
elem
.
Time
]
{
elementMap
[
elem
.
Time
]
=
true
result
=
append
(
result
,
elem
)
}
}
return
result
}
func
(
server
*
ClientController
)
TaskReward
()
{
func
(
server
*
ClientController
)
TaskReward
()
{
body
:=
server
.
Ctx
.
Input
.
RequestBody
body
:=
server
.
Ctx
.
Input
.
RequestBody
appRequest
:=
models
.
AppRequest
{}
appRequest
:=
models
.
AppRequest
{}
...
@@ -498,6 +515,7 @@ func (server *ClientController) TaskReward() {
...
@@ -498,6 +515,7 @@ func (server *ClientController) TaskReward() {
//}
//}
sql
=
fmt
.
Sprintf
(
"SELECT * FROM reward_multiplier WHERE time in(%s) ORDER BY time DESC;"
,
dateString
)
sql
=
fmt
.
Sprintf
(
"SELECT * FROM reward_multiplier WHERE time in(%s) ORDER BY time DESC;"
,
dateString
)
wei
,
err
:=
postgres
.
QueryWei
(
sql
)
wei
,
err
:=
postgres
.
QueryWei
(
sql
)
wei
=
removeDuplicates
(
wei
)
//return total, data, err
//return total, data, err
for
_
,
value
:=
range
wei
{
for
_
,
value
:=
range
wei
{
key
:=
value
.
Time
.
Format
(
format
)
key
:=
value
.
Time
.
Format
(
format
)
...
@@ -678,6 +696,7 @@ func (server *ClientController) IncomeRecord() {
...
@@ -678,6 +696,7 @@ func (server *ClientController) IncomeRecord() {
//}
//}
sql
=
fmt
.
Sprintf
(
"SELECT * FROM reward_multiplier WHERE time in(%s) ORDER BY time DESC;"
,
dateString
)
sql
=
fmt
.
Sprintf
(
"SELECT * FROM reward_multiplier WHERE time in(%s) ORDER BY time DESC;"
,
dateString
)
wei
,
err
:=
postgres
.
QueryWei
(
sql
)
wei
,
err
:=
postgres
.
QueryWei
(
sql
)
wei
=
removeDuplicates
(
wei
)
for
_
,
value
:=
range
wei
{
for
_
,
value
:=
range
wei
{
key
:=
value
.
Time
.
Format
(
format
)
key
:=
value
.
Time
.
Format
(
format
)
bills
:=
groupedItems
[
key
]
bills
:=
groupedItems
[
key
]
...
...
libs/cronjob/cronjob.go
View file @
f211ebb5
...
@@ -277,6 +277,7 @@ func startRevenue() {
...
@@ -277,6 +277,7 @@ func startRevenue() {
logs
.
Debug
(
"startRevenue revenueTask"
)
logs
.
Debug
(
"startRevenue revenueTask"
)
total
,
multipliers
,
err
:=
checkMultiplier
()
total
,
multipliers
,
err
:=
checkMultiplier
()
logs
.
Debug
(
"checkMultiplier total,multipliers"
,
total
,
multipliers
,
err
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
...
@@ -288,8 +289,10 @@ func startRevenue() {
...
@@ -288,8 +289,10 @@ func startRevenue() {
date
:=
fmt
.
Sprintf
(
time
.
Format
(
"2006-01-02"
))
date
:=
fmt
.
Sprintf
(
time
.
Format
(
"2006-01-02"
))
dates
=
append
(
dates
,
date
)
dates
=
append
(
dates
,
date
)
}
}
logs
.
Debug
(
"checkMultiplier dates,begore"
,
dates
)
if
total
<=
0
{
if
total
<=
0
{
dates
=
checkDate
()
dates
=
checkDate
()
logs
.
Debug
(
"checkMultiplier dates if checkDate"
,
dates
)
}
}
reaponse
,
err
:=
getWeiPerWorkload
(
dates
)
reaponse
,
err
:=
getWeiPerWorkload
(
dates
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -400,12 +403,12 @@ func getWeiPerWorkload(dates []string) ([]models.WeiPerWorkloadStruct, error) {
...
@@ -400,12 +403,12 @@ func getWeiPerWorkload(dates []string) ([]models.WeiPerWorkloadStruct, error) {
return
nil
,
err
return
nil
,
err
}
}
defer
resp
.
Body
.
Close
()
defer
resp
.
Body
.
Close
()
logs
.
Info
(
"getWeiPerWorkload resp code"
,
resp
.
StatusCode
)
body
,
err
:=
io
.
ReadAll
(
resp
.
Body
)
body
,
err
:=
io
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
if
err
!=
nil
{
logs
.
Info
(
"Error reading response:"
,
err
)
logs
.
Info
(
"Error reading response:"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
logs
.
Info
(
"getWeiPerWorkload resp body"
,
string
(
body
))
var
response
models
.
WeiPerWorkloadResponse
var
response
models
.
WeiPerWorkloadResponse
if
err
:=
json
.
Unmarshal
(
body
,
&
response
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
body
,
&
response
);
err
!=
nil
{
logs
.
Info
(
"Error Unmarshal response:"
,
err
)
logs
.
Info
(
"Error Unmarshal response:"
,
err
)
...
@@ -446,6 +449,7 @@ func insertMultiplier(data []models.WeiPerWorkloadStruct) error {
...
@@ -446,6 +449,7 @@ func insertMultiplier(data []models.WeiPerWorkloadStruct) error {
currentTime
=
time
.
Date
(
currentTime
.
Year
(),
currentTime
.
Month
(),
currentTime
.
Day
(),
0
,
0
,
0
,
0
,
time
.
UTC
)
currentTime
=
time
.
Date
(
currentTime
.
Year
(),
currentTime
.
Month
(),
currentTime
.
Day
(),
0
,
0
,
0
,
0
,
time
.
UTC
)
for
_
,
value
:=
range
data
{
for
_
,
value
:=
range
data
{
temp
,
_
:=
time
.
Parse
(
"2006-01-02"
,
value
.
Date
)
temp
,
_
:=
time
.
Parse
(
"2006-01-02"
,
value
.
Date
)
logs
.
Debug
(
"insertMultiplier"
,
temp
,
currentTime
,
value
.
WeiPerWorkload
)
if
strings
.
Compare
(
value
.
WeiPerWorkload
,
"0"
)
==
0
&&
temp
.
Compare
(
currentTime
)
>=
0
{
if
strings
.
Compare
(
value
.
WeiPerWorkload
,
"0"
)
==
0
&&
temp
.
Compare
(
currentTime
)
>=
0
{
continue
continue
}
}
...
...
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