修复缓存
Build docker and publish / build (20.15.1) (push) Successful in 7m26s

This commit is contained in:
2026-03-06 21:58:29 -08:00
parent 19932bb9f7
commit 4d913c1728
175 changed files with 437 additions and 12104 deletions
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"math"
"time"
commonLogic "github.com/perfect-panel/server/internal/logic/common"
"github.com/perfect-panel/server/internal/model/order"
@@ -108,6 +109,23 @@ func (l *PreCreateOrderLogic) PreCreateOrder(req *types.PurchaseOrderRequest) (r
}
}
// check new user only restriction
if !isSingleModeRenewal && sub.NewUserOnly != nil && *sub.NewUserOnly {
if time.Since(u.CreatedAt) > 24*time.Hour {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SubscribeNewUserOnly), "not a new user")
}
var historyCount int64
if e := l.svcCtx.DB.Model(&order.Order{}).
Where("user_id = ? AND subscribe_id = ? AND type = 1 AND status IN ?",
u.Id, targetSubscribeID, []uint8{2, 5}).
Count(&historyCount).Error; e != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "check new user purchase history error: %v", e.Error())
}
if historyCount >= 1 {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SubscribeNewUserOnly), "already purchased new user plan")
}
}
var discount float64 = 1
if sub.Discount != "" {
var dis []types.SubscribeDiscount