feat(distribution): 支持分销上传来源追踪、主站审核展示与收售结算模式自动判定
This commit is contained in:
@@ -3,6 +3,8 @@ package order
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"hfb_sys/backend/internal/model"
|
||||
@@ -146,13 +148,22 @@ func (r *Repository) Create(ctx context.Context, renterID uint64, req CreateRequ
|
||||
func orderAccountSourceSnapshot(tx *gorm.DB, listingID uint64) (string, string, error) {
|
||||
var upload model.ListingUpload
|
||||
err := tx.Where("listing_id = ?", listingID).Order("id DESC").First(&upload).Error
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return "internal", "", nil
|
||||
if err == nil {
|
||||
return "external", upload.SourceChannel, nil
|
||||
}
|
||||
if err != nil {
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return "", "", err
|
||||
}
|
||||
return "external", upload.SourceChannel, nil
|
||||
|
||||
var listing model.RentalListing
|
||||
if err := tx.Select("distribution_site_id").First(&listing, listingID).Error; err == nil && listing.DistributionSiteID != nil {
|
||||
var site model.DistributionSite
|
||||
if err := tx.Select("site_code, site_name").First(&site, *listing.DistributionSiteID).Error; err == nil {
|
||||
return "distribution", fmt.Sprintf("分销站 - %s (%s)", site.SiteName, site.SiteCode), nil
|
||||
}
|
||||
}
|
||||
|
||||
return "internal", "", nil
|
||||
}
|
||||
|
||||
func listingHandoffMode(listing model.RentalListing) string {
|
||||
|
||||
Reference in New Issue
Block a user