feat(distribution): 移除生产环境资金冻结,测试与生产口径统一
liveMoneyMovementEnabled 按 APP_ENV 在生产冻结结算入账、站点提现与自动释放, 与测试环境行为不一致,且该开关在 APP_ENV 缺失时为 fail-open。本次整体移除: - 删除 liveMoneyMovementEnabled 与 ErrLiveMoneyMovementFrozen - MarkSettlementBatch / ApplySiteWithdrawal / AutoReleaseDueSettlements 去掉守卫 - handler 去掉 403 settlement_frozen 映射 - 测试改为断言生产环境结算入账与提现正常执行
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -41,7 +40,6 @@ var (
|
||||
ErrAdminDisabled = errors.New("admin disabled")
|
||||
ErrDuplicateSiteCodeOrDomain = errors.New("distribution site code or domain already exists")
|
||||
ErrDuplicateUsername = errors.New("username already exists")
|
||||
ErrLiveMoneyMovementFrozen = errors.New("distribution settlement and withdrawal frozen until split rules are verified")
|
||||
ErrTooManySyncListings = errors.New("too many listings to sync")
|
||||
ErrSyncListingNotFound = errors.New("sync listing not found")
|
||||
ErrEmptyListingIDs = errors.New("listing ids required")
|
||||
@@ -54,11 +52,6 @@ var settlementReadyOrderStatuses = []string{"completed", "closed"}
|
||||
|
||||
const maxSyncListingIDs = 200
|
||||
|
||||
func liveMoneyMovementEnabled() bool {
|
||||
env := strings.ToLower(strings.TrimSpace(os.Getenv("APP_ENV")))
|
||||
return env != "production" && env != "prod"
|
||||
}
|
||||
|
||||
// normalizeSettlementHoldDays 校验站点结算冷却天数,允许 0(订单完成即释放)到 365 天。
|
||||
func normalizeSettlementHoldDays(days int) (int, error) {
|
||||
if days < 0 || days > 365 {
|
||||
@@ -1021,9 +1014,6 @@ func (r *Repository) CreateSettlementBatch(ctx context.Context, adminID uint64,
|
||||
}
|
||||
|
||||
func (r *Repository) MarkSettlementBatch(ctx context.Context, adminID, id uint64) (*SettlementBatchDTO, error) {
|
||||
if !liveMoneyMovementEnabled() {
|
||||
return nil, ErrLiveMoneyMovementFrozen
|
||||
}
|
||||
var row model.DistributionSettlementBatch
|
||||
err := r.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
if err := tx.Clauses(clause.Locking{Strength: "UPDATE"}).First(&row, id).Error; err != nil {
|
||||
@@ -2056,9 +2046,6 @@ func (r *Repository) GetSiteWallet(ctx context.Context, adminID, siteID uint64)
|
||||
}
|
||||
|
||||
func (r *Repository) ApplySiteWithdrawal(ctx context.Context, adminID, siteID uint64, req ApplySiteWithdrawalRequest) (*SiteWithdrawalDTO, error) {
|
||||
if !liveMoneyMovementEnabled() {
|
||||
return nil, ErrLiveMoneyMovementFrozen
|
||||
}
|
||||
if siteID == 0 {
|
||||
return nil, ErrSiteNotFound
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user