用户账单增加字段/优化代码

This commit is contained in:
刘祥超
2022-10-21 15:45:22 +08:00
parent 9aa71365b9
commit 548f56f8f0
3 changed files with 14 additions and 6 deletions

View File

@@ -2379,21 +2379,21 @@ func (this *ServerDAO) UpdateServerTrafficLimitStatus(tx *dbs.Tx, trafficLimitCo
// daily
if trafficLimitConfig.DailyBytes() > 0 {
if server.TrafficDay == timeutil.Format("Ymd") && server.TotalDailyTraffic >= float64(trafficLimitConfig.DailyBytes())/1024/1024/1024 {
if server.TrafficDay == timeutil.Format("Ymd") && server.TotalDailyTraffic >= float64(trafficLimitConfig.DailyBytes())/(1<<30) {
untilDay = timeutil.Format("Ymd")
}
}
// monthly
if server.TrafficMonth == timeutil.Format("Ym") && trafficLimitConfig.MonthlyBytes() > 0 {
if server.TotalMonthlyTraffic >= float64(trafficLimitConfig.MonthlyBytes())/1024/1024/1024 {
if server.TotalMonthlyTraffic >= float64(trafficLimitConfig.MonthlyBytes())/(1<<30) {
untilDay = timeutil.Format("Ym32")
}
}
// totally
if trafficLimitConfig.TotalBytes() > 0 {
if server.TotalTraffic >= float64(trafficLimitConfig.TotalBytes())/1024/1024/1024 {
if server.TotalTraffic >= float64(trafficLimitConfig.TotalBytes())/(1<<30) {
untilDay = "30000101"
}
}
@@ -2423,7 +2423,7 @@ func (this *ServerDAO) UpdateServerTrafficLimitStatus(tx *dbs.Tx, trafficLimitCo
// IncreaseServerTotalTraffic 增加服务的总流量
func (this *ServerDAO) IncreaseServerTotalTraffic(tx *dbs.Tx, serverId int64, bytes int64) error {
var gb = float64(bytes) / 1024 / 1024 / 1024
var gb = float64(bytes) / (1 << 30)
var day = timeutil.Format("Ymd")
var month = timeutil.Format("Ym")
return this.Query(tx).

View File

@@ -0,0 +1,6 @@
package models_test
import (
_ "github.com/go-sql-driver/mysql"
_ "github.com/iwind/TeaGo/bootstrap"
)

View File

@@ -5,6 +5,7 @@ type UserBill struct {
Id uint64 `field:"id"` // ID
UserId uint32 `field:"userId"` // 用户ID
Type string `field:"type"` // 消费类型
PricePeriod string `field:"pricePeriod"` // 计费周期
Description string `field:"description"` // 描述
Amount float64 `field:"amount"` // 消费数额
DayFrom string `field:"dayFrom"` // YYYYMMDD
@@ -15,7 +16,7 @@ type UserBill struct {
PaidAt uint64 `field:"paidAt"` // 支付时间
Code string `field:"code"` // 账单编号
CreatedAt uint64 `field:"createdAt"` // 创建时间
PricePeriod string `field:"pricePeriod"` // 计费周
CreatedDay string `field:"createdDay"` // 创建日
State uint8 `field:"state"` // 状态
}
@@ -23,6 +24,7 @@ type UserBillOperator struct {
Id any // ID
UserId any // 用户ID
Type any // 消费类型
PricePeriod any // 计费周期
Description any // 描述
Amount any // 消费数额
DayFrom any // YYYYMMDD
@@ -33,7 +35,7 @@ type UserBillOperator struct {
PaidAt any // 支付时间
Code any // 账单编号
CreatedAt any // 创建时间
PricePeriod any // 计费周
CreatedDay any // 创建日
State any // 状态
}