use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; #[derive( Debug, Clone, Copy, PartialEq, Eq, Default, EnumIter, DeriveActiveEnum, Serialize, Deserialize, )] #[sea_orm(rs_type = "i16", db_type = "SmallInteger")] pub enum OrderStatus { #[default] Pending = 0, Paid = 1, Failed = 2, Refunded = 3, Expired = 4, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "payment_order")] pub struct Model { #[sea_orm(primary_key)] pub id: Uuid, pub user_id: Uuid, pub space_id: Option, pub product_id: Option, pub amount: i64, #[sea_orm(default_value = "CNY")] pub currency: String, pub status: OrderStatus, pub payment_method: Option, #[sea_orm(unique)] pub external_txn_id: Option, pub created_at: OffsetDateTime, pub paid_at: Option, pub expires_at: Option, #[sea_orm(belongs_to, from = "user_id", to = "uid")] pub user: BelongsTo, #[sea_orm(belongs_to, from = "space_id", to = "id")] pub space: BelongsTo>, #[sea_orm(belongs_to, from = "product_id", to = "id")] pub product: BelongsTo>, } impl ActiveModelBehavior for ActiveModel {}