feat(活动): 节日活动高级签到邮件补发

This commit is contained in:
luying
2023-08-04 16:20:36 +08:00
parent 822c8c8c42
commit 3d510783da
8 changed files with 90 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, ReturnModelType, mongoose } from '@typegoose/typegoose';
import { CounterAllModal } from './CounterAll';
import { COUNTER } from '../consts';
import { ACTIVITY_TIME_TYPE, COUNTER } from '../consts';
import { ActivityGroupModel } from './ActivityGroup';
import { UpdateActivityParam } from '../domain/backEndField/params';
@@ -90,6 +90,12 @@ export default class Activity extends BaseModel {
return result;
}
// 查询
public static async findOpenTypeByTime(type: number) {
let result: ActivityModelType[] = await ActivityModel.find({ type, isEnable: true, timeType: ACTIVITY_TIME_TYPE.DATE_TIME, beginTime: { $lte: new Date }, endTime: { $gte: new Date() } }).lean();
return result;
}
//debug测试用接口
public static async debugFindActivityByType(type: number) {
let result: ActivityModelType[] = await ActivityModel.findOne({ type }).lean(true);

View File

@@ -27,6 +27,8 @@ export default class Activity_Sign_In extends BaseModel {
roundIndex: number; // 周期数,从活动设置的开始时间计算
@prop({ required: true, type: Activity_Sign_In_Record, _id: false })
records: Activity_Sign_In_Record[]; // 领取记录
@prop({ required: false })
hasRepair: boolean; // 是否补发了
//签到记录
public static async addSignInRecord(activityId: number, roleId: string, roundIndex: number, dayIndex: number) {
@@ -48,6 +50,16 @@ export default class Activity_Sign_In extends BaseModel {
return result;
}
// 根据活动id查询记录
public static async findByActivity(activityId: number, roundIndex: number) {
let result: ActivitySignInModelType[] = await ActivitySignInModel.find({ activityId, roundIndex }).lean();
return result;
}
public static async repairSignIn(activityId: number, roleIds: string[]) {
await ActivitySignInModel.updateMany({ activityId, roleId: { $in: roleIds } }, { $set: { hasRepair: true } });
}
//删除签到记录
public static async deleteActivity(activityId: number, roleId: string, roundIndex: number) {
await ActivitySignInModel.deleteMany({ roleId, activityId, roundIndex });