不允许购买第二个主套餐
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m50s

This commit is contained in:
Break
2026-06-10 15:24:26 +08:00
parent 32c9859b38
commit 5c779cb6e0
7 changed files with 314 additions and 108 deletions

View File

@@ -63,15 +63,16 @@ func NewClientAssetHandler(
}
type resolvedAssetContext struct {
CustomerID uint
Identifier string
Asset *dto.AssetResolveResponse
Generation int
WalletBalance int64
SkipPermissionCtx context.Context
IsAgentChannel bool
SellerShopID uint
HasAddonMainPackage bool
CustomerID uint
Identifier string
Asset *dto.AssetResolveResponse
Generation int
WalletBalance int64
SkipPermissionCtx context.Context
IsAgentChannel bool
SellerShopID uint
HasAddonMainPackage bool
HasFormalMainPackage bool
}
// resolveAssetFromIdentifier 统一执行资产解析与归属校验
@@ -242,6 +243,16 @@ func (h *ClientAssetHandler) GetAvailablePackages(c *fiber.Ctx) error {
} else if err != gorm.ErrRecordNotFound {
return errors.Wrap(errors.CodeDatabaseError, err, "查询主套餐失败")
}
if hasBlockingMain, err := packagepkg.HasBlockingMainPackageForFormal(
h.db.WithContext(resolved.SkipPermissionCtx),
resolved.Asset.AssetType,
resolved.Asset.AssetID,
time.Now(),
); err != nil {
return errors.Wrap(errors.CodeDatabaseError, err, "查询主套餐失败")
} else {
resolved.HasFormalMainPackage = hasBlockingMain
}
listCtx := resolved.SkipPermissionCtx
if resolved.IsAgentChannel {
@@ -530,6 +541,9 @@ func buildClientPackageItem(
}
isAddon := pkg.PackageType == constants.PackageTypeAddon
if pkg.PackageType == constants.PackageTypeFormal && resolved.HasFormalMainPackage {
return dto.ClientPackageItem{}, false
}
if isAddon && !resolved.HasAddonMainPackage {
return dto.ClientPackageItem{}, false
}