package model

import (
	"time"

	"gorm.io/datatypes"
)

type OrderCheckout struct {
	ID                      uint64         `gorm:"primaryKey" json:"id"`
	OrderID                 uint64         `gorm:"not null;index" json:"order_id"`
	InitiatedBy             uint64         `gorm:"not null" json:"initiated_by"`
	Status                  string         `gorm:"size:32;not null;default:'submitted'" json:"status"`
	RentAmountCent          int64          `gorm:"not null;default:0" json:"-"`
	OwnerRentAmountCent     int64          `gorm:"not null;default:0" json:"-"`
	PlatformFeeCent         int64          `gorm:"not null;default:0" json:"-"`
	DepositAmountCent       int64          `gorm:"not null;default:0" json:"-"`
	ConsumableAmountCent    int64          `gorm:"not null;default:0" json:"-"`
	CoinConsumedM           float64        `gorm:"type:decimal(12,2);not null;default:0" json:"coin_consumed_m"`
	OtherAmountCent         int64          `gorm:"not null;default:0" json:"-"`
	DepositDeductAmountCent int64          `gorm:"not null;default:0" json:"-"`
	RenterRefundAmountCent  int64          `gorm:"not null;default:0" json:"-"`
	OwnerIncomeAmountCent   int64          `gorm:"not null;default:0" json:"-"`
	Content                 string         `json:"content"`
	EvidenceURLS            datatypes.JSON `gorm:"column:evidence_urls" json:"evidence_urls"`
	OwnerAdjustmentReason   string         `json:"owner_adjustment_reason"`
	OwnerAdjustedAt         *time.Time     `json:"owner_adjusted_at"`
	RenterConfirmedAt       *time.Time     `json:"renter_confirmed_at"`
	RenterRejectedAt        *time.Time     `json:"renter_rejected_at"`
	CreatedAt               time.Time      `json:"created_at"`
	UpdatedAt               time.Time      `json:"updated_at"`
}

func (OrderCheckout) TableName() string {
	return "order_checkouts"
}
