fix(pickup): 支持天域分销货源提号结算
This commit is contained in:
@@ -50,57 +50,60 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type PickupDTO struct {
|
type PickupDTO struct {
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
TenantID uint64 `json:"tenant_id"`
|
TenantID uint64 `json:"tenant_id"`
|
||||||
TenantCode string `json:"tenant_code"`
|
TenantCode string `json:"tenant_code"`
|
||||||
TenantName string `json:"tenant_name"`
|
TenantName string `json:"tenant_name"`
|
||||||
SourceTenantID uint64 `json:"source_tenant_id"`
|
SourceTenantID uint64 `json:"source_tenant_id"`
|
||||||
SourceTenantCode string `json:"source_tenant_code"`
|
SourceTenantCode string `json:"source_tenant_code"`
|
||||||
SourceTenantName string `json:"source_tenant_name"`
|
SourceTenantName string `json:"source_tenant_name"`
|
||||||
IsCrossTenant bool `json:"is_cross_tenant"`
|
SourceDistributionSiteID uint64 `json:"source_distribution_site_id"`
|
||||||
PickupNo string `json:"pickup_no"`
|
SourceDistributionSiteCode string `json:"source_distribution_site_code"`
|
||||||
ListingID uint64 `json:"listing_id"`
|
SourceDistributionSiteName string `json:"source_distribution_site_name"`
|
||||||
ListingNo string `json:"listing_no"`
|
IsCrossTenant bool `json:"is_cross_tenant"`
|
||||||
AccountID uint64 `json:"account_id"`
|
PickupNo string `json:"pickup_no"`
|
||||||
AccountTitle string `json:"account_title"`
|
ListingID uint64 `json:"listing_id"`
|
||||||
ServerRegion string `json:"server_region"`
|
ListingNo string `json:"listing_no"`
|
||||||
LoginPlatform string `json:"login_platform"`
|
AccountID uint64 `json:"account_id"`
|
||||||
OwnerID uint64 `json:"owner_id"`
|
AccountTitle string `json:"account_title"`
|
||||||
OwnerPhone string `json:"owner_phone"`
|
ServerRegion string `json:"server_region"`
|
||||||
AdminID uint64 `json:"admin_id"`
|
LoginPlatform string `json:"login_platform"`
|
||||||
Operator string `json:"operator"`
|
OwnerID uint64 `json:"owner_id"`
|
||||||
Platform string `json:"platform"`
|
OwnerPhone string `json:"owner_phone"`
|
||||||
ThirdPartyOrderNo string `json:"third_party_order_no"`
|
AdminID uint64 `json:"admin_id"`
|
||||||
ShopName string `json:"shop_name"`
|
Operator string `json:"operator"`
|
||||||
RawShopName string `json:"raw_shop_name"`
|
Platform string `json:"platform"`
|
||||||
AccountSource string `json:"account_source"`
|
ThirdPartyOrderNo string `json:"third_party_order_no"`
|
||||||
SourceChannel string `json:"source_channel"`
|
ShopName string `json:"shop_name"`
|
||||||
SettlementMode string `json:"settlement_mode"`
|
RawShopName string `json:"raw_shop_name"`
|
||||||
ListingPriceCent int64 `json:"listing_price_cent"`
|
AccountSource string `json:"account_source"`
|
||||||
OrderAmountCent int64 `json:"order_amount_cent"`
|
SourceChannel string `json:"source_channel"`
|
||||||
DepositAmountCent int64 `json:"deposit_amount_cent"`
|
SettlementMode string `json:"settlement_mode"`
|
||||||
OwnerPriceCent int64 `json:"owner_price_cent"`
|
ListingPriceCent int64 `json:"listing_price_cent"`
|
||||||
WebsiteProfitCent int64 `json:"website_profit_cent"`
|
OrderAmountCent int64 `json:"order_amount_cent"`
|
||||||
ProfitAmountCent int64 `json:"profit_amount_cent"`
|
DepositAmountCent int64 `json:"deposit_amount_cent"`
|
||||||
ProfitAdjustmentCent int64 `json:"profit_adjustment_cent"`
|
OwnerPriceCent int64 `json:"owner_price_cent"`
|
||||||
EffectiveProfitAmountCent int64 `json:"effective_profit_amount_cent"`
|
WebsiteProfitCent int64 `json:"website_profit_cent"`
|
||||||
SellerRatio float64 `json:"seller_ratio"`
|
ProfitAmountCent int64 `json:"profit_amount_cent"`
|
||||||
BuyerRatio float64 `json:"buyer_ratio"`
|
ProfitAdjustmentCent int64 `json:"profit_adjustment_cent"`
|
||||||
AccountSnapshot datatypes.JSON `json:"account_snapshot,omitempty"`
|
EffectiveProfitAmountCent int64 `json:"effective_profit_amount_cent"`
|
||||||
SettleAmountCent int64 `json:"settle_amount_cent"`
|
SellerRatio float64 `json:"seller_ratio"`
|
||||||
SettleAdjustmentCent int64 `json:"settle_adjustment_cent"`
|
BuyerRatio float64 `json:"buyer_ratio"`
|
||||||
EffectiveSettleAmountCent int64 `json:"effective_settle_amount_cent"`
|
AccountSnapshot datatypes.JSON `json:"account_snapshot,omitempty"`
|
||||||
Status string `json:"status"`
|
SettleAmountCent int64 `json:"settle_amount_cent"`
|
||||||
OfflineSettlementStatus string `json:"offline_settlement_status"`
|
SettleAdjustmentCent int64 `json:"settle_adjustment_cent"`
|
||||||
OfflineSettlementRemark string `json:"offline_settlement_remark"`
|
EffectiveSettleAmountCent int64 `json:"effective_settle_amount_cent"`
|
||||||
ActualPayoutOperator string `json:"offline_settlement_actual_operator"`
|
Status string `json:"status"`
|
||||||
OfflineSettledBy *uint64 `json:"offline_settled_by,omitempty"`
|
OfflineSettlementStatus string `json:"offline_settlement_status"`
|
||||||
OfflineSettledAt *time.Time `json:"offline_settled_at,omitempty"`
|
OfflineSettlementRemark string `json:"offline_settlement_remark"`
|
||||||
Remark string `json:"remark"`
|
ActualPayoutOperator string `json:"offline_settlement_actual_operator"`
|
||||||
CompleteRemark string `json:"complete_remark"`
|
OfflineSettledBy *uint64 `json:"offline_settled_by,omitempty"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
OfflineSettledAt *time.Time `json:"offline_settled_at,omitempty"`
|
||||||
CompletedAt *time.Time `json:"completed_at,omitempty"`
|
Remark string `json:"remark"`
|
||||||
CancelledAt *time.Time `json:"cancelled_at,omitempty"`
|
CompleteRemark string `json:"complete_remark"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
CompletedAt *time.Time `json:"completed_at,omitempty"`
|
||||||
|
CancelledAt *time.Time `json:"cancelled_at,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FinancialAdjustmentDTO struct {
|
type FinancialAdjustmentDTO struct {
|
||||||
@@ -253,31 +256,34 @@ type SellerPickupQuery struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AvailableListingDTO struct {
|
type AvailableListingDTO struct {
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
SourceTenantID uint64 `json:"source_tenant_id"`
|
SourceTenantID uint64 `json:"source_tenant_id"`
|
||||||
SourceTenantCode string `json:"source_tenant_code"`
|
SourceTenantCode string `json:"source_tenant_code"`
|
||||||
SourceTenantName string `json:"source_tenant_name"`
|
SourceTenantName string `json:"source_tenant_name"`
|
||||||
IsCrossTenant bool `json:"is_cross_tenant"`
|
SourceDistributionSiteID uint64 `json:"source_distribution_site_id"`
|
||||||
ListingNo string `json:"listing_no"`
|
SourceDistributionSiteCode string `json:"source_distribution_site_code"`
|
||||||
AccountID uint64 `json:"account_id"`
|
SourceDistributionSiteName string `json:"source_distribution_site_name"`
|
||||||
AccountTitle string `json:"account_title"`
|
IsCrossTenant bool `json:"is_cross_tenant"`
|
||||||
ServerRegion string `json:"server_region"`
|
ListingNo string `json:"listing_no"`
|
||||||
LoginPlatform string `json:"login_platform"`
|
AccountID uint64 `json:"account_id"`
|
||||||
OwnerID uint64 `json:"owner_id"`
|
AccountTitle string `json:"account_title"`
|
||||||
OwnerPhone string `json:"owner_phone"`
|
ServerRegion string `json:"server_region"`
|
||||||
ListingPriceCent int64 `json:"listing_price_cent"`
|
LoginPlatform string `json:"login_platform"`
|
||||||
OwnerPriceCent int64 `json:"owner_price_cent"`
|
OwnerID uint64 `json:"owner_id"`
|
||||||
OwnerPurePriceCent int64 `json:"owner_pure_price_cent"`
|
OwnerPhone string `json:"owner_phone"`
|
||||||
OwnerExtraItemPriceCent int64 `json:"owner_extra_item_price_cent"`
|
ListingPriceCent int64 `json:"listing_price_cent"`
|
||||||
OwnerTotalPriceCent int64 `json:"owner_total_price_cent"`
|
OwnerPriceCent int64 `json:"owner_price_cent"`
|
||||||
WebsiteProfitCent int64 `json:"website_profit_cent"`
|
OwnerPurePriceCent int64 `json:"owner_pure_price_cent"`
|
||||||
SellerRatio float64 `json:"seller_ratio"`
|
OwnerExtraItemPriceCent int64 `json:"owner_extra_item_price_cent"`
|
||||||
BuyerRatio float64 `json:"buyer_ratio"`
|
OwnerTotalPriceCent int64 `json:"owner_total_price_cent"`
|
||||||
AccountSource string `json:"account_source"`
|
WebsiteProfitCent int64 `json:"website_profit_cent"`
|
||||||
IsExternalUpload bool `json:"is_external_upload"`
|
SellerRatio float64 `json:"seller_ratio"`
|
||||||
SourceChannel string `json:"source_channel"`
|
BuyerRatio float64 `json:"buyer_ratio"`
|
||||||
HandoffMode string `json:"handoff_mode"`
|
AccountSource string `json:"account_source"`
|
||||||
SettlementMode string `json:"settlement_mode"`
|
IsExternalUpload bool `json:"is_external_upload"`
|
||||||
|
SourceChannel string `json:"source_channel"`
|
||||||
|
HandoffMode string `json:"handoff_mode"`
|
||||||
|
SettlementMode string `json:"settlement_mode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AvailableListingQuery struct {
|
type AvailableListingQuery struct {
|
||||||
|
|||||||
@@ -134,17 +134,18 @@ func (r *Repository) Create(ctx context.Context, req CreateRequest, adminID uint
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := appendPickupEvent(tx, pickup, "pickup_created", adminID, "管理员创建线下提号。", pickup.Remark, map[string]any{
|
if err := appendPickupEvent(tx, pickup, "pickup_created", adminID, "管理员创建线下提号。", pickup.Remark, map[string]any{
|
||||||
"tenant_id": pickup.TenantID,
|
"tenant_id": pickup.TenantID,
|
||||||
"source_tenant_id": pickup.SourceTenantID,
|
"source_tenant_id": pickup.SourceTenantID,
|
||||||
"listing_price_cent": pickup.ListingPriceCent,
|
"source_distribution_site_id": pickupDistributionSiteID(listing),
|
||||||
"order_amount_cent": pickup.OrderAmountCent,
|
"listing_price_cent": pickup.ListingPriceCent,
|
||||||
"deposit_amount_cent": pickup.DepositAmountCent,
|
"order_amount_cent": pickup.OrderAmountCent,
|
||||||
"profit_amount_cent": pickup.ProfitAmountCent,
|
"deposit_amount_cent": pickup.DepositAmountCent,
|
||||||
"account_source": pickup.AccountSource,
|
"profit_amount_cent": pickup.ProfitAmountCent,
|
||||||
"source_channel": pickup.SourceChannel,
|
"account_source": pickup.AccountSource,
|
||||||
"settlement_mode": pickup.SettlementMode,
|
"source_channel": pickup.SourceChannel,
|
||||||
"operator": pickup.Operator,
|
"settlement_mode": pickup.SettlementMode,
|
||||||
"third_party_order_no": pickup.ThirdPartyOrderNo,
|
"operator": pickup.Operator,
|
||||||
|
"third_party_order_no": pickup.ThirdPartyOrderNo,
|
||||||
}, map[string]any{}); err != nil {
|
}, map[string]any{}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -193,19 +194,20 @@ func (r *Repository) Create(ctx context.Context, req CreateRequest, adminID uint
|
|||||||
BizID: &bid,
|
BizID: &bid,
|
||||||
Meta: meta,
|
Meta: meta,
|
||||||
Detail: map[string]any{
|
Detail: map[string]any{
|
||||||
"pickup_no": pickupNo,
|
"pickup_no": pickupNo,
|
||||||
"tenant_id": pickup.TenantID,
|
"tenant_id": pickup.TenantID,
|
||||||
"source_tenant_id": pickup.SourceTenantID,
|
"source_tenant_id": pickup.SourceTenantID,
|
||||||
"listing_id": listing.ID,
|
"source_distribution_site_id": pickupDistributionSiteID(listing),
|
||||||
"platform": pickup.Platform,
|
"listing_id": listing.ID,
|
||||||
"third_party_order_no": pickup.ThirdPartyOrderNo,
|
"platform": pickup.Platform,
|
||||||
"shop_name": pickup.ShopName,
|
"third_party_order_no": pickup.ThirdPartyOrderNo,
|
||||||
"operator": pickup.Operator,
|
"shop_name": pickup.ShopName,
|
||||||
"account_source": pickup.AccountSource,
|
"operator": pickup.Operator,
|
||||||
"source_channel": pickup.SourceChannel,
|
"account_source": pickup.AccountSource,
|
||||||
"order_amount_cent": pickup.OrderAmountCent,
|
"source_channel": pickup.SourceChannel,
|
||||||
"deposit_amount_cent": pickup.DepositAmountCent,
|
"order_amount_cent": pickup.OrderAmountCent,
|
||||||
"profit_cent": pickup.ProfitAmountCent,
|
"deposit_amount_cent": pickup.DepositAmountCent,
|
||||||
|
"profit_cent": pickup.ProfitAmountCent,
|
||||||
},
|
},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -303,13 +305,15 @@ func (r *Repository) Complete(ctx context.Context, pickupID uint64, req Complete
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := wallet.AppendEntries(tx, wallet.Entry{
|
if err := wallet.AppendEntries(tx, wallet.Entry{
|
||||||
UserID: pickup.OwnerID,
|
TenantID: pickup.SourceTenantID,
|
||||||
Direction: "in",
|
UserID: pickup.OwnerID,
|
||||||
AmountCent: req.SettleAmountCent,
|
DistributionSiteID: pickupDistributionSiteID(listing),
|
||||||
BalanceType: "available",
|
Direction: "in",
|
||||||
BizType: "admin_pickup_settle",
|
AmountCent: req.SettleAmountCent,
|
||||||
BizNo: pickup.PickupNo,
|
BalanceType: "available",
|
||||||
Remark: fmt.Sprintf("管理员提号结算:%s", pickup.PickupNo),
|
BizType: "admin_pickup_settle",
|
||||||
|
BizNo: pickup.PickupNo,
|
||||||
|
Remark: fmt.Sprintf("管理员提号结算:%s", pickup.PickupNo),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -650,14 +654,20 @@ func (r *Repository) CreateFinancialAdjustment(ctx context.Context, pickupID uin
|
|||||||
|
|
||||||
// 站内钱包的补款在创建调整时立即到账;扣款统一转待追回,避免余额被扣成负数。
|
// 站内钱包的补款在创建调整时立即到账;扣款统一转待追回,避免余额被扣成负数。
|
||||||
if pickup.SettlementMode == SettlementModeOwnerWallet && settleDeltaCent > 0 {
|
if pickup.SettlementMode == SettlementModeOwnerWallet && settleDeltaCent > 0 {
|
||||||
|
var listing model.RentalListing
|
||||||
|
if err := tx.Select("id", "distribution_site_id").First(&listing, pickup.ListingID).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := wallet.AppendEntries(tx, wallet.Entry{
|
if err := wallet.AppendEntries(tx, wallet.Entry{
|
||||||
UserID: pickup.OwnerID,
|
TenantID: pickup.SourceTenantID,
|
||||||
Direction: "in",
|
UserID: pickup.OwnerID,
|
||||||
AmountCent: settleDeltaCent,
|
DistributionSiteID: pickupDistributionSiteID(listing),
|
||||||
BalanceType: "available",
|
Direction: "in",
|
||||||
BizType: "admin_pickup_adjustment",
|
AmountCent: settleDeltaCent,
|
||||||
BizNo: fmt.Sprintf("%s-A%d", pickup.PickupNo, adjustment.ID),
|
BalanceType: "available",
|
||||||
Remark: fmt.Sprintf("管理员提号结算补款:%s", pickup.PickupNo),
|
BizType: "admin_pickup_adjustment",
|
||||||
|
BizNo: fmt.Sprintf("%s-A%d", pickup.PickupNo, adjustment.ID),
|
||||||
|
Remark: fmt.Sprintf("管理员提号结算补款:%s", pickup.PickupNo),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1567,10 +1577,23 @@ func (r *Repository) ListAvailableListings(ctx context.Context, query AvailableL
|
|||||||
Joins("JOIN game_accounts AS a ON a.id = l.account_id").
|
Joins("JOIN game_accounts AS a ON a.id = l.account_id").
|
||||||
Joins("JOIN users AS owner ON owner.id = l.owner_id").
|
Joins("JOIN users AS owner ON owner.id = l.owner_id").
|
||||||
Joins("LEFT JOIN tenants AS source_tenant ON source_tenant.id = l.source_tenant_id").
|
Joins("LEFT JOIN tenants AS source_tenant ON source_tenant.id = l.source_tenant_id").
|
||||||
|
Joins("LEFT JOIN distribution_sites AS source_site ON source_site.id = l.distribution_site_id").
|
||||||
Joins("LEFT JOIN (?) AS latest_upload ON latest_upload.listing_id = l.id", latestUploads).
|
Joins("LEFT JOIN (?) AS latest_upload ON latest_upload.listing_id = l.id", latestUploads).
|
||||||
Joins("LEFT JOIN listing_uploads AS lu ON lu.id = latest_upload.upload_id").
|
Joins("LEFT JOIN listing_uploads AS lu ON lu.id = latest_upload.upload_id").
|
||||||
Where("l.status = ? AND l.review_status = ? AND l.in_transaction = ?", "published", "approved", false).
|
Where("l.status = ? AND l.review_status = ? AND l.in_transaction = ?", "published", "approved", false)
|
||||||
Where("(l.distribution_site_id IS NULL OR l.distribution_site_id = 0)")
|
if tenantID := tenancy.IDFromContext(ctx); tenantID > 0 {
|
||||||
|
q = q.Where(`(
|
||||||
|
l.distribution_site_id IS NULL
|
||||||
|
OR l.distribution_site_id = 0
|
||||||
|
OR EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM tenant_listing_offers AS tlo
|
||||||
|
WHERE tlo.listing_id = l.id
|
||||||
|
AND tlo.tenant_id = ?
|
||||||
|
AND tlo.display_status = 'enabled'
|
||||||
|
)
|
||||||
|
)`, tenantID)
|
||||||
|
}
|
||||||
if kw := strings.TrimSpace(query.Keyword); kw != "" {
|
if kw := strings.TrimSpace(query.Keyword); kw != "" {
|
||||||
upper := strings.ToUpper(kw)
|
upper := strings.ToUpper(kw)
|
||||||
if strings.HasPrefix(upper, "L") || (len(kw) >= 12 && isAllDigits(kw)) {
|
if strings.HasPrefix(upper, "L") || (len(kw) >= 12 && isAllDigits(kw)) {
|
||||||
@@ -1594,6 +1617,9 @@ func (r *Repository) ListAvailableListings(ctx context.Context, query AvailableL
|
|||||||
if err := buildQuery().Select(`l.id, l.source_tenant_id,
|
if err := buildQuery().Select(`l.id, l.source_tenant_id,
|
||||||
COALESCE(source_tenant.code, '') AS source_tenant_code,
|
COALESCE(source_tenant.code, '') AS source_tenant_code,
|
||||||
COALESCE(source_tenant.name, '') AS source_tenant_name,
|
COALESCE(source_tenant.name, '') AS source_tenant_name,
|
||||||
|
COALESCE(source_site.id, 0) AS source_distribution_site_id,
|
||||||
|
COALESCE(source_site.site_code, '') AS source_distribution_site_code,
|
||||||
|
COALESCE(source_site.site_name, '') AS source_distribution_site_name,
|
||||||
l.listing_no, l.account_id, l.owner_id, l.price_cent AS listing_price_cent,
|
l.listing_no, l.account_id, l.owner_id, l.price_cent AS listing_price_cent,
|
||||||
a.title AS account_title, a.server_region, a.login_platform, a.haf_coin_amount, a.asset_summary,
|
a.title AS account_title, a.server_region, a.login_platform, a.haf_coin_amount, a.asset_summary,
|
||||||
owner.phone AS owner_phone, l.handoff_mode, l.settlement_mode,
|
owner.phone AS owner_phone, l.handoff_mode, l.settlement_mode,
|
||||||
@@ -1627,13 +1653,17 @@ func (r *Repository) baseQuery(ctx context.Context) *gorm.DB {
|
|||||||
COALESCE(pickup_tenant.name, '') AS tenant_name,
|
COALESCE(pickup_tenant.name, '') AS tenant_name,
|
||||||
COALESCE(source_tenant.code, '') AS source_tenant_code,
|
COALESCE(source_tenant.code, '') AS source_tenant_code,
|
||||||
COALESCE(source_tenant.name, '') AS source_tenant_name,
|
COALESCE(source_tenant.name, '') AS source_tenant_name,
|
||||||
|
COALESCE(source_site.id, 0) AS source_distribution_site_id,
|
||||||
|
COALESCE(source_site.site_code, '') AS source_distribution_site_code,
|
||||||
|
COALESCE(source_site.site_name, '') AS source_distribution_site_name,
|
||||||
COALESCE((SELECT SUM(fa.profit_delta_cent) FROM admin_pickup_financial_adjustments AS fa WHERE fa.pickup_id = p.id), 0) AS profit_adjustment_cent,
|
COALESCE((SELECT SUM(fa.profit_delta_cent) FROM admin_pickup_financial_adjustments AS fa WHERE fa.pickup_id = p.id), 0) AS profit_adjustment_cent,
|
||||||
COALESCE((SELECT SUM(fa.settle_delta_cent) FROM admin_pickup_financial_adjustments AS fa WHERE fa.pickup_id = p.id), 0) AS settle_adjustment_cent`).
|
COALESCE((SELECT SUM(fa.settle_delta_cent) FROM admin_pickup_financial_adjustments AS fa WHERE fa.pickup_id = p.id), 0) AS settle_adjustment_cent`).
|
||||||
Joins("JOIN rental_listings AS l ON l.id = p.listing_id").
|
Joins("JOIN rental_listings AS l ON l.id = p.listing_id").
|
||||||
Joins("JOIN game_accounts AS a ON a.id = p.account_id").
|
Joins("JOIN game_accounts AS a ON a.id = p.account_id").
|
||||||
Joins("JOIN users AS owner ON owner.id = p.owner_id").
|
Joins("JOIN users AS owner ON owner.id = p.owner_id").
|
||||||
Joins("LEFT JOIN tenants AS pickup_tenant ON pickup_tenant.id = p.tenant_id").
|
Joins("LEFT JOIN tenants AS pickup_tenant ON pickup_tenant.id = p.tenant_id").
|
||||||
Joins("LEFT JOIN tenants AS source_tenant ON source_tenant.id = p.source_tenant_id")
|
Joins("LEFT JOIN tenants AS source_tenant ON source_tenant.id = p.source_tenant_id").
|
||||||
|
Joins("LEFT JOIN distribution_sites AS source_site ON source_site.id = l.distribution_site_id")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repository) adminBaseQuery(ctx context.Context) *gorm.DB {
|
func (r *Repository) adminBaseQuery(ctx context.Context) *gorm.DB {
|
||||||
@@ -1642,72 +1672,78 @@ func (r *Repository) adminBaseQuery(ctx context.Context) *gorm.DB {
|
|||||||
|
|
||||||
type pickupRow struct {
|
type pickupRow struct {
|
||||||
model.AdminPickup
|
model.AdminPickup
|
||||||
TenantCode string
|
TenantCode string
|
||||||
TenantName string
|
TenantName string
|
||||||
SourceTenantCode string
|
SourceTenantCode string
|
||||||
SourceTenantName string
|
SourceTenantName string
|
||||||
ListingNo string
|
SourceDistributionSiteID uint64
|
||||||
AccountTitle string
|
SourceDistributionSiteCode string
|
||||||
ServerRegion string
|
SourceDistributionSiteName string
|
||||||
LoginPlatform string
|
ListingNo string
|
||||||
OwnerPhone string
|
AccountTitle string
|
||||||
ProfitAdjustmentCent int64
|
ServerRegion string
|
||||||
SettleAdjustmentCent int64
|
LoginPlatform string
|
||||||
|
OwnerPhone string
|
||||||
|
ProfitAdjustmentCent int64
|
||||||
|
SettleAdjustmentCent int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (row pickupRow) toDTO() PickupDTO {
|
func (row pickupRow) toDTO() PickupDTO {
|
||||||
return PickupDTO{
|
return PickupDTO{
|
||||||
ID: row.ID,
|
ID: row.ID,
|
||||||
TenantID: row.TenantID,
|
TenantID: row.TenantID,
|
||||||
TenantCode: row.TenantCode,
|
TenantCode: row.TenantCode,
|
||||||
TenantName: row.TenantName,
|
TenantName: row.TenantName,
|
||||||
SourceTenantID: row.SourceTenantID,
|
SourceTenantID: row.SourceTenantID,
|
||||||
SourceTenantCode: row.SourceTenantCode,
|
SourceTenantCode: row.SourceTenantCode,
|
||||||
SourceTenantName: row.SourceTenantName,
|
SourceTenantName: row.SourceTenantName,
|
||||||
IsCrossTenant: row.TenantID > 0 && row.SourceTenantID > 0 && row.TenantID != row.SourceTenantID,
|
SourceDistributionSiteID: row.SourceDistributionSiteID,
|
||||||
PickupNo: row.PickupNo,
|
SourceDistributionSiteCode: row.SourceDistributionSiteCode,
|
||||||
ListingID: row.ListingID,
|
SourceDistributionSiteName: row.SourceDistributionSiteName,
|
||||||
ListingNo: row.ListingNo,
|
IsCrossTenant: row.TenantID > 0 && row.SourceTenantID > 0 && row.TenantID != row.SourceTenantID,
|
||||||
AccountID: row.AccountID,
|
PickupNo: row.PickupNo,
|
||||||
AccountTitle: row.AccountTitle,
|
ListingID: row.ListingID,
|
||||||
ServerRegion: row.ServerRegion,
|
ListingNo: row.ListingNo,
|
||||||
LoginPlatform: row.LoginPlatform,
|
AccountID: row.AccountID,
|
||||||
OwnerID: row.OwnerID,
|
AccountTitle: row.AccountTitle,
|
||||||
OwnerPhone: row.OwnerPhone,
|
ServerRegion: row.ServerRegion,
|
||||||
AdminID: row.AdminID,
|
LoginPlatform: row.LoginPlatform,
|
||||||
Operator: row.Operator,
|
OwnerID: row.OwnerID,
|
||||||
Platform: row.Platform,
|
OwnerPhone: row.OwnerPhone,
|
||||||
ThirdPartyOrderNo: row.ThirdPartyOrderNo,
|
AdminID: row.AdminID,
|
||||||
ShopName: row.ShopName,
|
Operator: row.Operator,
|
||||||
RawShopName: row.RawShopName,
|
Platform: row.Platform,
|
||||||
AccountSource: row.AccountSource,
|
ThirdPartyOrderNo: row.ThirdPartyOrderNo,
|
||||||
SourceChannel: row.SourceChannel,
|
ShopName: row.ShopName,
|
||||||
SettlementMode: row.SettlementMode,
|
RawShopName: row.RawShopName,
|
||||||
ListingPriceCent: row.ListingPriceCent,
|
AccountSource: row.AccountSource,
|
||||||
OrderAmountCent: row.OrderAmountCent,
|
SourceChannel: row.SourceChannel,
|
||||||
DepositAmountCent: row.DepositAmountCent,
|
SettlementMode: row.SettlementMode,
|
||||||
OwnerPriceCent: row.OwnerPriceCent,
|
ListingPriceCent: row.ListingPriceCent,
|
||||||
WebsiteProfitCent: row.WebsiteProfitCent,
|
OrderAmountCent: row.OrderAmountCent,
|
||||||
ProfitAmountCent: row.ProfitAmountCent,
|
DepositAmountCent: row.DepositAmountCent,
|
||||||
ProfitAdjustmentCent: row.ProfitAdjustmentCent,
|
OwnerPriceCent: row.OwnerPriceCent,
|
||||||
EffectiveProfitAmountCent: row.ProfitAmountCent + row.ProfitAdjustmentCent,
|
WebsiteProfitCent: row.WebsiteProfitCent,
|
||||||
SellerRatio: row.SellerRatio,
|
ProfitAmountCent: row.ProfitAmountCent,
|
||||||
BuyerRatio: row.BuyerRatio,
|
ProfitAdjustmentCent: row.ProfitAdjustmentCent,
|
||||||
AccountSnapshot: row.AccountSnapshot,
|
EffectiveProfitAmountCent: row.ProfitAmountCent + row.ProfitAdjustmentCent,
|
||||||
SettleAmountCent: row.SettleAmountCent,
|
SellerRatio: row.SellerRatio,
|
||||||
SettleAdjustmentCent: row.SettleAdjustmentCent,
|
BuyerRatio: row.BuyerRatio,
|
||||||
EffectiveSettleAmountCent: row.SettleAmountCent + row.SettleAdjustmentCent,
|
AccountSnapshot: row.AccountSnapshot,
|
||||||
Status: row.Status,
|
SettleAmountCent: row.SettleAmountCent,
|
||||||
OfflineSettlementStatus: row.OfflineSettlementStatus,
|
SettleAdjustmentCent: row.SettleAdjustmentCent,
|
||||||
OfflineSettlementRemark: row.OfflineSettlementRemark,
|
EffectiveSettleAmountCent: row.SettleAmountCent + row.SettleAdjustmentCent,
|
||||||
ActualPayoutOperator: row.ActualPayoutOperator,
|
Status: row.Status,
|
||||||
OfflineSettledBy: row.OfflineSettledBy,
|
OfflineSettlementStatus: row.OfflineSettlementStatus,
|
||||||
OfflineSettledAt: row.OfflineSettledAt,
|
OfflineSettlementRemark: row.OfflineSettlementRemark,
|
||||||
Remark: row.Remark,
|
ActualPayoutOperator: row.ActualPayoutOperator,
|
||||||
CompleteRemark: row.CompleteRemark,
|
OfflineSettledBy: row.OfflineSettledBy,
|
||||||
CreatedAt: row.CreatedAt,
|
OfflineSettledAt: row.OfflineSettledAt,
|
||||||
CompletedAt: row.CompletedAt,
|
Remark: row.Remark,
|
||||||
CancelledAt: row.CancelledAt,
|
CompleteRemark: row.CompleteRemark,
|
||||||
|
CreatedAt: row.CreatedAt,
|
||||||
|
CompletedAt: row.CompletedAt,
|
||||||
|
CancelledAt: row.CancelledAt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1751,25 +1787,35 @@ func pickupRequiresOfflineSettlement(pickup model.AdminPickup) bool {
|
|||||||
return pickup.SettlementMode == SettlementModePlatformManaged
|
return pickup.SettlementMode == SettlementModePlatformManaged
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func pickupDistributionSiteID(listing model.RentalListing) uint64 {
|
||||||
|
if listing.DistributionSiteID == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return *listing.DistributionSiteID
|
||||||
|
}
|
||||||
|
|
||||||
type availableListingRow struct {
|
type availableListingRow struct {
|
||||||
ID uint64
|
ID uint64
|
||||||
SourceTenantID uint64
|
SourceTenantID uint64
|
||||||
SourceTenantCode string
|
SourceTenantCode string
|
||||||
SourceTenantName string
|
SourceTenantName string
|
||||||
ListingNo string
|
SourceDistributionSiteID uint64
|
||||||
AccountID uint64
|
SourceDistributionSiteCode string
|
||||||
AccountTitle string
|
SourceDistributionSiteName string
|
||||||
ServerRegion string
|
ListingNo string
|
||||||
LoginPlatform string
|
AccountID uint64
|
||||||
OwnerID uint64
|
AccountTitle string
|
||||||
OwnerPhone string
|
ServerRegion string
|
||||||
ListingPriceCent int64
|
LoginPlatform string
|
||||||
HafCoinAmount int64
|
OwnerID uint64
|
||||||
AssetSummary datatypes.JSON
|
OwnerPhone string
|
||||||
IsExternalUpload bool
|
ListingPriceCent int64
|
||||||
SourceChannel string
|
HafCoinAmount int64
|
||||||
HandoffMode string
|
AssetSummary datatypes.JSON
|
||||||
SettlementMode string
|
IsExternalUpload bool
|
||||||
|
SourceChannel string
|
||||||
|
HandoffMode string
|
||||||
|
SettlementMode string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (row availableListingRow) toDTO() AvailableListingDTO {
|
func (row availableListingRow) toDTO() AvailableListingDTO {
|
||||||
@@ -1782,30 +1828,33 @@ func (row availableListingRow) toDTO() AvailableListingDTO {
|
|||||||
accountSource = AccountSourceExternalPlatformManaged
|
accountSource = AccountSourceExternalPlatformManaged
|
||||||
}
|
}
|
||||||
return AvailableListingDTO{
|
return AvailableListingDTO{
|
||||||
ID: row.ID,
|
ID: row.ID,
|
||||||
SourceTenantID: row.SourceTenantID,
|
SourceTenantID: row.SourceTenantID,
|
||||||
SourceTenantCode: row.SourceTenantCode,
|
SourceTenantCode: row.SourceTenantCode,
|
||||||
SourceTenantName: row.SourceTenantName,
|
SourceTenantName: row.SourceTenantName,
|
||||||
ListingNo: row.ListingNo,
|
SourceDistributionSiteID: row.SourceDistributionSiteID,
|
||||||
AccountID: row.AccountID,
|
SourceDistributionSiteCode: row.SourceDistributionSiteCode,
|
||||||
AccountTitle: row.AccountTitle,
|
SourceDistributionSiteName: row.SourceDistributionSiteName,
|
||||||
ServerRegion: row.ServerRegion,
|
ListingNo: row.ListingNo,
|
||||||
LoginPlatform: row.LoginPlatform,
|
AccountID: row.AccountID,
|
||||||
OwnerID: row.OwnerID,
|
AccountTitle: row.AccountTitle,
|
||||||
OwnerPhone: row.OwnerPhone,
|
ServerRegion: row.ServerRegion,
|
||||||
ListingPriceCent: snapshot.ListingPriceCent,
|
LoginPlatform: row.LoginPlatform,
|
||||||
OwnerPriceCent: snapshot.OwnerPriceCent,
|
OwnerID: row.OwnerID,
|
||||||
OwnerPurePriceCent: snapshot.OwnerPurePriceCent,
|
OwnerPhone: row.OwnerPhone,
|
||||||
OwnerExtraItemPriceCent: snapshot.OwnerExtraItemPriceCent,
|
ListingPriceCent: snapshot.ListingPriceCent,
|
||||||
OwnerTotalPriceCent: snapshot.OwnerTotalPriceCent,
|
OwnerPriceCent: snapshot.OwnerPriceCent,
|
||||||
WebsiteProfitCent: snapshot.WebsiteProfitCent,
|
OwnerPurePriceCent: snapshot.OwnerPurePriceCent,
|
||||||
SellerRatio: snapshot.SellerRatio,
|
OwnerExtraItemPriceCent: snapshot.OwnerExtraItemPriceCent,
|
||||||
BuyerRatio: snapshot.BuyerRatio,
|
OwnerTotalPriceCent: snapshot.OwnerTotalPriceCent,
|
||||||
AccountSource: accountSource,
|
WebsiteProfitCent: snapshot.WebsiteProfitCent,
|
||||||
IsExternalUpload: row.IsExternalUpload,
|
SellerRatio: snapshot.SellerRatio,
|
||||||
SourceChannel: row.SourceChannel,
|
BuyerRatio: snapshot.BuyerRatio,
|
||||||
HandoffMode: row.HandoffMode,
|
AccountSource: accountSource,
|
||||||
SettlementMode: row.SettlementMode,
|
IsExternalUpload: row.IsExternalUpload,
|
||||||
|
SourceChannel: row.SourceChannel,
|
||||||
|
HandoffMode: row.HandoffMode,
|
||||||
|
SettlementMode: row.SettlementMode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,47 @@ func seedPickupTenantListing(t *testing.T, db *gorm.DB, tenantID uint64, suffix
|
|||||||
return listing
|
return listing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func seedPickupDistributionListing(t *testing.T, db *gorm.DB, tenantID, siteID uint64, suffix string) model.RentalListing {
|
||||||
|
t.Helper()
|
||||||
|
owner := model.User{
|
||||||
|
TenantID: tenantID,
|
||||||
|
DistributionSiteID: siteID,
|
||||||
|
Phone: "1890000" + suffix,
|
||||||
|
Nickname: "分销号主" + suffix,
|
||||||
|
Status: "active",
|
||||||
|
}
|
||||||
|
if err := db.Create(&owner).Error; err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
account := model.GameAccount{
|
||||||
|
SourceTenantID: tenantID,
|
||||||
|
OwnerID: owner.ID,
|
||||||
|
ServerRegion: "测试区",
|
||||||
|
LoginPlatform: "微信",
|
||||||
|
Title: "天域账号" + suffix,
|
||||||
|
Status: "published",
|
||||||
|
}
|
||||||
|
if err := db.Create(&account).Error; err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
listing := model.RentalListing{
|
||||||
|
SourceTenantID: tenantID,
|
||||||
|
ListingNo: "LST-PICKUP-DIST-" + suffix,
|
||||||
|
AccountID: account.ID,
|
||||||
|
OwnerID: owner.ID,
|
||||||
|
PriceCent: 12000,
|
||||||
|
Status: "published",
|
||||||
|
ReviewStatus: "approved",
|
||||||
|
HandoffMode: "owner",
|
||||||
|
SettlementMode: "owner_wallet",
|
||||||
|
DistributionSiteID: &siteID,
|
||||||
|
}
|
||||||
|
if err := db.Create(&listing).Error; err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
return listing
|
||||||
|
}
|
||||||
|
|
||||||
func TestPickupTenantScopeSupportsCrossTenantCreationAndSeparateLists(t *testing.T) {
|
func TestPickupTenantScopeSupportsCrossTenantCreationAndSeparateLists(t *testing.T) {
|
||||||
db := database.NewTestDB()
|
db := database.NewTestDB()
|
||||||
tenants := []model.Tenant{
|
tenants := []model.Tenant{
|
||||||
@@ -150,6 +191,110 @@ func TestPickupTenantScopeSupportsCrossTenantCreationAndSeparateLists(t *testing
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPickupSupportsSharedDistributionSourceAcrossTenants(t *testing.T) {
|
||||||
|
db := database.NewTestDB()
|
||||||
|
tenants := []model.Tenant{
|
||||||
|
{Code: "pickup_dist_source", Name: "货源站", Status: "active"},
|
||||||
|
{Code: "pickup_dist_a", Name: "提号A站", Status: "active"},
|
||||||
|
{Code: "pickup_dist_b", Name: "提号B站", Status: "active"},
|
||||||
|
{Code: "pickup_dist_other", Name: "未铺货站", Status: "active"},
|
||||||
|
}
|
||||||
|
if err := db.Create(&tenants).Error; err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
site := model.DistributionSite{
|
||||||
|
SiteCode: "tianyu_pickup",
|
||||||
|
SiteName: "天域商行",
|
||||||
|
Domain: "tianyu-pickup.example.com",
|
||||||
|
Status: "active",
|
||||||
|
}
|
||||||
|
if err := db.Create(&site).Error; err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
sourceTenant, tenantA, tenantB, otherTenant := tenants[0], tenants[1], tenants[2], tenants[3]
|
||||||
|
listing := seedPickupDistributionListing(t, db, sourceTenant.ID, site.ID, "01")
|
||||||
|
listingNumber := "202611230328"
|
||||||
|
if err := db.Model(&listing).Update("listing_no", listingNumber).Error; err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := db.Create(&[]model.TenantListingOffer{
|
||||||
|
{TenantID: tenantA.ID, ListingID: listing.ID, DisplayStatus: "enabled"},
|
||||||
|
{TenantID: tenantB.ID, ListingID: listing.ID, DisplayStatus: "enabled"},
|
||||||
|
}).Error; err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
repo := NewRepository(db)
|
||||||
|
for _, tc := range []struct {
|
||||||
|
name string
|
||||||
|
ctx context.Context
|
||||||
|
crossTenant bool
|
||||||
|
}{
|
||||||
|
{name: "A站", ctx: pickupTenantContext(tenantA.ID), crossTenant: true},
|
||||||
|
{name: "B站", ctx: pickupTenantContext(tenantB.ID), crossTenant: true},
|
||||||
|
} {
|
||||||
|
available, err := repo.ListAvailableListings(tc.ctx, AvailableListingQuery{
|
||||||
|
Keyword: listingNumber,
|
||||||
|
Page: 1,
|
||||||
|
PageSize: 20,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("%s 查询可提号商品: %v", tc.name, err)
|
||||||
|
}
|
||||||
|
if len(available.Items) != 1 {
|
||||||
|
t.Fatalf("%s 可提号商品 = %+v, want 天域商品", tc.name, available.Items)
|
||||||
|
}
|
||||||
|
item := available.Items[0]
|
||||||
|
if item.ID != listing.ID ||
|
||||||
|
item.SourceDistributionSiteID != site.ID ||
|
||||||
|
item.SourceDistributionSiteName != site.SiteName ||
|
||||||
|
item.IsCrossTenant != tc.crossTenant {
|
||||||
|
t.Fatalf("%s 天域货源快照 = %+v", tc.name, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
otherAvailable, err := repo.ListAvailableListings(pickupTenantContext(otherTenant.ID), AvailableListingQuery{Page: 1, PageSize: 20})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(otherAvailable.Items) != 0 {
|
||||||
|
t.Fatalf("未铺货经营租户看到了天域商品: %+v", otherAvailable.Items)
|
||||||
|
}
|
||||||
|
|
||||||
|
pickup, err := repo.Create(pickupTenantContext(tenantB.ID), CreateRequest{ListingID: listing.ID}, 9, auditlog.Meta{})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("从 B 站创建天域货源提号: %v", err)
|
||||||
|
}
|
||||||
|
if _, err := repo.Complete(pickupTenantContext(tenantB.ID), pickup.ID, CompleteRequest{
|
||||||
|
SettleAmountCent: 8000,
|
||||||
|
}, 9, auditlog.Meta{}); err != nil {
|
||||||
|
t.Fatalf("完成天域货源提号: %v", err)
|
||||||
|
}
|
||||||
|
var ledger model.WalletLedger
|
||||||
|
if err := db.Where("biz_type = ? AND biz_no = ?", "admin_pickup_settle", pickup.PickupNo).First(&ledger).Error; err != nil {
|
||||||
|
t.Fatalf("查询天域货源结算流水: %v", err)
|
||||||
|
}
|
||||||
|
if ledger.TenantID != sourceTenant.ID || ledger.DistributionSiteID != site.ID {
|
||||||
|
t.Fatalf("天域货源结算流水归属 = %+v, want tenant=%d site=%d", ledger, sourceTenant.ID, site.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
adjustedSettleAmount := int64(9000)
|
||||||
|
if _, err := repo.CreateFinancialAdjustment(pickupTenantContext(tenantB.ID), pickup.ID, FinancialAdjustmentRequest{
|
||||||
|
SettleAmountCent: &adjustedSettleAmount,
|
||||||
|
Reason: "补发天域货源结算差额",
|
||||||
|
}, 9, auditlog.Meta{}); err != nil {
|
||||||
|
t.Fatalf("创建天域货源结算补款: %v", err)
|
||||||
|
}
|
||||||
|
var adjustmentLedger model.WalletLedger
|
||||||
|
if err := db.Where("biz_type = ? AND biz_no LIKE ?", "admin_pickup_adjustment", pickup.PickupNo+"-A%").
|
||||||
|
First(&adjustmentLedger).Error; err != nil {
|
||||||
|
t.Fatalf("查询天域货源补款流水: %v", err)
|
||||||
|
}
|
||||||
|
if adjustmentLedger.TenantID != sourceTenant.ID || adjustmentLedger.DistributionSiteID != site.ID {
|
||||||
|
t.Fatalf("天域货源补款流水归属 = %+v, want tenant=%d site=%d", adjustmentLedger, sourceTenant.ID, site.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestPickupShopsAreSeparatedByTenant(t *testing.T) {
|
func TestPickupShopsAreSeparatedByTenant(t *testing.T) {
|
||||||
db := database.NewTestDB()
|
db := database.NewTestDB()
|
||||||
tenants := []model.Tenant{
|
tenants := []model.Tenant{
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ export interface AdminPickup {
|
|||||||
source_tenant_id: number
|
source_tenant_id: number
|
||||||
source_tenant_code: string
|
source_tenant_code: string
|
||||||
source_tenant_name: string
|
source_tenant_name: string
|
||||||
|
source_distribution_site_id: number
|
||||||
|
source_distribution_site_code: string
|
||||||
|
source_distribution_site_name: string
|
||||||
is_cross_tenant: boolean
|
is_cross_tenant: boolean
|
||||||
pickup_no: string
|
pickup_no: string
|
||||||
listing_id: number
|
listing_id: number
|
||||||
@@ -101,6 +104,9 @@ export interface AvailableListing {
|
|||||||
source_tenant_id: number
|
source_tenant_id: number
|
||||||
source_tenant_code: string
|
source_tenant_code: string
|
||||||
source_tenant_name: string
|
source_tenant_name: string
|
||||||
|
source_distribution_site_id: number
|
||||||
|
source_distribution_site_code: string
|
||||||
|
source_distribution_site_name: string
|
||||||
is_cross_tenant: boolean
|
is_cross_tenant: boolean
|
||||||
listing_no: string
|
listing_no: string
|
||||||
account_id: number
|
account_id: number
|
||||||
|
|||||||
@@ -609,11 +609,19 @@ function siteName(code: string, name: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pickupSiteText(row: AdminPickup) {
|
function pickupSiteText(row: AdminPickup) {
|
||||||
|
if (row.source_distribution_site_id > 0) {
|
||||||
|
const source = siteName(row.source_distribution_site_code, row.source_distribution_site_name)
|
||||||
|
return row.is_cross_tenant ? `跨站 · ${source}` : `本站 · ${source}`
|
||||||
|
}
|
||||||
if (!row.is_cross_tenant) return '本站货源'
|
if (!row.is_cross_tenant) return '本站货源'
|
||||||
return `跨站 · ${siteName(row.source_tenant_code, row.source_tenant_name)}`
|
return `跨站 · ${siteName(row.source_tenant_code, row.source_tenant_name)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function listingSiteText(item: AvailableListing) {
|
function listingSiteText(item: AvailableListing) {
|
||||||
|
if (item.source_distribution_site_id > 0) {
|
||||||
|
const source = siteName(item.source_distribution_site_code, item.source_distribution_site_name)
|
||||||
|
return item.is_cross_tenant ? `跨站 · ${source}` : `本站 · ${source}`
|
||||||
|
}
|
||||||
const source = siteName(item.source_tenant_code, item.source_tenant_name)
|
const source = siteName(item.source_tenant_code, item.source_tenant_name)
|
||||||
return item.is_cross_tenant ? `跨站 · ${source}` : `本站 · ${source}`
|
return item.is_cross_tenant ? `跨站 · ${source}` : `本站 · ${source}`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user