fix(admin): 主站分销管理按最新分成与释放口径改展示
规则页按模式展示收号/卖出/服务费,通道费标明主站承担;订单改为释放状态筛选;结算区分自动与人工批次。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -331,9 +331,16 @@ func (r *Repository) UpdateSite(ctx context.Context, adminID, id uint64, req Upd
|
||||
}
|
||||
|
||||
func (r *Repository) ListRules(ctx context.Context, adminID uint64, siteID *uint64, mode string) ([]RuleDTO, error) {
|
||||
db := r.db.WithContext(ctx).Model(&model.DistributionRuleVersion{}).Order("effective_from DESC, id DESC")
|
||||
db := r.db.WithContext(ctx).Model(&model.DistributionRuleVersion{}).
|
||||
Order("CASE WHEN site_id IS NULL THEN 0 ELSE 1 END ASC, site_id ASC, mode ASC, version DESC, id DESC")
|
||||
if siteID == nil {
|
||||
db = db.Where("site_id IS NULL")
|
||||
global, err := r.hasGlobalDistributionAccess(ctx, adminID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !global {
|
||||
db = db.Where("site_id IS NULL")
|
||||
}
|
||||
} else {
|
||||
if err := r.ensureSiteAccess(ctx, adminID, *siteID); err != nil {
|
||||
return nil, err
|
||||
@@ -475,6 +482,12 @@ func (r *Repository) ListOrders(ctx context.Context, query DistributionOrderList
|
||||
if query.Status != "" {
|
||||
base = base.Where("ro.status = ?", query.Status)
|
||||
}
|
||||
if mode := strings.TrimSpace(query.Mode); mode != "" {
|
||||
base = base.Where("ro.distribution_mode = ?", mode)
|
||||
}
|
||||
if financialStatus := strings.TrimSpace(query.FinancialStatus); financialStatus != "" {
|
||||
base = base.Where("f.settlement_status = ?", financialStatus)
|
||||
}
|
||||
if strings.TrimSpace(query.Keyword) != "" {
|
||||
kw := "%" + strings.TrimSpace(query.Keyword) + "%"
|
||||
base = base.Where("(ro.order_no LIKE ? OR rl.listing_no LIKE ? OR ga.title LIKE ? OR u.phone LIKE ?)", kw, kw, kw, kw)
|
||||
|
||||
Reference in New Issue
Block a user