package dispute

import (
	"time"

	"hfb_sys/backend/internal/auditlog"

	"gorm.io/datatypes"
)

type DisputeDTO struct {
	ID                       uint64         `json:"id"`
	OrderID                  uint64         `json:"order_id"`
	OrderNo                  string         `json:"order_no"`
	OrderStatus              string         `json:"order_status"`
	HandoffStatus            string         `json:"handoff_status"`
	SettlementStatus         string         `json:"settlement_status"`
	ListingNo                string         `json:"listing_no"`
	Title                    string         `json:"title"`
	OwnerID                  uint64         `json:"owner_id"`
	RenterID                 uint64         `json:"renter_id"`
	OwnerPhone               string         `json:"owner_phone"`
	RenterPhone              string         `json:"renter_phone"`
	InitiatorID              uint64         `json:"initiator_id"`
	TargetUserID             uint64         `json:"target_user_id"`
	Type                     string         `json:"type"`
	Status                   string         `json:"status"`
	Description              string         `json:"description"`
	EvidenceURLS             datatypes.JSON `json:"evidence_urls"`
	PreviousOrderStatus      string         `json:"previous_order_status"`
	PreviousHandoffStatus    string         `json:"previous_handoff_status"`
	PreviousSettlementStatus string         `json:"previous_settlement_status"`
	CheckoutID               *uint64        `json:"checkout_id"`
	PreviousCheckoutStatus   string         `json:"previous_checkout_status"`
	ArbitrationResult        string         `json:"arbitration_result"`
	ArbitrationRemark        string         `json:"arbitration_remark"`
	HandledBy                *uint64        `json:"handled_by"`
	HandledAt                *time.Time     `json:"handled_at"`
	CreatedAt                time.Time      `json:"created_at"`
	UpdatedAt                time.Time      `json:"updated_at"`
}

type CreateRequest struct {
	Type         string   `json:"type" binding:"required"`
	Description  string   `json:"description" binding:"required"`
	EvidenceURLS []string `json:"evidence_urls"`
}

type ArbitrateRequest struct {
	Result     string `json:"result" binding:"required"`
	Remark     string `json:"remark" binding:"required"`
	AmountCent int64  `json:"amount_cent"`
}

type AdminListQuery struct {
	Page     int
	PageSize int
	Keyword  string
	Status   string
	Type     string
}

type AuditMeta = auditlog.Meta

type PaginatedResult struct {
	Items    []DisputeDTO `json:"items"`
	Total    int64        `json:"total"`
	Page     int          `json:"page"`
	PageSize int          `json:"page_size"`
}
