Commit b1951f4c authored by brent's avatar brent

modify debit

parent 75f00400
......@@ -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"
......
......@@ -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 {
......
......@@ -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
......
......@@ -45,7 +45,7 @@ func (m PayMethodType) EnString() string {
case ApplePay:
return "ApplePay"
case ManualPay:
return "Manual"
return "Manual Recharge"
default:
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