41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import BaseModel from './BaseModel';
|
|
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
|
|
|
export class RefundRec {
|
|
@prop({ required: true })
|
|
roleId: string;
|
|
|
|
@prop({ required: true })
|
|
itemId: number;
|
|
|
|
@prop({ required: true })
|
|
diff: number;
|
|
}
|
|
|
|
/**
|
|
* 活动系统 - 团购玩家记录
|
|
*/
|
|
@index({ activityId: 1 })
|
|
|
|
export default class Activity_Group_Shop_Refund extends BaseModel {
|
|
|
|
@prop({ required: true })
|
|
activityId: number; // 活动Id
|
|
|
|
@prop({ required: true, type: RefundRec, _id: false })
|
|
refundRec: RefundRec[]; // 是否退好费了
|
|
|
|
public static async check(activityId: number) {
|
|
return await ActivityGroupShopRefundModel.exists({ activityId });
|
|
}
|
|
|
|
public static async refund(activityId: number, refundRec: RefundRec[]) {
|
|
let result: ActivityGroupShopRefundRecType = await ActivityGroupShopRefundModel.findOneAndUpdate({ activityId }, { $set: { refundRec } }, { upsert: true, new: true }).lean();
|
|
return result;
|
|
}
|
|
}
|
|
|
|
export const ActivityGroupShopRefundModel = getModelForClass(Activity_Group_Shop_Refund);
|
|
|
|
export interface ActivityGroupShopRefundRecType extends Pick<DocumentType<Activity_Group_Shop_Refund>, keyof Activity_Group_Shop_Refund> { }
|
|
export type ActivityGroupShopRefundRecTypeParam = Partial<ActivityGroupShopRefundRecType>; // 将所有字段变成可选项
|