feat: 资产套餐接口返回是否开启虚流量字段
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m26s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m26s
current-package 和 packages 两个接口的响应中新增 enable_virtual_data 字段,表示该套餐是否启用虚流量 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -101,6 +101,7 @@ type AssetPackageResponse struct {
|
||||
VirtualUsedMB float64 `json:"virtual_used_mb" description:"已用虚流量(MB),按virtual_ratio换算"`
|
||||
VirtualRemainMB float64 `json:"virtual_remain_mb" description:"剩余虚流量(MB),按virtual_ratio换算"`
|
||||
VirtualRatio float64 `json:"virtual_ratio" description:"虚流量比例(real/virtual)"`
|
||||
EnableVirtualData bool `json:"enable_virtual_data" description:"是否启用虚流量"`
|
||||
ActivatedAt *time.Time `json:"activated_at,omitempty" description:"激活时间(待生效套餐为空)"`
|
||||
ExpiresAt *time.Time `json:"expires_at,omitempty" description:"到期时间(待生效套餐为空)"`
|
||||
MasterUsageID *uint `json:"master_usage_id,omitempty" description:"主套餐ID(加油包时有值)"`
|
||||
|
||||
@@ -654,10 +654,12 @@ func (s *Service) GetPackages(ctx context.Context, assetType string, id uint, pa
|
||||
ratio := 1.0
|
||||
pkgName := ""
|
||||
pkgType := ""
|
||||
enableVirtualData := false
|
||||
if pkg != nil {
|
||||
ratio = safeVirtualRatio(pkg.VirtualRatio)
|
||||
pkgName = pkg.PackageName
|
||||
pkgType = pkg.PackageType
|
||||
enableVirtualData = pkg.EnableVirtualData
|
||||
}
|
||||
|
||||
item := &dto.AssetPackageResponse{
|
||||
@@ -674,6 +676,7 @@ func (s *Service) GetPackages(ctx context.Context, assetType string, id uint, pa
|
||||
VirtualUsedMB: float64(u.DataUsageMB) / ratio,
|
||||
VirtualRemainMB: float64(u.DataLimitMB-u.DataUsageMB) / ratio,
|
||||
VirtualRatio: ratio,
|
||||
EnableVirtualData: enableVirtualData,
|
||||
ActivatedAt: nonZeroTimePtr(u.ActivatedAt),
|
||||
ExpiresAt: nonZeroTimePtr(u.ExpiresAt),
|
||||
MasterUsageID: u.MasterUsageID,
|
||||
@@ -728,10 +731,12 @@ func (s *Service) GetCurrentPackage(ctx context.Context, assetType string, id ui
|
||||
ratio := 1.0
|
||||
pkgName := ""
|
||||
pkgType := ""
|
||||
enableVirtualData := false
|
||||
if pkgErr == nil && pkg != nil {
|
||||
ratio = safeVirtualRatio(pkg.VirtualRatio)
|
||||
pkgName = pkg.PackageName
|
||||
pkgType = pkg.PackageType
|
||||
enableVirtualData = pkg.EnableVirtualData
|
||||
}
|
||||
|
||||
return &dto.AssetPackageResponse{
|
||||
@@ -748,6 +753,7 @@ func (s *Service) GetCurrentPackage(ctx context.Context, assetType string, id ui
|
||||
VirtualUsedMB: float64(usage.DataUsageMB) / ratio,
|
||||
VirtualRemainMB: float64(usage.DataLimitMB-usage.DataUsageMB) / ratio,
|
||||
VirtualRatio: ratio,
|
||||
EnableVirtualData: enableVirtualData,
|
||||
ActivatedAt: nonZeroTimePtr(usage.ActivatedAt),
|
||||
ExpiresAt: nonZeroTimePtr(usage.ExpiresAt),
|
||||
MasterUsageID: usage.MasterUsageID,
|
||||
|
||||
Reference in New Issue
Block a user