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 TransactionKind {
#[default]
Recharge = 0,
Consume = 1,
Refund = 2,
Adjust = 3,
}
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Default, EnumIter, DeriveActiveEnum, Serialize, Deserialize,
)]
#[sea_orm(rs_type = "i16", db_type = "SmallInteger")]
pub enum TransactionStatus {
#[default]
Pending = 0,
Success = 1,
Failed = 2,
Cancelled = 3,
}
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "payment_transaction")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: Uuid,
#[sea_orm(indexed)]
pub wallet_id: Uuid,
pub user_id: Uuid,
pub amount: i64,
pub kind: TransactionKind,
pub status: TransactionStatus,
pub ref_type: Option<String>,
pub ref_id: Option<String>,
pub created_at: OffsetDateTime,
pub completed_at: Option<OffsetDateTime>,
#[sea_orm(belongs_to, from = "wallet_id", to = "user_id")]
pub wallet: BelongsTo<super::payment_wallets::Entity>,
#[sea_orm(belongs_to, from = "user_id", to = "uid")]
pub user: BelongsTo<super::super::user::users::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}