a06673b
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<Uuid>,
pub product_id: Option<Uuid>,
pub amount: i64,
#[sea_orm(default_value = "CNY")]
pub currency: String,
pub status: OrderStatus,
pub payment_method: Option<String>,
#[sea_orm(unique)]
pub external_txn_id: Option<String>,
pub created_at: OffsetDateTime,
pub paid_at: Option<OffsetDateTime>,
pub expires_at: Option<OffsetDateTime>,
#[sea_orm(belongs_to, from = "user_id", to = "uid")]
pub user: BelongsTo<super::super::user::users::Entity>,
#[sea_orm(belongs_to, from = "space_id", to = "id")]
pub space: BelongsTo<Option<super::super::space::spaces::Entity>>,
#[sea_orm(belongs_to, from = "product_id", to = "id")]
pub product: BelongsTo<Option<super::super::products::products::Entity>>,
}
impl ActiveModelBehavior for ActiveModel {}