团购活动:定时退费
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
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>; // 将所有字段变成可选项
|
||||
Reference in New Issue
Block a user