feat(distribution): 分销站点消息中心与钱包提现多租户独立分支隔离
- 新增 000070 数据库迁移:支持 chat_conversations、wallet_accounts、wallet_ledger、withdrawal_requests 按 distribution_site_id 隔离 - 消息中心:会话列表、未读数统计、站点专属客服及订单群聊与主站实现双向完全隔离 - 资金账户与提现:独立按 (user_id, distribution_site_id) 建账,分销订单自动结算至对应分站钱包,提现与流水相互独立 - 前台界面:Axios 自动透传 X-Distribution-Site-Code,钱包、提现与消息页面呈现分站专属标牌与独立说明
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package withdrawal
|
||||
|
||||
import (
|
||||
"hfb_sys/backend/pkg/response"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"hfb_sys/backend/pkg/response"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -15,6 +17,20 @@ func NewHandler(service *Service) *Handler {
|
||||
return &Handler{service: service}
|
||||
}
|
||||
|
||||
func parseSiteCode(c *gin.Context) string {
|
||||
for _, val := range []string{
|
||||
c.Query("distribution_site_code"),
|
||||
c.Query("site_code"),
|
||||
c.GetHeader("X-Distribution-Site-Code"),
|
||||
c.GetHeader("X-Site-Code"),
|
||||
} {
|
||||
if trimmed := strings.TrimSpace(val); trimmed != "" {
|
||||
return trimmed
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// ========== 用户端接口 ==========
|
||||
|
||||
func (h *Handler) Create(c *gin.Context) {
|
||||
@@ -30,7 +46,8 @@ func (h *Handler) Create(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
withdrawal, err := h.service.Create(c.Request.Context(), userID, req)
|
||||
siteCode := parseSiteCode(c)
|
||||
withdrawal, err := h.service.Create(c.Request.Context(), userID, req, siteCode)
|
||||
if err != nil {
|
||||
writeError(c, err)
|
||||
return
|
||||
@@ -49,7 +66,8 @@ func (h *Handler) List(c *gin.Context) {
|
||||
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
|
||||
pageSize, _ := strconv.Atoi(c.DefaultQuery("page_size", "20"))
|
||||
|
||||
result, err := h.service.List(c.Request.Context(), userID, page, pageSize)
|
||||
siteCode := parseSiteCode(c)
|
||||
result, err := h.service.List(c.Request.Context(), userID, page, pageSize, siteCode)
|
||||
if err != nil {
|
||||
writeError(c, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user