增加功能报价
This commit is contained in:
@@ -99,6 +99,7 @@ type tenantPackagePayload struct {
|
||||
Code string `json:"code"`
|
||||
Description string `json:"description"`
|
||||
Price *float64 `json:"price"`
|
||||
DurationDays *int `json:"duration_days"`
|
||||
UserQuota *int `json:"user_quota"`
|
||||
ExtraUserPrice *float64 `json:"extra_user_price"`
|
||||
IsDefault *int8 `json:"is_default"`
|
||||
@@ -108,6 +109,14 @@ type tenantPackagePayload struct {
|
||||
Modules []string `json:"modules"`
|
||||
}
|
||||
|
||||
// normalizePackageDuration 套餐有效时长(天)规范化:<=0 时按 365(年付)
|
||||
func normalizePackageDuration(v *int) int {
|
||||
if v == nil || *v <= 0 {
|
||||
return services.DefaultPackageDurationDays
|
||||
}
|
||||
return *v
|
||||
}
|
||||
|
||||
// loadPackageModules 批量加载套餐模块(packageID -> 模块列表)
|
||||
func loadPackageModules(packageIDs []uint64) map[uint64][]tenantPackageModuleItem {
|
||||
result := map[uint64][]tenantPackageModuleItem{}
|
||||
@@ -180,6 +189,7 @@ func (c *PlatformTenantPackageController) GetPackageList() {
|
||||
"code": r.Code,
|
||||
"description": r.Description,
|
||||
"price": r.Price,
|
||||
"duration_days": r.DurationDays,
|
||||
"user_quota": r.UserQuota,
|
||||
"extra_user_price": r.ExtraUserPrice,
|
||||
"is_default": r.IsDefault,
|
||||
@@ -235,6 +245,7 @@ func (c *PlatformTenantPackageController) GetPackageSelectList() {
|
||||
"code": r.Code,
|
||||
"description": r.Description,
|
||||
"price": r.Price,
|
||||
"duration_days": r.DurationDays,
|
||||
"user_quota": r.UserQuota,
|
||||
"extra_user_price": r.ExtraUserPrice,
|
||||
"is_default": r.IsDefault,
|
||||
@@ -267,6 +278,27 @@ func (c *PlatformTenantPackageController) GetPackageDetail() {
|
||||
c.jsonOK(tenantPackageDTO{SystemTenantPackage: row, Modules: modules}, "获取成功")
|
||||
}
|
||||
|
||||
// GetPurchaseURL GET /platform/tenantPackage/purchaseUrl
|
||||
// 套餐购买链接:租户端未开通功能卡片「购买」按钮的跳转地址
|
||||
func (c *PlatformTenantPackageController) GetPurchaseURL() {
|
||||
c.jsonOK(map[string]interface{}{"purchase_url": services.GetPackagePurchaseURL()}, "获取成功")
|
||||
}
|
||||
|
||||
// SavePurchaseURL POST /platform/tenantPackage/purchaseUrl
|
||||
func (c *PlatformTenantPackageController) SavePurchaseURL() {
|
||||
var p struct {
|
||||
PurchaseURL string `json:"purchase_url"`
|
||||
}
|
||||
if !c.readBody(&p) {
|
||||
return
|
||||
}
|
||||
if err := services.SavePackagePurchaseURL(p.PurchaseURL); err != nil {
|
||||
c.jsonErr(500, 500, "保存失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
c.jsonOK(nil, "保存成功")
|
||||
}
|
||||
|
||||
// GetModuleOptions GET /platform/tenantPackage/moduleOptions
|
||||
// 可加入套餐的功能模块清单(取 yz_system_modules 中启用且未删除的模块)
|
||||
func (c *PlatformTenantPackageController) GetModuleOptions() {
|
||||
@@ -365,6 +397,7 @@ func (c *PlatformTenantPackageController) CreatePackage() {
|
||||
Code: p.Code,
|
||||
Description: strings.TrimSpace(p.Description),
|
||||
Price: valueFloat(p.Price, 0),
|
||||
DurationDays: normalizePackageDuration(p.DurationDays),
|
||||
UserQuota: valueInt(p.UserQuota, services.DefaultTenantUserQuota),
|
||||
ExtraUserPrice: valueFloat(p.ExtraUserPrice, services.DefaultTenantExtraUserPrice),
|
||||
IsDefault: valueInt8(p.IsDefault, 0),
|
||||
@@ -436,6 +469,9 @@ func (c *PlatformTenantPackageController) EditPackage() {
|
||||
if p.Price != nil {
|
||||
update["price"] = *p.Price
|
||||
}
|
||||
if p.DurationDays != nil {
|
||||
update["duration_days"] = normalizePackageDuration(p.DurationDays)
|
||||
}
|
||||
if p.UserQuota != nil {
|
||||
quota := *p.UserQuota
|
||||
if quota <= 0 {
|
||||
@@ -718,6 +754,9 @@ func (c *PlatformTenantPackageController) GetTenantQuotaInfo() {
|
||||
"used": info.Used,
|
||||
"remaining": info.Remaining,
|
||||
"extra_user_price": info.ExtraUserPrice,
|
||||
"duration_days": info.DurationDays,
|
||||
"package_expire_time": info.PackageExpireTime,
|
||||
"days_remaining": info.DaysRemaining,
|
||||
"quota_packages": quotaPackages,
|
||||
}, "获取成功")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user