You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
1.5 KiB

package console
import (
"github.com/gin-gonic/gin"
)
// 渠道商账号的数据收敛(P3 渠道分成体系)。
//
// 语义:渠道商账号(5) 锁死到自己那一个渠道商——由 acctScope.statsClause 直接出 channel_id = ?。
//
// ⚠️ 2026-09-12 品牌商(identity=3)整体下线:brand 表、品牌商管理页、品牌商账号角色一并删除,
// 原先「品牌商账号可见名下全部渠道商 ∪ 本品牌商产品」那层额外收敛随之取消。
// 渠道商现在是全局实体,不再有上级归属。
//
// 这些收敛在后端强制执行,前端传什么过滤条件都只能在这个范围内再缩小。
// statsScopeClause 组合出统计查询的账号作用域条件(应用/产品/区域/渠道商)。
// 返回的条件由调用方与前端下钻条件 AND,越权不可能穿透。
func (this *serverComp) statsScopeClause(c *gin.Context) (string, []interface{}) {
s := scopeOf(c)
// 账号绑定里存的是应用名与国内/海外,统计表按部署粒度存,收敛前同样要展开(口径与前端下钻一致)。
s.apps = this.expandAppNames(s.apps)
s.regions = expandRegionCodes(s.regions)
return s.statsClause()
}
// effectiveChannelId 把请求里的渠道商过滤收敛到账号绑定:渠道商账号一律强制成自己的 channelid,
// 其余角色按前端传值。
func effectiveChannelId(c *gin.Context, reqChannelId string) string {
s := scopeOf(c)
if s.unlimited || s.channelId == "" {
return reqChannelId
}
return s.channelId
}