活动:新手限定礼包

This commit is contained in:
qiaoxin
2021-05-11 17:03:59 +08:00
parent b268c85fa2
commit df13e8181e
26 changed files with 412 additions and 154 deletions
+9 -9
View File
@@ -8,7 +8,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
export default class ActivitySelfServiceGoods extends BaseModel {
@prop({ required: true })
acvitityId: number; // 活动Id
activityId: number; // 活动Id
@prop({ required: true })
roundIndex: number; // 活动第几周期 从1开始,根据活动开始时间计算
@prop({ required: true })
@@ -24,28 +24,28 @@ export default class ActivitySelfServiceGoods extends BaseModel {
//添加选中的物品
public static async addGoods(acvitityId: number, roleId: string, roundIndex: number, index: number, cellIndex: number, gift: number, rewardIndex: number) {
let result: ActivitySelfServiceGoodsModelType = await ActivitySelfServiceGoodsModel.findOneAndUpdate({ roleId, acvitityId, roundIndex, index, cellIndex },
public static async addGoods(activityId: number, roleId: string, roundIndex: number, index: number, cellIndex: number, gift: number, rewardIndex: number) {
let result: ActivitySelfServiceGoodsModelType = await ActivitySelfServiceGoodsModel.findOneAndUpdate({ roleId, activityId, roundIndex, index, cellIndex },
{ $set: { gift, rewardIndex } }, { upsert: true, new: true }).lean(true);
return result;
}
public static async findData(acvitityId: number, roleId: string, roundIndex: number, lean = true) {
let result: ActivitySelfServiceGoodsModelType[] = await ActivitySelfServiceGoodsModel.find({ roleId, acvitityId, roundIndex }, {
public static async findData(activityId: number, roleId: string, roundIndex: number, lean = true) {
let result: ActivitySelfServiceGoodsModelType[] = await ActivitySelfServiceGoodsModel.find({ roleId, activityId, roundIndex }, {
index: 1, cellIndex: 1, gift: 1, rewardIndex: 1, _id: -1
}).lean(lean);
return result;
}
//查询第几个货架数据
public static async findDataByIndex(acvitityId: number, roleId: string, roundIndex: number, index: number, lean = true) {
let result: ActivitySelfServiceGoodsModelType[] = await ActivitySelfServiceGoodsModel.find({ roleId, acvitityId, roundIndex, index }).lean(lean);
public static async findDataByIndex(activityId: number, roleId: string, roundIndex: number, index: number, lean = true) {
let result: ActivitySelfServiceGoodsModelType[] = await ActivitySelfServiceGoodsModel.find({ roleId, activityId, roundIndex, index }).lean(lean);
return result;
}
//删除活动领取记录
public static async deleteActivity(acvitityId: number, roleId: string, roundIndex: number, index: number,) {
await ActivitySelfServiceGoodsModel.deleteMany({ roleId, acvitityId, index, roundIndex });
public static async deleteActivity(activityId: number, roleId: string, roundIndex: number, index: number,) {
await ActivitySelfServiceGoodsModel.deleteMany({ roleId, activityId, index, roundIndex });
}
}