fix(distribution): 统一分销订单租户管理口径

This commit is contained in:
yml
2026-11-24 22:12:52 +08:00
parent 3ac4052ac5
commit 3cc61615f9
20 changed files with 462 additions and 101 deletions
@@ -19,8 +19,10 @@ func (r *Repository) FindTenantOffer(ctx context.Context, listingID uint64) (*Te
}
var listing model.RentalListing
if err := r.db.WithContext(ctx).
Select("id, price_cent").
Where("id = ? AND (distribution_site_id IS NULL OR distribution_site_id = 0)", listingID).
Table("rental_listings AS l").
Select("l.id, l.price_cent").
Joins("JOIN tenant_listing_offers AS tlo ON tlo.listing_id = l.id AND tlo.tenant_id = ?", tenantID).
Where("l.id = ?", listingID).
First(&listing).Error; err != nil {
return nil, err
}
@@ -54,8 +56,10 @@ func (r *Repository) UpdateTenantOffer(
}
var listing model.RentalListing
if err := r.db.WithContext(ctx).
Select("id, price_cent").
Where("id = ? AND (distribution_site_id IS NULL OR distribution_site_id = 0)", listingID).
Table("rental_listings AS l").
Select("l.id, l.price_cent").
Joins("JOIN tenant_listing_offers AS tlo ON tlo.listing_id = l.id AND tlo.tenant_id = ?", tenantID).
Where("l.id = ?", listingID).
First(&listing).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, ErrListingNotFound