test(distribution): 补齐分销全场景E2E与HTTP接口全链路集成测试
- 新增端到端测试场景: - 场景 1: 主站收号分站加价售卖与批次结算全链路 - 场景 2: 分站收号主站售卖、独立鉴权、大盘统计与提现全流程 - 场景 3: 三方模式跨站流转、专属支付通道自动路由与双站批次独立结算 - 场景 4: 分站自收自售、3天冷却期自动释放及幂等防护 - 场景 5: 结算后退款回冲金库钱包、掏空后透支扣减与仲裁风险隔离 - 场景 6: 一键开站、成员JWT鉴权、品牌个性化、三模解析与货架同步加价 - 新增 distribution/handler_integration_test.go:覆盖 30+ 分销 HTTP 接口(前台公开端点、分站管理员登录/信息端点、站长运营端点及总台管理端点) - 修复并对齐底层逻辑: - FindOrder & ListOrders:多参与方按 PartyID 准确隔离各站收益与提价统计 - SnapshotPaidOrderTx:规范多方模式下 PartyTypeSite 的 SiteID/PartyID - 增加 ErrInsufficientBalance 哨兵错误并在 handler 映射为 400
This commit is contained in:
@@ -592,6 +592,9 @@ func (r *Repository) ListOrders(ctx context.Context, query DistributionOrderList
|
||||
if p.PartyType != PartyTypeSite {
|
||||
continue
|
||||
}
|
||||
if query.SiteID > 0 && p.PartyID > 0 && p.PartyID != query.SiteID {
|
||||
continue
|
||||
}
|
||||
totalEarning += p.IncomeAmountCent
|
||||
if p.PartyRole == "distributor_sell" || p.PartyRole == "distributor_b" {
|
||||
roles = append(roles, "sell")
|
||||
@@ -723,13 +726,12 @@ func (r *Repository) FindOrder(ctx context.Context, adminID, id uint64) (*Distri
|
||||
}
|
||||
if len(siteSet) > 0 {
|
||||
match := false
|
||||
if p.SiteID > 0 {
|
||||
if _, ok := siteSet[p.SiteID]; ok {
|
||||
if p.PartyType == PartyTypeSite && p.PartyID > 0 {
|
||||
if _, ok := siteSet[p.PartyID]; ok {
|
||||
match = true
|
||||
}
|
||||
}
|
||||
if p.PartyID > 0 {
|
||||
if _, ok := siteSet[p.PartyID]; ok {
|
||||
} else if p.SiteID > 0 {
|
||||
if _, ok := siteSet[p.SiteID]; ok {
|
||||
match = true
|
||||
}
|
||||
}
|
||||
@@ -2261,7 +2263,7 @@ func (r *Repository) ApplySiteWithdrawal(ctx context.Context, adminID, siteID ui
|
||||
return err
|
||||
}
|
||||
if account.AvailableBalanceCent < req.AmountCent {
|
||||
return errors.New("可提现余额不足")
|
||||
return ErrInsufficientBalance
|
||||
}
|
||||
|
||||
withdrawal = model.WithdrawalRequest{
|
||||
|
||||
Reference in New Issue
Block a user