fix(order): 支持客服跨站处理订单与退款

This commit is contained in:
yml
2026-11-19 20:29:16 +08:00
parent 3492ecbe9b
commit cd081d1cdd
18 changed files with 349 additions and 191 deletions
-30
View File
@@ -370,7 +370,6 @@ func (r *Repository) FindAdmin(ctx context.Context, orderID uint64) (*OrderDTO,
}
dto := row.toAdminDTO()
dto.SiteRole = tenantOrderRole(ctx, row.RentalOrder)
filterAdminActionsForSiteRole(&dto)
applyPaymentDeadline(&dto, row.RentalOrder, pendingPaymentTimeoutMinutes(db))
dto.ActiveDispute = r.activeDisputeDTO(ctx, orderID)
dto.Checkout = r.latestCheckoutAdminDTO(ctx, orderID)
@@ -388,7 +387,6 @@ func (r *Repository) FindLatestAdminByListing(ctx context.Context, listingID uin
}
dto := row.toAdminDTO()
dto.SiteRole = tenantOrderRole(ctx, row.RentalOrder)
filterAdminActionsForSiteRole(&dto)
applyPaymentDeadline(&dto, row.RentalOrder, pendingPaymentTimeoutMinutes(db))
dto.ActiveDispute = r.activeDisputeDTO(ctx, row.ID)
dto.Checkout = r.latestCheckoutAdminDTO(ctx, row.ID)
@@ -551,16 +549,6 @@ func applyTenantOrderScope(query *gorm.DB, ctx context.Context) *gorm.DB {
Where("(o.distribution_site_id IS NULL OR o.distribution_site_id = 0)")
}
func applyBuyerTenantOrderScope(query *gorm.DB, ctx context.Context) *gorm.DB {
tenantID := tenancy.IDFromContext(ctx)
if tenantID == 0 {
return query
}
return query.
Where("o.buyer_tenant_id = ?", tenantID).
Where("(o.distribution_site_id IS NULL OR o.distribution_site_id = 0)")
}
func tenantOrderRole(ctx context.Context, order model.RentalOrder) string {
tenantID := tenancy.IDFromContext(ctx)
if tenantID == 0 {
@@ -580,24 +568,6 @@ func tenantOrderRole(ctx context.Context, order model.RentalOrder) string {
}
}
func filterAdminActionsForSiteRole(dto *OrderDTO) {
if dto == nil || dto.AdminActions == nil || dto.SiteRole == "" || dto.SiteRole == "both" {
return
}
actions := dto.AdminActions
if dto.SiteRole == "buyer" {
actions.ResetHandoff = nil
actions.PlatformHandoff = nil
actions.ForceHandoff = nil
actions.PlatformOfflineSettlement = nil
}
if dto.SiteRole == "source" {
actions.PlatformCheckoutConfirm = nil
actions.PlatformCheckoutCounter = nil
actions.PlatformCheckoutDispute = nil
}
}
type orderRow struct {
model.RentalOrder
Title string