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
b1951f4c
Commit
b1951f4c
authored
Mar 13, 2024
by
brent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify debit
parent
75f00400
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
3 deletions
+13
-3
app.conf
conf/app.conf
+1
-0
cronjob.go
libs/cronjob/cronjob.go
+10
-2
redis.go
libs/redis/redis.go
+1
-0
funds.go
models/funds.go
+1
-1
No files found.
conf/app.conf
View file @
b1951f4c
...
...
@@ -6,6 +6,7 @@ sessionon = true
sessiongcmaxlifetime
=
127800
logLevel
=
7
logfile
=
"admin_backend.log"
debitTime
=
"01 01 00 * * ?"
;
01
01
00
* * ?
;
SessionProvider
=
"redis"
;
SessionProviderConfig
=
"192.168.1.10:6379,1000"
web3ClientId
=
"BHciicCbodMasHsyVfcdPYCaCokJMK5wGs2H4IRCaseqNJlcb1Li4kExaf5gF5DoUx-m_77epCrRPq4XmQzzdRk"
...
...
libs/cronjob/cronjob.go
View file @
b1951f4c
...
...
@@ -13,6 +13,7 @@ import (
beego
"github.com/beego/beego/v2/server/web"
qdb
"github.com/questdb/go-questdb-client/v2"
"github.com/robfig/cron/v3"
"sort"
"strconv"
"time"
)
...
...
@@ -92,6 +93,9 @@ func startHeatKey() {
// }
// response = append(response, retask)
//}
sort
.
Slice
(
response
,
func
(
i
,
j
int
)
bool
{
return
response
[
i
]
.
Count
>
response
[
j
]
.
Count
})
data
,
err
:=
json
.
Marshal
(
response
)
if
err
==
nil
{
redis
.
SetKeyAndData
(
HeatKey
,
string
(
data
),
0
)
...
...
@@ -101,15 +105,17 @@ func startHeatKey() {
}
func
startDebit
()
{
logs
.
Debug
(
"startDebit"
)
//spec := "*/50 */23 * * * ?" //"@every 1h"
spec
:=
"00 00 00 * * ?"
//spec := "01 01 00 * * ?"
spec
,
_
:=
beego
.
AppConfig
.
String
(
"debitTime"
)
//spec := "@every 1m"
dbhost
,
_
:=
beego
.
AppConfig
.
String
(
"postgreshost"
)
dbport
,
_
:=
beego
.
AppConfig
.
Int
(
"senderport"
)
questAddr
:=
fmt
.
Sprintf
(
"%s:%d"
,
dbhost
,
dbport
)
debitTask
.
AddFunc
(
spec
,
func
()
{
logs
.
Debug
(
"startDebit"
)
logs
.
Debug
(
"startDebit
debitTask
"
)
ctx
:=
context
.
TODO
()
addrOpt
:=
qdb
.
WithAddress
(
questAddr
)
sender
,
err
:=
qdb
.
NewLineSender
(
ctx
,
addrOpt
)
...
...
@@ -129,6 +135,8 @@ func startDebit() {
start
:=
fmt
.
Sprintf
(
startTime
.
Format
(
format
))
end
:=
fmt
.
Sprintf
(
endTime
.
Format
(
format
))
logs
.
Debug
(
"startDebit before sql = %s"
,
dayTime
)
sql
:=
fmt
.
Sprintf
(
"SELECT time, uid,sum(fee) AS amount FROM bills WHERE time >= '%s' and time <= '%s' SAMPLE BY 1d ALIGN TO CALENDAR GROUP BY uid,time;"
,
start
,
end
)
data
,
err
:=
postgres
.
CountFunds
(
sql
)
if
err
!=
nil
{
...
...
libs/redis/redis.go
View file @
b1951f4c
...
...
@@ -31,6 +31,7 @@ func createClient(redisHost string, password string, dataBase int) *redis.Client
_
,
err
:=
client
.
Ping
()
.
Result
()
if
err
!=
nil
{
logs
.
Error
(
"连接失败,"
,
err
)
panic
(
err
.
Error
())
}
return
client
...
...
models/funds.go
View file @
b1951f4c
...
...
@@ -45,7 +45,7 @@ func (m PayMethodType) EnString() string {
case
ApplePay
:
return
"ApplePay"
case
ManualPay
:
return
"Manual"
return
"Manual
Recharge
"
default
:
return
"_"
}
...
...
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