feat(distribution): 独立分销前台商城多租户体系、货源与订单数据严格隔离

This commit is contained in:
yml2213
2026-09-07 17:18:14 +08:00
parent 550b42eb22
commit ecaf15417b
34 changed files with 2397 additions and 119 deletions
@@ -186,10 +186,7 @@ func (h *Handler) CreateFinancialSnapshot(c *gin.Context) {
func (h *Handler) ListAccountDisplays(c *gin.Context) {
siteID := parseQueryUint(c, "site_id")
if siteID <= 0 {
if siteID == 0 {
response.BadRequest(c, "site_id 不正确")
}
if siteID < 0 {
return
}
adminID, _ := currentAdminID(c)
@@ -198,6 +195,10 @@ func (h *Handler) ListAccountDisplays(c *gin.Context) {
writeError(c, err)
return
}
if scoped == 0 && siteID == 0 {
response.BadRequest(c, "site_id 不正确")
return
}
items, err := h.service.ListAccountDisplays(c.Request.Context(), scoped, c.Query("status"))
if err != nil {
writeError(c, err)
@@ -225,6 +226,75 @@ func (h *Handler) UpdateAccountDisplay(c *gin.Context) {
response.OK(c, item)
}
func (h *Handler) SyncSiteAccounts(c *gin.Context) {
var siteID uint64
id, ok := parseID(c)
if ok && id > 0 {
siteID = id
} else {
qID := parseQueryUint(c, "site_id")
if qID > 0 {
siteID = uint64(qID)
}
}
adminID, _ := currentAdminID(c)
scoped, err := h.service.ScopeSiteID(c.Request.Context(), adminID, siteID)
if err != nil {
writeError(c, err)
return
}
if scoped == 0 {
response.BadRequest(c, "site_id 不正确")
return
}
result, err := h.service.SyncSiteAccounts(c.Request.Context(), adminID, scoped)
if err != nil {
writeError(c, err)
return
}
response.OK(c, result)
}
func (h *Handler) ListPublicSiteListings(c *gin.Context) {
siteCode := strings.TrimSpace(c.Param("site_code"))
if siteCode == "" {
siteCode = strings.TrimSpace(c.Query("site_code"))
}
if siteCode == "" {
response.BadRequest(c, "site_code 不能为空")
return
}
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
pageSize, _ := strconv.Atoi(c.DefaultQuery("page_size", "20"))
result, err := h.service.ListPublicSiteListings(c.Request.Context(), siteCode, page, pageSize)
if err != nil {
writeError(c, err)
return
}
response.OK(c, result)
}
func (h *Handler) GetPublicSiteInfo(c *gin.Context) {
code := strings.TrimSpace(c.Query("code"))
if code == "" {
code = strings.TrimSpace(c.Query("site_code"))
}
domain := strings.TrimSpace(c.Query("domain"))
if code == "" && domain == "" {
host := c.Request.Host
if colon := strings.Index(host, ":"); colon != -1 {
host = host[:colon]
}
domain = host
}
info, err := h.service.GetPublicSiteInfo(c.Request.Context(), code, domain)
if err != nil {
writeError(c, err)
return
}
response.OK(c, info)
}
func (h *Handler) ListPaymentChannels(c *gin.Context) {
siteID := parseQueryUint(c, "site_id")
if siteID <= 0 {