2021-11-09 15:36:31 +08:00
|
|
|
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
package serverconfigs
|
|
|
|
|
|
|
|
|
|
|
|
import timeutil "github.com/iwind/TeaGo/utils/time"
|
|
|
|
|
|
|
|
|
|
|
|
// DefaultPlanExpireNoticePageBody 套餐过期时提示
|
|
|
|
|
|
const DefaultPlanExpireNoticePageBody = `<!DOCTYPE html>
|
|
|
|
|
|
<html>
|
|
|
|
|
|
<head>
|
|
|
|
|
|
<title>套餐已过期</title>
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
2021-12-02 14:44:56 +08:00
|
|
|
|
<h1>套餐已过期,请及时续费。</h1>
|
2021-11-09 15:36:31 +08:00
|
|
|
|
<p>Your server plan has been expired, please renew the plan.</p>
|
2021-12-02 14:44:56 +08:00
|
|
|
|
<address>Request ID: ${requestId}.</address>
|
2021-11-09 15:36:31 +08:00
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
</html>`
|
|
|
|
|
|
|
|
|
|
|
|
// UserPlanConfig 用户套餐配置
|
|
|
|
|
|
type UserPlanConfig struct {
|
|
|
|
|
|
DayTo string `yaml:"dayTo" json:"dayTo"` // 有效期
|
2021-11-11 08:31:32 +08:00
|
|
|
|
|
|
|
|
|
|
Plan *PlanConfig `yaml:"plan" json:"plan"`
|
2021-11-09 15:36:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Init 初始化
|
|
|
|
|
|
func (this *UserPlanConfig) Init() error {
|
2021-11-11 08:31:32 +08:00
|
|
|
|
if this.Plan != nil {
|
|
|
|
|
|
err := this.Plan.Init()
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
return err
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-11-09 15:36:31 +08:00
|
|
|
|
return nil
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// IsAvailable 是否有效
|
|
|
|
|
|
func (this *UserPlanConfig) IsAvailable() bool {
|
|
|
|
|
|
return this.DayTo >= timeutil.Format("Y-m-d")
|
|
|
|
|
|
}
|