mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-08 03:00:26 +08:00
用户账单增加字段/优化代码
This commit is contained in:
@@ -2379,21 +2379,21 @@ func (this *ServerDAO) UpdateServerTrafficLimitStatus(tx *dbs.Tx, trafficLimitCo
|
|||||||
|
|
||||||
// daily
|
// daily
|
||||||
if trafficLimitConfig.DailyBytes() > 0 {
|
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")
|
untilDay = timeutil.Format("Ymd")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// monthly
|
// monthly
|
||||||
if server.TrafficMonth == timeutil.Format("Ym") && trafficLimitConfig.MonthlyBytes() > 0 {
|
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")
|
untilDay = timeutil.Format("Ym32")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// totally
|
// totally
|
||||||
if trafficLimitConfig.TotalBytes() > 0 {
|
if trafficLimitConfig.TotalBytes() > 0 {
|
||||||
if server.TotalTraffic >= float64(trafficLimitConfig.TotalBytes())/1024/1024/1024 {
|
if server.TotalTraffic >= float64(trafficLimitConfig.TotalBytes())/(1<<30) {
|
||||||
untilDay = "30000101"
|
untilDay = "30000101"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2423,7 +2423,7 @@ func (this *ServerDAO) UpdateServerTrafficLimitStatus(tx *dbs.Tx, trafficLimitCo
|
|||||||
|
|
||||||
// IncreaseServerTotalTraffic 增加服务的总流量
|
// IncreaseServerTotalTraffic 增加服务的总流量
|
||||||
func (this *ServerDAO) IncreaseServerTotalTraffic(tx *dbs.Tx, serverId int64, bytes int64) error {
|
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 day = timeutil.Format("Ymd")
|
||||||
var month = timeutil.Format("Ym")
|
var month = timeutil.Format("Ym")
|
||||||
return this.Query(tx).
|
return this.Query(tx).
|
||||||
|
|||||||
6
internal/db/models/user_bill_dao_test.go
Normal file
6
internal/db/models/user_bill_dao_test.go
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package models_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "github.com/go-sql-driver/mysql"
|
||||||
|
_ "github.com/iwind/TeaGo/bootstrap"
|
||||||
|
)
|
||||||
@@ -5,6 +5,7 @@ type UserBill struct {
|
|||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
Type string `field:"type"` // 消费类型
|
Type string `field:"type"` // 消费类型
|
||||||
|
PricePeriod string `field:"pricePeriod"` // 计费周期
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
Amount float64 `field:"amount"` // 消费数额
|
Amount float64 `field:"amount"` // 消费数额
|
||||||
DayFrom string `field:"dayFrom"` // YYYYMMDD
|
DayFrom string `field:"dayFrom"` // YYYYMMDD
|
||||||
@@ -15,7 +16,7 @@ type UserBill struct {
|
|||||||
PaidAt uint64 `field:"paidAt"` // 支付时间
|
PaidAt uint64 `field:"paidAt"` // 支付时间
|
||||||
Code string `field:"code"` // 账单编号
|
Code string `field:"code"` // 账单编号
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
PricePeriod string `field:"pricePeriod"` // 计费周期
|
CreatedDay string `field:"createdDay"` // 创建日期
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ type UserBillOperator struct {
|
|||||||
Id any // ID
|
Id any // ID
|
||||||
UserId any // 用户ID
|
UserId any // 用户ID
|
||||||
Type any // 消费类型
|
Type any // 消费类型
|
||||||
|
PricePeriod any // 计费周期
|
||||||
Description any // 描述
|
Description any // 描述
|
||||||
Amount any // 消费数额
|
Amount any // 消费数额
|
||||||
DayFrom any // YYYYMMDD
|
DayFrom any // YYYYMMDD
|
||||||
@@ -33,7 +35,7 @@ type UserBillOperator struct {
|
|||||||
PaidAt any // 支付时间
|
PaidAt any // 支付时间
|
||||||
Code any // 账单编号
|
Code any // 账单编号
|
||||||
CreatedAt any // 创建时间
|
CreatedAt any // 创建时间
|
||||||
PricePeriod any // 计费周期
|
CreatedDay any // 创建日期
|
||||||
State any // 状态
|
State any // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user