fix(distribution): 统一分销订单租户管理口径
This commit is contained in:
@@ -92,7 +92,6 @@ func (r *Repository) Summary(ctx context.Context) (*DashboardDTO, error) {
|
||||
SELECT 1 FROM rental_orders AS tenant_order
|
||||
WHERE tenant_order.id = d.order_id
|
||||
AND tenant_order.buyer_tenant_id = ?
|
||||
AND (tenant_order.distribution_site_id IS NULL OR tenant_order.distribution_site_id = 0)
|
||||
)`, tenantID)
|
||||
}
|
||||
if err := disputeQuery.Where("d.status IN ?", []string{"open", "processing"}).Count(&pending.Disputes).Error; err != nil {
|
||||
@@ -163,7 +162,6 @@ func (r *Repository) tenantStats(ctx context.Context, tenantID uint64, metrics M
|
||||
}
|
||||
if err := db.Table("rental_orders AS o").
|
||||
Where("o.buyer_tenant_id = ?", tenantID).
|
||||
Where("(o.distribution_site_id IS NULL OR o.distribution_site_id = 0)").
|
||||
Where(tradingOrderPaidCondition).
|
||||
Select("COUNT(*) AS buyer_order_count, COALESCE(SUM(o.rent_amount_cent), 0) AS buyer_gmv_cent").
|
||||
Scan(&buyerStats).Error; err != nil {
|
||||
@@ -177,7 +175,6 @@ func (r *Repository) tenantStats(ctx context.Context, tenantID uint64, metrics M
|
||||
}
|
||||
if err := db.Table("rental_orders AS o").
|
||||
Where("o.source_tenant_id = ?", tenantID).
|
||||
Where("(o.distribution_site_id IS NULL OR o.distribution_site_id = 0)").
|
||||
Where(tradingOrderPaidCondition).
|
||||
Select("COUNT(*) AS source_order_count, COALESCE(SUM(o.source_amount_cent), 0) AS source_amount_cent").
|
||||
Scan(&sourceStats).Error; err != nil {
|
||||
@@ -193,8 +190,7 @@ func applyDashboardOrderScope(query *gorm.DB, tenantID uint64) *gorm.DB {
|
||||
return query
|
||||
}
|
||||
return query.
|
||||
Where("(o.buyer_tenant_id = ? OR o.source_tenant_id = ?)", tenantID, tenantID).
|
||||
Where("(o.distribution_site_id IS NULL OR o.distribution_site_id = 0)")
|
||||
Where("(o.buyer_tenant_id = ? OR o.source_tenant_id = ?)", tenantID, tenantID)
|
||||
}
|
||||
|
||||
func (r *Repository) listingDailyOverview(ctx context.Context, now time.Time, days int) (ListingDailyOverviewDTO, error) {
|
||||
@@ -597,8 +593,7 @@ func (r *Repository) recentDisputes(ctx context.Context) ([]RecentDisputeDTO, er
|
||||
Joins("JOIN game_accounts AS a ON a.id = o.account_id")
|
||||
if tenantID := tenancy.IDFromContext(ctx); tenantID > 0 {
|
||||
query = query.
|
||||
Where("o.buyer_tenant_id = ?", tenantID).
|
||||
Where("(o.distribution_site_id IS NULL OR o.distribution_site_id = 0)")
|
||||
Where("o.buyer_tenant_id = ?", tenantID)
|
||||
}
|
||||
err := query.
|
||||
Order("d.id DESC").
|
||||
|
||||
Reference in New Issue
Block a user