197 lines
8.0 KiB
Go
197 lines
8.0 KiB
Go
package pickup
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
|
|
"gorm.io/datatypes"
|
|
)
|
|
|
|
// 提号状态
|
|
const (
|
|
StatusPickingUp = "picking_up"
|
|
StatusCompleted = "completed"
|
|
StatusCancelled = "cancelled"
|
|
|
|
AccountSourceInternal = "internal"
|
|
AccountSourceExternalPlatformManaged = "external_platform_managed"
|
|
ListingSourceExternal = "external"
|
|
ListingSourceInternal = "internal"
|
|
SettlementModeOwnerWallet = "owner_wallet"
|
|
SettlementModePlatformManaged = "platform_managed"
|
|
OfflineSettlementStatusNone = "none"
|
|
OfflineSettlementStatusPending = "pending"
|
|
OfflineSettlementStatusSettled = "settled"
|
|
FinancialAdjustmentStatusSettled = "settled"
|
|
FinancialAdjustmentStatusPending = "pending"
|
|
FinancialAdjustmentStatusRecovery = "recovery_pending"
|
|
)
|
|
|
|
var (
|
|
ErrDependencyUnavailable = errors.New("dependency unavailable")
|
|
ErrListingUnavailable = errors.New("listing unavailable")
|
|
ErrPickupNotFound = errors.New("pickup not found")
|
|
ErrPickupNotPickingUp = errors.New("pickup not in picking_up status")
|
|
ErrInvalidAmount = errors.New("invalid amount")
|
|
ErrInvalidProfit = errors.New("invalid profit amount")
|
|
ErrDuplicatePickup = errors.New("duplicate pickup in progress")
|
|
ErrOfflineSettlementCannotMark = errors.New("pickup offline settlement cannot be marked")
|
|
ErrFinancialAdjustmentInvalid = errors.New("financial adjustment invalid")
|
|
ErrFinancialAdjustmentNotFound = errors.New("financial adjustment not found")
|
|
ErrFinancialAdjustmentCannotSettle = errors.New("financial adjustment cannot be settled")
|
|
)
|
|
|
|
type PickupDTO struct {
|
|
ID uint64 `json:"id"`
|
|
PickupNo string `json:"pickup_no"`
|
|
ListingID uint64 `json:"listing_id"`
|
|
ListingNo string `json:"listing_no"`
|
|
AccountID uint64 `json:"account_id"`
|
|
AccountTitle string `json:"account_title"`
|
|
ServerRegion string `json:"server_region"`
|
|
LoginPlatform string `json:"login_platform"`
|
|
OwnerID uint64 `json:"owner_id"`
|
|
OwnerPhone string `json:"owner_phone"`
|
|
AdminID uint64 `json:"admin_id"`
|
|
Platform string `json:"platform"`
|
|
ShopName string `json:"shop_name"`
|
|
AccountSource string `json:"account_source"`
|
|
SourceChannel string `json:"source_channel"`
|
|
SettlementMode string `json:"settlement_mode"`
|
|
ListingPriceCent int64 `json:"listing_price_cent"`
|
|
OwnerPriceCent int64 `json:"owner_price_cent"`
|
|
WebsiteProfitCent int64 `json:"website_profit_cent"`
|
|
ProfitAmountCent int64 `json:"profit_amount_cent"`
|
|
ProfitAdjustmentCent int64 `json:"profit_adjustment_cent"`
|
|
EffectiveProfitAmountCent int64 `json:"effective_profit_amount_cent"`
|
|
SellerRatio float64 `json:"seller_ratio"`
|
|
BuyerRatio float64 `json:"buyer_ratio"`
|
|
AccountSnapshot datatypes.JSON `json:"account_snapshot,omitempty"`
|
|
SettleAmountCent int64 `json:"settle_amount_cent"`
|
|
SettleAdjustmentCent int64 `json:"settle_adjustment_cent"`
|
|
EffectiveSettleAmountCent int64 `json:"effective_settle_amount_cent"`
|
|
Status string `json:"status"`
|
|
OfflineSettlementStatus string `json:"offline_settlement_status"`
|
|
OfflineSettlementRemark string `json:"offline_settlement_remark"`
|
|
OfflineSettledBy *uint64 `json:"offline_settled_by,omitempty"`
|
|
OfflineSettledAt *time.Time `json:"offline_settled_at,omitempty"`
|
|
Remark string `json:"remark"`
|
|
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 {
|
|
ID uint64 `json:"id"`
|
|
PickupID uint64 `json:"pickup_id"`
|
|
ProfitDeltaCent int64 `json:"profit_delta_cent"`
|
|
SettleDeltaCent int64 `json:"settle_delta_cent"`
|
|
SettlementMode string `json:"settlement_mode"`
|
|
Status string `json:"status"`
|
|
Reason string `json:"reason"`
|
|
CreatedBy uint64 `json:"created_by"`
|
|
SettledBy *uint64 `json:"settled_by,omitempty"`
|
|
SettledAt *time.Time `json:"settled_at,omitempty"`
|
|
SettlementRemark string `json:"settlement_remark"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type CreateRequest struct {
|
|
ListingID uint64 `json:"listing_id" binding:"required"`
|
|
Platform string `json:"platform"`
|
|
ShopName string `json:"shop_name" binding:"max=100"`
|
|
ProfitAmountCent int64 `json:"profit_amount_cent"`
|
|
Remark string `json:"remark"`
|
|
}
|
|
|
|
type CompleteRequest struct {
|
|
SettleAmountCent int64 `json:"settle_amount_cent" binding:"required,min=1"`
|
|
ProfitAmountCent *int64 `json:"profit_amount_cent"`
|
|
CompleteRemark string `json:"complete_remark"`
|
|
}
|
|
|
|
type OfflineSettlementRequest struct {
|
|
Remark string `json:"remark" binding:"max=255"`
|
|
}
|
|
|
|
type UpdateProfitRequest struct {
|
|
ProfitAmountCent int64 `json:"profit_amount_cent" binding:"min=0"`
|
|
Reason string `json:"reason"`
|
|
}
|
|
|
|
// FinancialAdjustmentRequest 按目标金额创建完成后的差额流水,至少提供一个金额。
|
|
type FinancialAdjustmentRequest struct {
|
|
ProfitAmountCent *int64 `json:"profit_amount_cent"`
|
|
SettleAmountCent *int64 `json:"settle_amount_cent"`
|
|
Reason string `json:"reason" binding:"required,max=255"`
|
|
}
|
|
|
|
type FinancialAdjustmentSettlementRequest struct {
|
|
Remark string `json:"remark" binding:"max=255"`
|
|
}
|
|
|
|
type CancelRequest struct {
|
|
Reason string `json:"reason" binding:"required"`
|
|
}
|
|
|
|
type AdminPickupQuery struct {
|
|
Page int
|
|
PageSize int
|
|
Keyword string
|
|
Status string
|
|
ShopName string
|
|
AccountSource string
|
|
}
|
|
|
|
type SellerPickupQuery struct {
|
|
Page int
|
|
PageSize int
|
|
Status string
|
|
}
|
|
|
|
type AvailableListingDTO struct {
|
|
ID uint64 `json:"id"`
|
|
ListingNo string `json:"listing_no"`
|
|
AccountID uint64 `json:"account_id"`
|
|
AccountTitle string `json:"account_title"`
|
|
ServerRegion string `json:"server_region"`
|
|
LoginPlatform string `json:"login_platform"`
|
|
OwnerID uint64 `json:"owner_id"`
|
|
OwnerPhone string `json:"owner_phone"`
|
|
ListingPriceCent int64 `json:"listing_price_cent"`
|
|
OwnerPriceCent int64 `json:"owner_price_cent"`
|
|
OwnerPurePriceCent int64 `json:"owner_pure_price_cent"`
|
|
OwnerExtraItemPriceCent int64 `json:"owner_extra_item_price_cent"`
|
|
OwnerTotalPriceCent int64 `json:"owner_total_price_cent"`
|
|
WebsiteProfitCent int64 `json:"website_profit_cent"`
|
|
SellerRatio float64 `json:"seller_ratio"`
|
|
BuyerRatio float64 `json:"buyer_ratio"`
|
|
AccountSource string `json:"account_source"`
|
|
IsExternalUpload bool `json:"is_external_upload"`
|
|
SourceChannel string `json:"source_channel"`
|
|
HandoffMode string `json:"handoff_mode"`
|
|
SettlementMode string `json:"settlement_mode"`
|
|
}
|
|
|
|
type AvailableListingQuery struct {
|
|
Page int
|
|
PageSize int
|
|
Keyword string
|
|
SourceType string
|
|
}
|
|
|
|
type PaginatedResult struct {
|
|
Items []PickupDTO `json:"items"`
|
|
Total int64 `json:"total"`
|
|
Page int `json:"page"`
|
|
PageSize int `json:"page_size"`
|
|
}
|
|
|
|
type AvailableListingsResult struct {
|
|
Items []AvailableListingDTO `json:"items"`
|
|
Total int64 `json:"total"`
|
|
Page int `json:"page"`
|
|
PageSize int `json:"page_size"`
|
|
}
|