补全分销分账结算闭环并修复站点越权
- 权限落库:新增 000066 迁移,注册 11 个 distribution:* 权限并授权 super_admin/ops/finance - 越权修复:siteAccessAllowed 校验贯穿站点/规则/订单/展示/支付通道/结算全部按 ID 操作 - 分账闭环:SplitSettlement 按比例拆分分成基数,销售加价归卖出方,尾差记入 rounding_adjustment_cent 归平台;支付快照与退款重算均按拆分写入参与方金额 - 结算批次:创建时聚合周期内待结算订单生成明细并汇总金额,结算时校验明细与总额一致后联动置位财务快照 - 手工补数接口禁止覆盖已有快照并写入审计日志 - 杂项:二维码池校验站点启用状态且不吞真实 DB 错误;绑定支付通道校验商户配置存在;表探测改为 sync.Once 缓存
This commit is contained in:
@@ -61,11 +61,11 @@ func (s *Service) ScopeSiteID(ctx context.Context, adminID, requested uint64) (u
|
||||
}
|
||||
return s.repo.ScopeSiteID(ctx, adminID, requested)
|
||||
}
|
||||
func (s *Service) FindSite(ctx context.Context, id uint64) (*SiteDTO, error) {
|
||||
func (s *Service) FindSite(ctx context.Context, adminID, id uint64) (*SiteDTO, error) {
|
||||
if err := s.available(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.repo.FindSite(ctx, id)
|
||||
return s.repo.FindSite(ctx, adminID, id)
|
||||
}
|
||||
func (s *Service) CreateSite(ctx context.Context, req CreateSiteRequest) (*SiteDTO, error) {
|
||||
if err := s.available(); err != nil {
|
||||
@@ -73,17 +73,17 @@ func (s *Service) CreateSite(ctx context.Context, req CreateSiteRequest) (*SiteD
|
||||
}
|
||||
return s.repo.CreateSite(ctx, req)
|
||||
}
|
||||
func (s *Service) UpdateSite(ctx context.Context, id uint64, req UpdateSiteRequest) (*SiteDTO, error) {
|
||||
func (s *Service) UpdateSite(ctx context.Context, adminID, id uint64, req UpdateSiteRequest) (*SiteDTO, error) {
|
||||
if err := s.available(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.repo.UpdateSite(ctx, id, req)
|
||||
return s.repo.UpdateSite(ctx, adminID, id, req)
|
||||
}
|
||||
func (s *Service) ListRules(ctx context.Context, siteID *uint64, mode string) ([]RuleDTO, error) {
|
||||
func (s *Service) ListRules(ctx context.Context, adminID uint64, siteID *uint64, mode string) ([]RuleDTO, error) {
|
||||
if err := s.available(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.repo.ListRules(ctx, siteID, mode)
|
||||
return s.repo.ListRules(ctx, adminID, siteID, mode)
|
||||
}
|
||||
func (s *Service) CreateRule(ctx context.Context, adminID uint64, req CreateRuleRequest) (*RuleDTO, error) {
|
||||
if err := s.available(); err != nil {
|
||||
@@ -91,11 +91,11 @@ func (s *Service) CreateRule(ctx context.Context, adminID uint64, req CreateRule
|
||||
}
|
||||
return s.repo.CreateRule(ctx, adminID, req)
|
||||
}
|
||||
func (s *Service) UpdateRuleStatus(ctx context.Context, id uint64, status string) (*RuleDTO, error) {
|
||||
func (s *Service) UpdateRuleStatus(ctx context.Context, adminID, id uint64, status string) (*RuleDTO, error) {
|
||||
if err := s.available(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.repo.UpdateRuleStatus(ctx, id, status)
|
||||
return s.repo.UpdateRuleStatus(ctx, adminID, id, status)
|
||||
}
|
||||
|
||||
func (s *Service) ListOrders(ctx context.Context, query DistributionOrderListQuery) (*DistributionOrderPage, error) {
|
||||
@@ -104,11 +104,11 @@ func (s *Service) ListOrders(ctx context.Context, query DistributionOrderListQue
|
||||
}
|
||||
return s.repo.ListOrders(ctx, query)
|
||||
}
|
||||
func (s *Service) FindOrder(ctx context.Context, id uint64) (*DistributionOrderDTO, error) {
|
||||
func (s *Service) FindOrder(ctx context.Context, adminID, id uint64) (*DistributionOrderDTO, error) {
|
||||
if err := s.available(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.repo.FindOrder(ctx, id)
|
||||
return s.repo.FindOrder(ctx, adminID, id)
|
||||
}
|
||||
func (s *Service) ListAccountDisplays(ctx context.Context, siteID uint64, status string) ([]AccountDisplayDTO, error) {
|
||||
if err := s.available(); err != nil {
|
||||
@@ -116,11 +116,11 @@ func (s *Service) ListAccountDisplays(ctx context.Context, siteID uint64, status
|
||||
}
|
||||
return s.repo.ListAccountDisplays(ctx, siteID, status)
|
||||
}
|
||||
func (s *Service) UpdateAccountDisplay(ctx context.Context, id uint64, status string) (*AccountDisplayDTO, error) {
|
||||
func (s *Service) UpdateAccountDisplay(ctx context.Context, adminID, id uint64, status string) (*AccountDisplayDTO, error) {
|
||||
if err := s.available(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.repo.UpdateAccountDisplay(ctx, id, status)
|
||||
return s.repo.UpdateAccountDisplay(ctx, adminID, id, status)
|
||||
}
|
||||
func (s *Service) ListPaymentChannels(ctx context.Context, siteID uint64) ([]PaymentChannelDTO, error) {
|
||||
if err := s.available(); err != nil {
|
||||
@@ -134,11 +134,11 @@ func (s *Service) BindPaymentChannel(ctx context.Context, siteID uint64, req Bin
|
||||
}
|
||||
return s.repo.BindPaymentChannel(ctx, siteID, req)
|
||||
}
|
||||
func (s *Service) UnbindPaymentChannel(ctx context.Context, id uint64) error {
|
||||
func (s *Service) UnbindPaymentChannel(ctx context.Context, adminID, id uint64) error {
|
||||
if err := s.available(); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.repo.UnbindPaymentChannel(ctx, id)
|
||||
return s.repo.UnbindPaymentChannel(ctx, adminID, id)
|
||||
}
|
||||
func (s *Service) ListSettlementBatches(ctx context.Context, siteID uint64) ([]SettlementBatchDTO, error) {
|
||||
if err := s.available(); err != nil {
|
||||
@@ -152,16 +152,16 @@ func (s *Service) CreateSettlementBatch(ctx context.Context, adminID uint64, req
|
||||
}
|
||||
return s.repo.CreateSettlementBatch(ctx, adminID, req)
|
||||
}
|
||||
func (s *Service) MarkSettlementBatch(ctx context.Context, id uint64) (*SettlementBatchDTO, error) {
|
||||
func (s *Service) MarkSettlementBatch(ctx context.Context, adminID, id uint64) (*SettlementBatchDTO, error) {
|
||||
if err := s.available(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.repo.MarkSettlementBatch(ctx, id)
|
||||
return s.repo.MarkSettlementBatch(ctx, adminID, id)
|
||||
}
|
||||
|
||||
func (s *Service) CreateFinancialSnapshot(ctx context.Context, orderID uint64, req CreateFinancialSnapshotRequest) (*DistributionOrderDTO, error) {
|
||||
func (s *Service) CreateFinancialSnapshot(ctx context.Context, adminID, orderID uint64, req CreateFinancialSnapshotRequest) (*DistributionOrderDTO, error) {
|
||||
if err := s.available(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.repo.CreateFinancialSnapshot(ctx, orderID, req)
|
||||
return s.repo.CreateFinancialSnapshot(ctx, adminID, orderID, req)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user