Commit b1951f4c authored by brent's avatar brent

modify debit

parent 75f00400
...@@ -6,6 +6,7 @@ sessionon = true ...@@ -6,6 +6,7 @@ sessionon = true
sessiongcmaxlifetime = 127800 sessiongcmaxlifetime = 127800
logLevel = 7 logLevel = 7
logfile = "admin_backend.log" logfile = "admin_backend.log"
debitTime = "01 01 00 * * ?" ;01 01 00 * * ?
; SessionProvider = "redis" ; SessionProvider = "redis"
; SessionProviderConfig = "192.168.1.10:6379,1000" ; SessionProviderConfig = "192.168.1.10:6379,1000"
web3ClientId = "BHciicCbodMasHsyVfcdPYCaCokJMK5wGs2H4IRCaseqNJlcb1Li4kExaf5gF5DoUx-m_77epCrRPq4XmQzzdRk" web3ClientId = "BHciicCbodMasHsyVfcdPYCaCokJMK5wGs2H4IRCaseqNJlcb1Li4kExaf5gF5DoUx-m_77epCrRPq4XmQzzdRk"
......
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
beego "github.com/beego/beego/v2/server/web" beego "github.com/beego/beego/v2/server/web"
qdb "github.com/questdb/go-questdb-client/v2" qdb "github.com/questdb/go-questdb-client/v2"
"github.com/robfig/cron/v3" "github.com/robfig/cron/v3"
"sort"
"strconv" "strconv"
"time" "time"
) )
...@@ -92,6 +93,9 @@ func startHeatKey() { ...@@ -92,6 +93,9 @@ func startHeatKey() {
// } // }
// response = append(response, retask) // response = append(response, retask)
//} //}
sort.Slice(response, func(i, j int) bool {
return response[i].Count > response[j].Count
})
data, err := json.Marshal(response) data, err := json.Marshal(response)
if err == nil { if err == nil {
redis.SetKeyAndData(HeatKey, string(data), 0) redis.SetKeyAndData(HeatKey, string(data), 0)
...@@ -101,15 +105,17 @@ func startHeatKey() { ...@@ -101,15 +105,17 @@ func startHeatKey() {
} }
func startDebit() { func startDebit() {
logs.Debug("startDebit")
//spec := "*/50 */23 * * * ?" //"@every 1h" //spec := "*/50 */23 * * * ?" //"@every 1h"
spec := "00 00 00 * * ?" //spec := "01 01 00 * * ?"
spec, _ := beego.AppConfig.String("debitTime")
//spec := "@every 1m" //spec := "@every 1m"
dbhost, _ := beego.AppConfig.String("postgreshost") dbhost, _ := beego.AppConfig.String("postgreshost")
dbport, _ := beego.AppConfig.Int("senderport") dbport, _ := beego.AppConfig.Int("senderport")
questAddr := fmt.Sprintf("%s:%d", dbhost, dbport) questAddr := fmt.Sprintf("%s:%d", dbhost, dbport)
debitTask.AddFunc(spec, func() { debitTask.AddFunc(spec, func() {
logs.Debug("startDebit") logs.Debug("startDebit debitTask")
ctx := context.TODO() ctx := context.TODO()
addrOpt := qdb.WithAddress(questAddr) addrOpt := qdb.WithAddress(questAddr)
sender, err := qdb.NewLineSender(ctx, addrOpt) sender, err := qdb.NewLineSender(ctx, addrOpt)
...@@ -129,6 +135,8 @@ func startDebit() { ...@@ -129,6 +135,8 @@ func startDebit() {
start := fmt.Sprintf(startTime.Format(format)) start := fmt.Sprintf(startTime.Format(format))
end := fmt.Sprintf(endTime.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) 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) data, err := postgres.CountFunds(sql)
if err != nil { if err != nil {
......
...@@ -31,6 +31,7 @@ func createClient(redisHost string, password string, dataBase int) *redis.Client ...@@ -31,6 +31,7 @@ func createClient(redisHost string, password string, dataBase int) *redis.Client
_, err := client.Ping().Result() _, err := client.Ping().Result()
if err != nil { if err != nil {
logs.Error("连接失败,", err) logs.Error("连接失败,", err)
panic(err.Error())
} }
return client return client
......
...@@ -45,7 +45,7 @@ func (m PayMethodType) EnString() string { ...@@ -45,7 +45,7 @@ func (m PayMethodType) EnString() string {
case ApplePay: case ApplePay:
return "ApplePay" return "ApplePay"
case ManualPay: case ManualPay:
return "Manual" return "Manual Recharge"
default: default:
return "_" return "_"
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment