package model

import (
	"time"

	"gorm.io/datatypes"
)

// AdminPickup 管理员线下提号记录。
// 独立于 rental_orders，不进入正常订单状态机与财务统计口径，
// 完成时通过 wallet.AppendEntries 给卖家增加可用余额。
type AdminPickup struct {
	ID                uint64         `gorm:"primaryKey" json:"id"`
	PickupNo          string         `gorm:"size:64;not null;uniqueIndex" json:"pickup_no"`
	ListingID         uint64         `gorm:"not null;index" json:"listing_id"`
	AccountID         uint64         `gorm:"not null;index" json:"account_id"`
	OwnerID           uint64         `gorm:"not null;index" json:"owner_id"`
	AdminID           uint64         `gorm:"not null" json:"admin_id"`
	Platform          string         `gorm:"size:32;not null;default:''" json:"platform"`
	ListingPriceCent  int64          `gorm:"not null;default:0" json:"listing_price_cent"`
	OwnerPriceCent    int64          `gorm:"not null;default:0" json:"owner_price_cent"`
	WebsiteProfitCent int64          `gorm:"not null;default:0" json:"website_profit_cent"`
	ProfitAmountCent  int64          `gorm:"not null;default:0" json:"profit_amount_cent"`
	SellerRatio       float64        `gorm:"type:decimal(10,2);not null;default:0" json:"seller_ratio"`
	BuyerRatio        float64        `gorm:"type:decimal(10,2);not null;default:0" json:"buyer_ratio"`
	AccountSnapshot   datatypes.JSON `json:"account_snapshot,omitempty"`
	SettleAmountCent  int64          `gorm:"not null;default:0" json:"settle_amount_cent"`
	Status            string         `gorm:"size:20;not null;default:'picking_up';index" json:"status"`
	Remark            string         `gorm:"size:255;not null;default:''" json:"remark"`
	CompleteRemark    string         `gorm:"size:255;not null;default:''" json:"complete_remark"`
	CreatedAt         time.Time      `json:"created_at"`
	CompletedAt       *time.Time     `json:"completed_at,omitempty"`
	CancelledAt       *time.Time     `json:"cancelled_at,omitempty"`
}

func (AdminPickup) TableName() string {
	return "admin_pickups"
}
