74 lines
1.6 KiB
TypeScript
74 lines
1.6 KiB
TypeScript
import { ReturnModelType, getModelForClass, index, modelOptions, prop } from '@typegoose/typegoose'
|
|
import { dbconn } from 'decorators/dbconn'
|
|
import { BaseModule } from './Base'
|
|
import { PayType } from './PayRecord'
|
|
|
|
/**
|
|
* 支付打款记录
|
|
*/
|
|
@dbconn()
|
|
@index({ recordId: 1 }, { unique: true })
|
|
@modelOptions({ schemaOptions: { collection: 'pay_transfer_record', timestamps: true } })
|
|
export class TransferRecordClass extends BaseModule {
|
|
@prop({ required: true })
|
|
public account: string
|
|
|
|
// pay_record 的 id
|
|
@prop()
|
|
public recordId: string
|
|
|
|
@prop({ required: true, default: PayType.BUY })
|
|
public type: PayType
|
|
|
|
@prop()
|
|
public chain: number
|
|
|
|
// token 的合约地址
|
|
@prop()
|
|
public contract: string
|
|
|
|
// 用户的钱包地址
|
|
@prop()
|
|
public to: string
|
|
|
|
// 转出钱包
|
|
@prop()
|
|
public from: string
|
|
|
|
@prop()
|
|
public amount: string
|
|
|
|
@prop()
|
|
public gas: string
|
|
|
|
@prop()
|
|
public gasPrice: string
|
|
|
|
/**
|
|
* 0: 队列中, 等待上链
|
|
* 1: 已请求上链, 等待结果
|
|
* 2: 成功上链, 等待确认
|
|
* 9: 已确认成功(成功的最终状态)
|
|
* 8: 已上报状态
|
|
* 10: 失败
|
|
* 11: 部分失败
|
|
*/
|
|
@prop({ default: 0 })
|
|
public status: number
|
|
|
|
@prop({ default: 0 })
|
|
public errorCount: number
|
|
|
|
@prop({ type: () => [String] })
|
|
public hashList: string[]
|
|
|
|
@prop({ default: 0 })
|
|
public version: number
|
|
|
|
public static async findByRecordId(this: ReturnModelType<typeof TransferRecordClass>, recordId: string) {
|
|
return this.findOne({ recordId }).exec()
|
|
}
|
|
}
|
|
|
|
export const TransferRecord = getModelForClass(TransferRecordClass, { existingConnection: TransferRecordClass.db })
|