mirror of
http://88.130.71.182:3000/BlitTech/badoHair_be.git
synced 2026-06-13 10:43:22 +00:00
58 lines
1.2 KiB
Python
58 lines
1.2 KiB
Python
from typing import Literal
|
|
from pydantic import BaseModel, Field
|
|
from uuid import UUID
|
|
from datetime import datetime
|
|
|
|
OrderStatus = Literal["pending", "paid", "processing", "shipped", "delivered", "cancelled", "refunded"]
|
|
|
|
|
|
class OrderItemCreate(BaseModel):
|
|
product_id: UUID
|
|
quantity: int = Field(ge=1)
|
|
|
|
|
|
class OrderCreate(BaseModel):
|
|
items: list[OrderItemCreate] = Field(min_length=1)
|
|
shipping_address: dict | None = None
|
|
notes: str | None = None
|
|
|
|
|
|
class OrderItemOut(BaseModel):
|
|
id: UUID
|
|
product_id: UUID
|
|
product_name: str
|
|
quantity: int
|
|
unit_price: float
|
|
|
|
@property
|
|
def subtotal(self) -> float:
|
|
return round(self.quantity * self.unit_price, 2)
|
|
|
|
|
|
class OrderOut(BaseModel):
|
|
id: UUID
|
|
user_id: UUID
|
|
status: str
|
|
total_amount: float
|
|
items: list[OrderItemOut] = []
|
|
shipping_address: dict | None = None
|
|
notes: str | None = None
|
|
stripe_payment_intent_id: str | None = None
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
|
|
class CheckoutResponse(BaseModel):
|
|
order_id: UUID
|
|
client_secret: str
|
|
amount: float
|
|
|
|
|
|
class UpdateOrderStatus(BaseModel):
|
|
status: OrderStatus
|
|
|
|
|
|
class RefundRequest(BaseModel):
|
|
reason: str | None = None
|
|
amount: float | None = Field(None, gt=0)
|