清理冗余的梯度返佣(TierCommission)配置
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m46s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m46s
- 移除 Model 层:删除 ShopSeriesCommissionTier 模型及相关字段 - 更新 DTO:删除 TierCommissionConfig、TierEntry 类型及相关请求/响应字段 - 删除 Store 层:移除 ShopSeriesCommissionTierStore 及相关查询逻辑 - 简化 Service 层:删除梯度返佣处理逻辑,统计查询移除 tier_bonus 字段 - 数据库迁移:创建 000034_remove_tier_commission 移除相关表和字段 - 更新测试:移除梯度返佣相关测试用例,更新集成测试 - OpenAPI 文档:删除梯度返佣相关 schema 和枚举值 - 归档变更:归档 remove-tier-commission-redundancy 到 archive/2026-01-30- - 同步规范:更新 4 个主 specs,标记废弃功能并添加迁移指引 原因:梯度返佣功能与一次性梯度佣金功能重复,且从未实现实际计算逻辑 迁移:使用一次性佣金的梯度模式 (OneTimeCommissionConfig.type = "tiered") 替代
This commit is contained in:
@@ -96,14 +96,12 @@ func (s *CommissionRecordStore) ListByShopID(ctx context.Context, opts *store.Qu
|
||||
}
|
||||
|
||||
type CommissionStats struct {
|
||||
TotalAmount int64
|
||||
CostDiffAmount int64
|
||||
OneTimeAmount int64
|
||||
TierBonusAmount int64
|
||||
TotalCount int64
|
||||
CostDiffCount int64
|
||||
OneTimeCount int64
|
||||
TierBonusCount int64
|
||||
TotalAmount int64
|
||||
CostDiffAmount int64
|
||||
OneTimeAmount int64
|
||||
TotalCount int64
|
||||
CostDiffCount int64
|
||||
OneTimeCount int64
|
||||
}
|
||||
|
||||
func (s *CommissionRecordStore) GetStats(ctx context.Context, filters *CommissionRecordListFilters) (*CommissionStats, error) {
|
||||
@@ -128,11 +126,9 @@ func (s *CommissionRecordStore) GetStats(ctx context.Context, filters *Commissio
|
||||
COALESCE(SUM(amount), 0) as total_amount,
|
||||
COALESCE(SUM(CASE WHEN commission_source = 'cost_diff' THEN amount ELSE 0 END), 0) as cost_diff_amount,
|
||||
COALESCE(SUM(CASE WHEN commission_source = 'one_time' THEN amount ELSE 0 END), 0) as one_time_amount,
|
||||
COALESCE(SUM(CASE WHEN commission_source = 'tier_bonus' THEN amount ELSE 0 END), 0) as tier_bonus_amount,
|
||||
COUNT(*) as total_count,
|
||||
COALESCE(SUM(CASE WHEN commission_source = 'cost_diff' THEN 1 ELSE 0 END), 0) as cost_diff_count,
|
||||
COALESCE(SUM(CASE WHEN commission_source = 'one_time' THEN 1 ELSE 0 END), 0) as one_time_count,
|
||||
COALESCE(SUM(CASE WHEN commission_source = 'tier_bonus' THEN 1 ELSE 0 END), 0) as tier_bonus_count
|
||||
COALESCE(SUM(CASE WHEN commission_source = 'one_time' THEN 1 ELSE 0 END), 0) as one_time_count
|
||||
`).Scan(&stats)
|
||||
|
||||
if result.Error != nil {
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ShopSeriesCommissionTierStore struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewShopSeriesCommissionTierStore(db *gorm.DB) *ShopSeriesCommissionTierStore {
|
||||
return &ShopSeriesCommissionTierStore{db: db}
|
||||
}
|
||||
|
||||
func (s *ShopSeriesCommissionTierStore) Create(ctx context.Context, tier *model.ShopSeriesCommissionTier) error {
|
||||
return s.db.WithContext(ctx).Create(tier).Error
|
||||
}
|
||||
|
||||
func (s *ShopSeriesCommissionTierStore) GetByID(ctx context.Context, id uint) (*model.ShopSeriesCommissionTier, error) {
|
||||
var tier model.ShopSeriesCommissionTier
|
||||
if err := s.db.WithContext(ctx).First(&tier, id).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &tier, nil
|
||||
}
|
||||
|
||||
func (s *ShopSeriesCommissionTierStore) Update(ctx context.Context, tier *model.ShopSeriesCommissionTier) error {
|
||||
return s.db.WithContext(ctx).Save(tier).Error
|
||||
}
|
||||
|
||||
func (s *ShopSeriesCommissionTierStore) Delete(ctx context.Context, id uint) error {
|
||||
return s.db.WithContext(ctx).Delete(&model.ShopSeriesCommissionTier{}, id).Error
|
||||
}
|
||||
|
||||
func (s *ShopSeriesCommissionTierStore) ListByAllocationID(ctx context.Context, allocationID uint) ([]*model.ShopSeriesCommissionTier, error) {
|
||||
var tiers []*model.ShopSeriesCommissionTier
|
||||
if err := s.db.WithContext(ctx).
|
||||
Where("allocation_id = ?", allocationID).
|
||||
Order("threshold_value ASC").
|
||||
Find(&tiers).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return tiers, nil
|
||||
}
|
||||
|
||||
func (s *ShopSeriesCommissionTierStore) DeleteByAllocationID(ctx context.Context, allocationID uint) error {
|
||||
return s.db.WithContext(ctx).
|
||||
Where("allocation_id = ?", allocationID).
|
||||
Delete(&model.ShopSeriesCommissionTier{}).Error
|
||||
}
|
||||
Reference in New Issue
Block a user