package dto

import (
	"time"

	"github.com/UpmeshLTD/urus-aio/infrastructure/common"
	"github.com/google/uuid"
)

type Fulfillment struct {
	ID           uuid.UUID      `json:"id"`
	Shipping     Shipping       `json:"shipping"`
	OrderDetails []*OrderDetail `json:"orderDetails"`
	PickupDetail PickupDetail   `json:"pickupDetail"`
	Step         int            `json:"step"`
	CreatedAt    time.Time      `json:"createdAt"`
	UpdatedAt    time.Time      `json:"updatedAt"`
}

type GetFulfillmentsRequest struct {
	Deactivate bool `form:"deactivate"`
	common.Pagination
}

type GetFulfillmentsResponse struct {
	Data  []*Fulfillment `json:"data"`
	Total int64          `json:"total"`
}

type GetFulfillmentRequest struct {
	ID string `uri:"id"`
}

type Shipping struct {
	CourierDeliveryPlanID *int64 `json:"courierDeliveryPlanId"`
	CourierID             *int64 `json:"courierId"`
}

type OrderDetail struct {
	ID              string  `json:"id"`
	CartID          string  `json:"cartId"`
	ShippingGroupID *string `json:"shippingGroupId"`

	Width        *float64 `json:"width"`
	Length       *float64 `json:"length"`
	Height       *float64 `json:"height"`
	Weight       *float64 `json:"weight"`
	EstimatedFee float64  `json:"estimatedFee"`

	AddressEditable       bool             `json:"addressEditable"`
	DeliveryPhoneEditable bool             `json:"deliveryPhoneEditable"`
	DeliveryAddress       *DeliveryAddress `json:"deliveryAddress"`
}

type UpdateOrderDetailRequest struct {
	ID              string   `json:"id"`
	CartID          string   `json:"cartId"`
	ShippingGroupID *string  `json:"shippingGroupId"`
	Width           *float64 `json:"width"`
	Length          *float64 `json:"length"`
	Height          *float64 `json:"height"`
	Weight          float64  `json:"weight"`
}

type PickupDetail struct {
	PickupPointID     *int64     `json:"pickupPointId"`
	PickupTime        *time.Time `json:"pickupTime"`
	PickupStartTime   *time.Time `json:"pickupStartTime"`
	PickupEndTime     *time.Time `json:"pickupEndTime"`
	PickupInstruction *string    `json:"pickupInstruction"`
}

type UpdateFulfillmentRequest struct {
	ID           string                      `uri:"id" swaggerignore:"true"`
	Shipping     *Shipping                   `json:"shipping"`
	OrderDetails []*UpdateOrderDetailRequest `json:"orderDetails"`
	PickupDetail *PickupDetail               `json:"pickupDetail"`
	Step         int                         `json:"step"`
}

type DeleteFulfillmentRequest struct {
	ID string `uri:"id"`
}

type DeleteFulfillmentOrderRequest struct {
	FulfillmentID   string  `uri:"id" swaggerignore:"true"`
	CartID          string  `json:"cartId"`
	ShippingGroupID *string `json:"shippingGroupId"`
}

type DeleteOrderFromFulfillmentRequest struct {
	FulfillmentID string `uri:"id"`
	PaidOrderID   string `uri:"paidOrderId"`
}

type GetNotFulfillPaidOrdersRequest struct {
	CartIDs []string `json:"cartIds"`
}

type GetNotFulfillPaidOrdersResponse struct {
	CartIDs []string `json:"cartIds"`
}

type GetFulfillmentEstimatedFeeRequest struct {
	CourierDeliveryPlanID int64                                 `json:"courierDeliveryPlanId"`
	Dimensions            []GetFulfillmentEstimatedFeeDimension `json:"dimensions"`
}

type GetFulfillmentEstimatedFeeDimension struct {
	ID           string  `json:"id"`
	Width        float64 `json:"width"`
	Length       float64 `json:"length"`
	Height       float64 `json:"height"`
	Weight       float64 `json:"weight"`
	EstimatedFee float64 `json:"estimatedFee"`
}

type GetFulfillmentEstimatedFeeResponse struct {
	CourierDeliveryPlanID int64                                 `json:"courierDeliveryPlanId"`
	Dimensions            []GetFulfillmentEstimatedFeeDimension `json:"dimensions"`
	TotalFee              float64                               `json:"totalFee"`
}

type CreateFulfillmentRequest struct {
	PaidOrderIDs []string `json:"paidOrderIds"`
}

type CreateFulfillmentResponse struct {
	FulfillmentID string `json:"fulfillmentId"`
}

type CreateFulfillmentFromDraftRequest struct {
	FulfillmentID string   `uri:"id" swaggerignore:"true"`
	PaidOrderIDs  []string `json:"paidOrderIds"`
}

type CreateFulfillmentFromDraftResponse struct {
	FulfillmentID string `json:"fulfillmentId"`
}
