import { DateTime } from 'luxon'
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
import { decimalConverter } from 'App/Helpers/db'
import Decimal from 'decimal.js'

export enum RechargeOrderStatus {
    Pending = 'pending',
    Success = 'success',
    Failed = 'failed'
}

export default class RechargeOrder extends BaseModel {
    @column({ isPrimary: true })
    public id: number

    @column.dateTime({ autoCreate: true })
    public createdAt: DateTime

    @column.dateTime({ autoCreate: true, autoUpdate: true })
    public updatedAt: DateTime

    @column()
    public userId: number

    @column({ ...decimalConverter })
    public amount: Decimal

    @column()
    public status: RechargeOrderStatus

    @column()
    public transactionId: string

    @column.dateTime()
    public payTime: DateTime
}
