mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-08 03:00:26 +08:00
套餐增加请求数(日/月)限制
This commit is contained in:
@@ -20,6 +20,8 @@ const (
|
|||||||
PlanField_TotalServers dbs.FieldName = "totalServers" // 可以绑定的网站数量
|
PlanField_TotalServers dbs.FieldName = "totalServers" // 可以绑定的网站数量
|
||||||
PlanField_TotalServerNamesPerServer dbs.FieldName = "totalServerNamesPerServer" // 每个网站可以绑定的域名数量
|
PlanField_TotalServerNamesPerServer dbs.FieldName = "totalServerNamesPerServer" // 每个网站可以绑定的域名数量
|
||||||
PlanField_TotalServerNames dbs.FieldName = "totalServerNames" // 总域名数量
|
PlanField_TotalServerNames dbs.FieldName = "totalServerNames" // 总域名数量
|
||||||
|
PlanField_MonthlyRequests dbs.FieldName = "monthlyRequests" // 每月访问量额度
|
||||||
|
PlanField_DailyRequests dbs.FieldName = "dailyRequests" // 每日访问量额度
|
||||||
)
|
)
|
||||||
|
|
||||||
// Plan 用户套餐
|
// Plan 用户套餐
|
||||||
@@ -41,6 +43,8 @@ type Plan struct {
|
|||||||
TotalServers uint32 `field:"totalServers"` // 可以绑定的网站数量
|
TotalServers uint32 `field:"totalServers"` // 可以绑定的网站数量
|
||||||
TotalServerNamesPerServer uint32 `field:"totalServerNamesPerServer"` // 每个网站可以绑定的域名数量
|
TotalServerNamesPerServer uint32 `field:"totalServerNamesPerServer"` // 每个网站可以绑定的域名数量
|
||||||
TotalServerNames uint32 `field:"totalServerNames"` // 总域名数量
|
TotalServerNames uint32 `field:"totalServerNames"` // 总域名数量
|
||||||
|
MonthlyRequests uint64 `field:"monthlyRequests"` // 每月访问量额度
|
||||||
|
DailyRequests uint64 `field:"dailyRequests"` // 每日访问量额度
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlanOperator struct {
|
type PlanOperator struct {
|
||||||
@@ -61,6 +65,8 @@ type PlanOperator struct {
|
|||||||
TotalServers any // 可以绑定的网站数量
|
TotalServers any // 可以绑定的网站数量
|
||||||
TotalServerNamesPerServer any // 每个网站可以绑定的域名数量
|
TotalServerNamesPerServer any // 每个网站可以绑定的域名数量
|
||||||
TotalServerNames any // 总域名数量
|
TotalServerNames any // 总域名数量
|
||||||
|
MonthlyRequests any // 每月访问量额度
|
||||||
|
DailyRequests any // 每日访问量额度
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPlanOperator() *PlanOperator {
|
func NewPlanOperator() *PlanOperator {
|
||||||
|
|||||||
@@ -2420,8 +2420,9 @@ func (this *ServerDAO) RenewServerTrafficLimitStatus(tx *dbs.Tx, trafficLimitCon
|
|||||||
var isChanged = oldStatus.UntilDay != untilDay
|
var isChanged = oldStatus.UntilDay != untilDay
|
||||||
if isChanged {
|
if isChanged {
|
||||||
statusJSON, err := json.Marshal(&serverconfigs.TrafficLimitStatus{
|
statusJSON, err := json.Marshal(&serverconfigs.TrafficLimitStatus{
|
||||||
UntilDay: untilDay,
|
UntilDay: untilDay,
|
||||||
DateType: dateType,
|
DateType: dateType,
|
||||||
|
TargetType: serverconfigs.TrafficLimitTargetTraffic,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -2444,7 +2445,7 @@ func (this *ServerDAO) RenewServerTrafficLimitStatus(tx *dbs.Tx, trafficLimitCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateServerTrafficLimitStatus 修改网站的流量限制状态
|
// UpdateServerTrafficLimitStatus 修改网站的流量限制状态
|
||||||
func (this *ServerDAO) UpdateServerTrafficLimitStatus(tx *dbs.Tx, serverId int64, day string, planId int64, dateType string) error {
|
func (this *ServerDAO) UpdateServerTrafficLimitStatus(tx *dbs.Tx, serverId int64, day string, planId int64, dateType string, targetType string) error {
|
||||||
if !regexputils.YYYYMMDD.MatchString(day) {
|
if !regexputils.YYYYMMDD.MatchString(day) {
|
||||||
return errors.New("invalid 'day' format")
|
return errors.New("invalid 'day' format")
|
||||||
}
|
}
|
||||||
@@ -2475,9 +2476,10 @@ func (this *ServerDAO) UpdateServerTrafficLimitStatus(tx *dbs.Tx, serverId int64
|
|||||||
}
|
}
|
||||||
|
|
||||||
var status = &serverconfigs.TrafficLimitStatus{
|
var status = &serverconfigs.TrafficLimitStatus{
|
||||||
UntilDay: day,
|
UntilDay: day,
|
||||||
PlanId: planId,
|
PlanId: planId,
|
||||||
DateType: dateType,
|
DateType: dateType,
|
||||||
|
TargetType: targetType,
|
||||||
}
|
}
|
||||||
statusJSON, err = json.Marshal(status)
|
statusJSON, err = json.Marshal(status)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -2494,7 +2496,7 @@ func (this *ServerDAO) UpdateServerTrafficLimitStatus(tx *dbs.Tx, serverId int64
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateServersTrafficLimitStatusWithUserPlanId 修改某个套餐下的网站的流量限制状态
|
// UpdateServersTrafficLimitStatusWithUserPlanId 修改某个套餐下的网站的流量限制状态
|
||||||
func (this *ServerDAO) UpdateServersTrafficLimitStatusWithUserPlanId(tx *dbs.Tx, userPlanId int64, day string, planId int64, dateType string) error {
|
func (this *ServerDAO) UpdateServersTrafficLimitStatusWithUserPlanId(tx *dbs.Tx, userPlanId int64, day string, planId int64, dateType string, targetType serverconfigs.TrafficLimitTarget) error {
|
||||||
if userPlanId <= 0 {
|
if userPlanId <= 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -2509,7 +2511,7 @@ func (this *ServerDAO) UpdateServersTrafficLimitStatusWithUserPlanId(tx *dbs.Tx,
|
|||||||
}
|
}
|
||||||
for _, server := range servers {
|
for _, server := range servers {
|
||||||
var serverId = int64(server.(*Server).Id)
|
var serverId = int64(server.(*Server).Id)
|
||||||
err = this.UpdateServerTrafficLimitStatus(tx, serverId, day, planId, dateType)
|
err = this.UpdateServerTrafficLimitStatus(tx, serverId, day, planId, dateType, targetType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111387,7 +111387,7 @@
|
|||||||
"name": "edgePlans",
|
"name": "edgePlans",
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"charset": "utf8mb4_general_ci",
|
"charset": "utf8mb4_general_ci",
|
||||||
"definition": "CREATE TABLE `edgePlans` (\n `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n `name` varchar(255) DEFAULT NULL COMMENT '套餐名',\n `clusterId` int(11) unsigned DEFAULT '0' COMMENT '集群ID',\n `trafficLimit` json DEFAULT NULL COMMENT '流量限制',\n `features` json DEFAULT NULL COMMENT '允许的功能',\n `trafficPrice` json DEFAULT NULL COMMENT '流量价格设定',\n `bandwidthPrice` json DEFAULT NULL COMMENT '带宽价格',\n `monthlyPrice` decimal(12,2) unsigned DEFAULT '0.00' COMMENT '月付',\n `seasonallyPrice` decimal(12,2) unsigned DEFAULT '0.00' COMMENT '季付',\n `yearlyPrice` decimal(12,2) unsigned DEFAULT '0.00' COMMENT '年付',\n `priceType` varchar(32) DEFAULT NULL COMMENT '价格类型',\n `order` int(11) unsigned DEFAULT '0' COMMENT '排序',\n `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n `totalServers` int(11) unsigned DEFAULT '1' COMMENT '可以绑定的网站数量',\n `totalServerNamesPerServer` int(255) unsigned DEFAULT '0' COMMENT '每个网站可以绑定的域名数量',\n `totalServerNames` int(255) unsigned DEFAULT '0' COMMENT '总域名数量',\n PRIMARY KEY (`id`),\n KEY `state` (`state`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户套餐'",
|
"definition": "CREATE TABLE `edgePlans` (\n `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n `name` varchar(255) DEFAULT NULL COMMENT '套餐名',\n `clusterId` int(11) unsigned DEFAULT '0' COMMENT '集群ID',\n `trafficLimit` json DEFAULT NULL COMMENT '流量限制',\n `features` json DEFAULT NULL COMMENT '允许的功能',\n `trafficPrice` json DEFAULT NULL COMMENT '流量价格设定',\n `bandwidthPrice` json DEFAULT NULL COMMENT '带宽价格',\n `monthlyPrice` decimal(12,2) unsigned DEFAULT '0.00' COMMENT '月付',\n `seasonallyPrice` decimal(12,2) unsigned DEFAULT '0.00' COMMENT '季付',\n `yearlyPrice` decimal(12,2) unsigned DEFAULT '0.00' COMMENT '年付',\n `priceType` varchar(32) DEFAULT NULL COMMENT '价格类型',\n `order` int(11) unsigned DEFAULT '0' COMMENT '排序',\n `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n `totalServers` int(11) unsigned DEFAULT '1' COMMENT '可以绑定的网站数量',\n `totalServerNamesPerServer` int(255) unsigned DEFAULT '0' COMMENT '每个网站可以绑定的域名数量',\n `totalServerNames` int(255) unsigned DEFAULT '0' COMMENT '总域名数量',\n `monthlyRequests` bigint(20) unsigned DEFAULT '0' COMMENT '每月访问量额度',\n `dailyRequests` bigint(20) unsigned DEFAULT '0' COMMENT '每日访问量额度',\n PRIMARY KEY (`id`),\n KEY `state` (`state`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户套餐'",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "id",
|
||||||
@@ -111456,6 +111456,14 @@
|
|||||||
{
|
{
|
||||||
"name": "totalServerNames",
|
"name": "totalServerNames",
|
||||||
"definition": "int(255) unsigned DEFAULT '0' COMMENT '总域名数量'"
|
"definition": "int(255) unsigned DEFAULT '0' COMMENT '总域名数量'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "monthlyRequests",
|
||||||
|
"definition": "bigint(20) unsigned DEFAULT '0' COMMENT '每月访问量额度'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dailyRequests",
|
||||||
|
"definition": "bigint(20) unsigned DEFAULT '0' COMMENT '每日访问量额度'"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"indexes": [
|
"indexes": [
|
||||||
|
|||||||
Reference in New Issue
Block a user