fix(tenant): 隔离经营租户与旧分销站点上下文
This commit is contained in:
@@ -99,18 +99,21 @@ func (h *Handler) SendSMS(c *gin.Context) {
|
||||
}
|
||||
|
||||
siteCode := sitecode.FromRequest(c)
|
||||
if siteCode == "" {
|
||||
siteCode = strings.TrimSpace(req.SiteCode)
|
||||
}
|
||||
domain := strings.TrimSpace(firstNonEmpty(
|
||||
c.GetHeader("X-Distribution-Domain"),
|
||||
c.Query("distribution_domain"),
|
||||
c.Query("domain"),
|
||||
))
|
||||
if siteCode == "" && domain == "" {
|
||||
host := sitecode.ExtractHost(c.Request.Host)
|
||||
if host != "" && !sitecode.IsLocalHost(host) {
|
||||
domain = host
|
||||
domain := ""
|
||||
if !sitecode.HasTenantScope(c.Request.Context()) {
|
||||
if siteCode == "" {
|
||||
siteCode = strings.TrimSpace(req.SiteCode)
|
||||
}
|
||||
domain = strings.TrimSpace(firstNonEmpty(
|
||||
c.GetHeader("X-Distribution-Domain"),
|
||||
c.Query("distribution_domain"),
|
||||
c.Query("domain"),
|
||||
))
|
||||
if siteCode == "" && domain == "" {
|
||||
host := sitecode.ExtractHost(c.Request.Host)
|
||||
if host != "" && !sitecode.IsLocalHost(host) {
|
||||
domain = host
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"hfb_sys/backend/internal/sitecode"
|
||||
"hfb_sys/backend/pkg/response"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -67,7 +68,9 @@ func (h *Handler) EnsureSupportConversation(c *gin.Context) {
|
||||
// scene 可选;空 body 仍按平台客服处理
|
||||
_ = c.ShouldBindJSON(&req)
|
||||
siteCode := parseSiteCode(c)
|
||||
if siteCode == "" && req.DistributionSiteCode != "" {
|
||||
if siteCode == "" &&
|
||||
req.DistributionSiteCode != "" &&
|
||||
!sitecode.HasTenantScope(c.Request.Context()) {
|
||||
siteCode = req.DistributionSiteCode
|
||||
}
|
||||
item, err := h.service.EnsureSupportConversation(c.Request.Context(), userID, req.Scene, siteCode)
|
||||
|
||||
@@ -387,6 +387,10 @@ func (h *Handler) ListPublicSiteListings(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *Handler) GetPublicSiteInfo(c *gin.Context) {
|
||||
if sitecode.HasTenantScope(c.Request.Context()) {
|
||||
response.NotFound(c, "经营租户站点不使用分销站点信息")
|
||||
return
|
||||
}
|
||||
code := sitecode.FromQueryThenHeader(c)
|
||||
domain := strings.TrimSpace(c.Query("domain"))
|
||||
if code == "" && domain == "" {
|
||||
|
||||
@@ -20,7 +20,7 @@ func (h *Handler) Create(c *gin.Context) {
|
||||
response.BadRequest(c, "订单信息不完整")
|
||||
return
|
||||
}
|
||||
if strings.TrimSpace(req.DistributionSiteCode) == "" {
|
||||
if sitecode.HasTenantScope(c.Request.Context()) || strings.TrimSpace(req.DistributionSiteCode) == "" {
|
||||
req.DistributionSiteCode = sitecode.FromRequest(c)
|
||||
}
|
||||
item, err := h.service.Create(c.Request.Context(), userID, req)
|
||||
|
||||
Reference in New Issue
Block a user