Files
admin a950fd2ead
Docker Build (Gitea) / Build and Push Docker Image (push) Successful in 47s
rebrand: BEpusdt → VUPAY
展示层与标识符全量改名:
- module github.com/v03413/bepusdt → git.viaeon.com/admin/vupay(含全部 import)
- 二进制/镜像/容器/DB 名 bepusdt → vupay(Dockerfile、workflow IMAGE、compose、docs)
- 显示名 BEpusdt → VUPAY(前端 title、后端 banner、version 命令、通知文案)
- 默认路径 /var/lib/bepusdt → /var/lib/vupay,/var/log/bepusdt → /var/log/vupay
- Telegram 通知的频道按钮原来指向上游 t.me 群,改成站点链接(否则改名后是死链)

刻意保留(运行语义,改了会坏):
- api_type 取值 "epusdt" / "epusdt_order"(库里存量数据按此匹配)
- 表前缀 bep_(bep_order / bep_conf / …,改需 RENAME TABLE 迁移)
- 签名函数 EpusdtSign 与 handler 包名 epusdt(对外协议语义,非品牌)
- 所有加密/会话派生的字面量原样不动

验证:gofmt 通过、go build ./... 通过、全仓 grep -i bepusdt 归零
2026-11-25 09:06:06 +08:00

48 lines
992 B
Go

package task
import (
"context"
"fmt"
"time"
"git.viaeon.com/admin/vupay/app/log"
"git.viaeon.com/admin/vupay/app/model"
"github.com/spf13/cast"
)
func init() {
var rate = Rate{}
Register(Task{Duration: time.Hour, Callback: rate.Clear})
Register(Task{Duration: time.Second * 5, Callback: rate.Sync})
}
type Rate struct {
}
func (Rate) Sync(ctx context.Context) {
var lastAt model.Rate
model.Db.Model(&lastAt).Order("id desc").Limit(1).Find(&lastAt)
var interval = cast.ToInt64(model.GetC(model.RateSyncInterval))
if lastAt.ID != 0 && time.Now().Unix()-lastAt.CreatedAt.Time().Unix() < interval {
return
}
err := model.CoingeckoRate()
if err != nil {
log.Warn(fmt.Sprintf("同步汇率失败: %s", err.Error()))
}
}
func (Rate) Clear(ctx context.Context) {
days := cast.ToInt(model.GetC(model.RateSyncHistoryDays))
if days <= 0 {
days = 1
}
createdAt := time.Now().AddDate(0, 0, -days)
model.Db.Where("created_at < ?", createdAt).Delete(&model.Rate{})
}