返回 AiToEarn
userWalletRecord.shema.ts
根目录 / project / aitoearn-electron / server / src / db / schema / userWalletRecord.shema.ts
1 /*
2 * @Author: nevin
3 * @Date: 2022-11-16 22:04:18
4 * @LastEditTime: 2025-03-24 21:44:35
5 * @LastEditors: nevin
6 * @Description: 钱包收支记录
7 */
8 import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
9 import { TimeTemp } from './time.tamp';
10 import { Decimal128 } from 'mongodb';
11 import { Types } from 'mongoose';
12 import { UserWalletAccount } from './userWalletAccount.shema';
13
14 export enum UserWalletRecordType {
15 TASK_COMMISSION = 'TASK_COMMISSION', // 任务佣金
16 WITHDRAW = 'WITHDRAW', // 提现
17 }
18
19 export enum UserWalletRecordStatus {
20 FAIL = -1,
21 WAIT = 0,
22 SUCCESS = 1,
23 }
24 @Schema({
25 collection: 'userWalletRecord',
26 versionKey: false,
27 toJSON: { virtuals: true },
28 toObject: { virtuals: true },
29 timestamps: false,
30 })
31 export class UserWalletRecord extends TimeTemp {
32 id: string;
33
34 @Prop({
35 index: true,
36 required: true,
37 })
38 userId: string;
39
40 @Prop({
41 type: Types.ObjectId,
42 ref: UserWalletAccount.name,
43 required: true,
44 })
45 account: Types.ObjectId;
46
47 @Prop({
48 index: true,
49 required: false,
50 })
51 dataId?: string; // 关联数据的ID
52
53 @Prop({
54 index: true,
55 required: true,
56 enum: UserWalletRecordType,
57 })
58 type: UserWalletRecordType;
59
60 @Prop({
61 index: true,
62 type: Decimal128,
63 required: true,
64 default: 0,
65 })
66 balance: Decimal128;
67
68 // 状态 -1 失败 0 等待 1 完成
69 @Prop({
70 index: true,
71 required: true,
72 default: UserWalletRecordStatus.WAIT,
73 })
74 status: UserWalletRecordStatus;
75
76 @Prop({
77 required: false,
78 })
79 payTime?: Date;
80
81 @Prop({
82 required: false,
83 })
84 des?: string;
85
86 @Prop({
87 required: false,
88 })
89 imgUrl?: string; // 反馈截图
90 }
91
92 export const UserWalletRecordSchema =
93 SchemaFactory.createForClass(UserWalletRecord);
94
94 lines TYPESCRIPT