修复反馈
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m30s

This commit is contained in:
2026-08-10 16:30:38 +08:00
parent 7aa03e91fb
commit f15a64395f
25 changed files with 527 additions and 90 deletions

View File

@@ -741,6 +741,22 @@ func (s *Service) batchGetAllocationsForShop(ctx context.Context, shopID uint, p
}
func (s *Service) toResponseWithAllocation(_ context.Context, pkg *model.Package, allocationMap map[uint]*model.ShopPackageAllocation, seriesAllocationMap map[uint]*model.ShopSeriesAllocation, seriesConfigMap map[uint]*model.OneTimeCommissionConfig) *dto.PackageResponse {
var allocation *model.ShopPackageAllocation
if allocationMap != nil {
allocation = allocationMap[pkg.ID]
}
resp := BuildResponseForAllocation(pkg, allocation)
// 填充返佣信息(仅代理用户可见)
if pkg.SeriesID > 0 && seriesAllocationMap != nil && seriesConfigMap != nil {
s.fillCommissionInfo(resp, pkg.SeriesID, seriesAllocationMap, seriesConfigMap)
}
return resp
}
// BuildResponseForAllocation 构建套餐列表字段,并按店铺授权覆盖价格和上架状态。
func BuildResponseForAllocation(pkg *model.Package, allocation *model.ShopPackageAllocation) *dto.PackageResponse {
var seriesID *uint
if pkg.SeriesID > 0 {
seriesID = &pkg.SeriesID
@@ -778,29 +794,21 @@ func (s *Service) toResponseWithAllocation(_ context.Context, pkg *model.Package
}
initPackageExpiryBaseFields(resp, pkg)
if allocationMap != nil {
if allocation, ok := allocationMap[pkg.ID]; ok {
resp.CostPrice = allocation.CostPrice
resp.RetailPrice = packageprice.AllocationRawRetailPrice(allocation)
retailPriceConfigStatus := allocation.RetailPriceConfigStatus
resp.RetailPriceConfigStatus = &retailPriceConfigStatus
effectiveRetailPrice := packageprice.AllocationEffectiveRetailPrice(allocation)
resp.EffectiveRetailPrice = &effectiveRetailPrice
profitMargin := effectiveRetailPrice - allocation.CostPrice
resp.ProfitMargin = &profitMargin
applyAllocationExpiryBase(resp, pkg, allocation)
resp.ShelfStatus = allocation.ShelfStatus
}
if allocation != nil {
resp.CostPrice = allocation.CostPrice
resp.RetailPrice = packageprice.AllocationRawRetailPrice(allocation)
retailPriceConfigStatus := allocation.RetailPriceConfigStatus
resp.RetailPriceConfigStatus = &retailPriceConfigStatus
effectiveRetailPrice := packageprice.AllocationEffectiveRetailPrice(allocation)
resp.EffectiveRetailPrice = &effectiveRetailPrice
profitMargin := effectiveRetailPrice - allocation.CostPrice
resp.ProfitMargin = &profitMargin
applyAllocationExpiryBase(resp, pkg, allocation)
resp.ShelfStatus = allocation.ShelfStatus
} else {
effectiveRetailPrice := packageprice.PackageEffectiveRetailPrice(pkg)
resp.EffectiveRetailPrice = &effectiveRetailPrice
}
// 填充返佣信息(仅代理用户可见)
if pkg.SeriesID > 0 && seriesAllocationMap != nil && seriesConfigMap != nil {
s.fillCommissionInfo(resp, pkg.SeriesID, seriesAllocationMap, seriesConfigMap)
}
return resp
}