活动:新手限定礼包
This commit is contained in:
@@ -19,6 +19,8 @@ export enum ACTIVITY_TYPE {
|
||||
THIRTY_DAYS = 12, // 30日目标活动
|
||||
SELF_SERVICE_SHOP = 13, // 自选商店
|
||||
FIRST_GIFT = 14, // 首充礼包
|
||||
NEW_PLAYER_LIMIT_PACKAGE = 15, // 新手限定RMB购买礼包
|
||||
LIMIT_PACKAGE_SHOP = 16, // 限购礼包,RMB购买礼包
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -351,6 +351,7 @@ export const STATUS = {
|
||||
ACTIVITY_THIRTY_DAYS_END: { code: 50014, simStr: '30日活动结束' },
|
||||
ACTIVITY_FIRST_GIFT_NOT_OPEN: { code: 50015, simStr: '首充没开' },
|
||||
ACTIVITY_FIRST_GIFT_END: { code: 50016, simStr: '首充结束' },
|
||||
ACTIVITY_NEW_PLAYER_LIMIT_PACKAGE_END: { code: 50017, simStr: '新手礼包结束' },
|
||||
// GM后台相关状态 60000 - 69999
|
||||
GM_ERR_PASSWORD: { code: 60001, simStr: '账号或密码错误' },
|
||||
GM_MISS_API: { code: 60002, simStr: '未找到该接口' },
|
||||
|
||||
@@ -4,11 +4,11 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
/**
|
||||
* 活动系统
|
||||
*/
|
||||
@index({ acvitityId: 1 })
|
||||
@index({ activityId: 1 })
|
||||
|
||||
export default class Activity extends BaseModel {
|
||||
@prop({ required: true })
|
||||
acvitityId: number; // 活动Id
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
beginTime: Date; // 开启时间
|
||||
@prop({ required: true })
|
||||
@@ -31,21 +31,21 @@ export default class Activity extends BaseModel {
|
||||
}
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findActivity(acvitityId: number, lean = true) {
|
||||
let result: ActivityModelType = await ActivityModel.findOne({ acvitityId }).lean(lean);
|
||||
public static async findActivity(activityId: number, lean = true) {
|
||||
let result: ActivityModelType = await ActivityModel.findOne({ activityId }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//新增活动
|
||||
public static async addActivity(acvitityId: number, beginTime: Date, endTime: Date, type: number, data: string, lean = true) {
|
||||
let result: ActivityModelType = await ActivityModel.findOneAndUpdate({ acvitityId }, { beginTime, endTime, type, data },
|
||||
public static async addActivity(activityId: number, beginTime: Date, endTime: Date, type: number, data: string, lean = true) {
|
||||
let result: ActivityModelType = await ActivityModel.findOneAndUpdate({ activityId }, { beginTime, endTime, type, data },
|
||||
{ upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动
|
||||
public static async deleteActivity(acvitityId: number) {
|
||||
let result = await ActivityModel.deleteMany({ acvitityId });
|
||||
public static async deleteActivity(activityId: number) {
|
||||
let result = await ActivityModel.deleteMany({ activityId });
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
|
||||
export default class ActivityBuyRecords extends BaseModel {
|
||||
@prop({ required: true })
|
||||
acvitityId: number; // 活动Id
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
@@ -18,27 +18,27 @@ export default class ActivityBuyRecords extends BaseModel {
|
||||
|
||||
|
||||
//添加购买记录
|
||||
public static async addRecord(acvitityId: number, roleId: string, type: number, pageIndex: number, lean = true) {
|
||||
let result: ActivityBuyRecordsModelType = await ActivityBuyRecordsModel.findOneAndUpdate({ roleId, acvitityId, type, pageIndex },
|
||||
public static async addRecord(activityId: number, roleId: string, type: number, pageIndex: number, lean = true) {
|
||||
let result: ActivityBuyRecordsModelType = await ActivityBuyRecordsModel.findOneAndUpdate({ roleId, activityId, type, pageIndex },
|
||||
{}, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动id查询数据
|
||||
public static async findRecordsByActivityId(acvitityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityBuyRecordsModelType[] = await ActivityBuyRecordsModel.find({ roleId, acvitityId }).lean(lean);
|
||||
public static async findRecordsByActivityId(activityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityBuyRecordsModelType[] = await ActivityBuyRecordsModel.find({ roleId, activityId }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几页的活动数据
|
||||
public static async findDataBypageIndex(acvitityId: number, type: number, roleId: string, pageIndex: number, lean = true) {
|
||||
let result: ActivityBuyRecordsModelType[] = await ActivityBuyRecordsModel.find({ roleId, type, acvitityId, pageIndex }).lean(lean);
|
||||
public static async findDataBypageIndex(activityId: number, type: number, roleId: string, pageIndex: number, lean = true) {
|
||||
let result: ActivityBuyRecordsModelType[] = await ActivityBuyRecordsModel.find({ roleId, type, activityId, pageIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动购买记录
|
||||
public static async deleteActivity(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number) {
|
||||
await ActivityBuyRecordsModel.deleteMany({ roleId, acvitityId, pageIndex, cellIndex });
|
||||
public static async deleteActivity(activityId: number, roleId: string, pageIndex: number, cellIndex: number) {
|
||||
await ActivityBuyRecordsModel.deleteMany({ roleId, activityId, pageIndex, cellIndex });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
|
||||
export default class ActivityDailyChallenges extends BaseModel {
|
||||
@prop({ required: true })
|
||||
acvitityId: number; // 活动Id
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
@@ -23,55 +23,55 @@ export default class ActivityDailyChallenges extends BaseModel {
|
||||
receiveRewardCount: number; // 领取奖励次数
|
||||
|
||||
//任务领取记录
|
||||
public static async addCellRecord(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ roleId, acvitityId, dayIndex, cellIndex, type },
|
||||
public static async addCellRecord(activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ roleId, activityId, dayIndex, cellIndex, type },
|
||||
{ $inc: { receiveRewardCount: count } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async setTaskCount(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ roleId, acvitityId, dayIndex, cellIndex, type },
|
||||
public static async setTaskCount(activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ roleId, activityId, dayIndex, cellIndex, type },
|
||||
{ $set: { totalCount: count } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async addTaskCount(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, addCount: number, lean = true) {
|
||||
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ roleId, acvitityId, dayIndex, cellIndex, type },
|
||||
public static async addTaskCount(activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, addCount: number, lean = true) {
|
||||
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ roleId, activityId, dayIndex, cellIndex, type },
|
||||
{ $inc: { totalCount: addCount } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findData(acvitityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityDailyChallengesModelType[] = await ActivityDailyChallengesModel.find({ roleId, acvitityId }).lean(lean);
|
||||
public static async findData(activityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityDailyChallengesModelType[] = await ActivityDailyChallengesModel.find({ roleId, activityId }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几天的活动数据
|
||||
public static async findDataByDayIndex(acvitityId: number, roleId: string, dayIndex: number, lean = true) {
|
||||
let result: ActivityDailyChallengesModelType[] = await ActivityDailyChallengesModel.find({ roleId, acvitityId, dayIndex }).lean(lean);
|
||||
public static async findDataByDayIndex(activityId: number, roleId: string, dayIndex: number, lean = true) {
|
||||
let result: ActivityDailyChallengesModelType[] = await ActivityDailyChallengesModel.find({ roleId, activityId, dayIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几天某个的活动数据
|
||||
public static async findDataByCellIndex(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityDailyChallengesModelType[] = await ActivityDailyChallengesModel.find({ roleId, acvitityId, dayIndex, cellIndex }).lean(lean);
|
||||
public static async findDataByCellIndex(activityId: number, roleId: string, dayIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityDailyChallengesModelType[] = await ActivityDailyChallengesModel.find({ roleId, activityId, dayIndex, cellIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//新增领取记录
|
||||
public static async addData(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, count: number, lean = true) {
|
||||
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ roleId, acvitityId, dayIndex, cellIndex },
|
||||
public static async addData(activityId: number, roleId: string, dayIndex: number, cellIndex: number, count: number, lean = true) {
|
||||
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ roleId, activityId, dayIndex, cellIndex },
|
||||
{ $: { count: count } },
|
||||
{ upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number) {
|
||||
await ActivityDailyChallengesModel.deleteMany({ roleId, acvitityId, dayIndex, cellIndex });
|
||||
public static async deleteActivity(activityId: number, roleId: string, dayIndex: number, cellIndex: number) {
|
||||
await ActivityDailyChallengesModel.deleteMany({ roleId, activityId, dayIndex, cellIndex });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
|
||||
export default class ActivityDailyGifts extends BaseModel {
|
||||
@prop({ required: true })
|
||||
acvitityId: number; // 活动Id
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
@@ -20,33 +20,33 @@ export default class ActivityDailyGifts extends BaseModel {
|
||||
buyCount: number; // 购买次数
|
||||
|
||||
//购买记录
|
||||
public static async buyRecord(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, count: number, lean = true) {
|
||||
let result: ActivityDailyGiftsModelType = await ActivityDailyGiftsModel.findOneAndUpdate({ roleId, acvitityId, dayIndex, cellIndex },
|
||||
public static async buyRecord(activityId: number, roleId: string, dayIndex: number, cellIndex: number, count: number, lean = true) {
|
||||
let result: ActivityDailyGiftsModelType = await ActivityDailyGiftsModel.findOneAndUpdate({ roleId, activityId, dayIndex, cellIndex },
|
||||
{ $inc: { receiveRewardCount: count } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findData(acvitityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityDailyGiftsModelType[] = await ActivityDailyGiftsModel.find({ roleId, acvitityId }).lean(lean);
|
||||
public static async findData(activityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityDailyGiftsModelType[] = await ActivityDailyGiftsModel.find({ roleId, activityId }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几天的活动数据
|
||||
public static async findDataByDayIndex(acvitityId: number, roleId: string, dayIndex: number, lean = true) {
|
||||
let result: ActivityDailyGiftsModelType[] = await ActivityDailyGiftsModel.find({ roleId, acvitityId, dayIndex }).lean(lean);
|
||||
public static async findDataByDayIndex(activityId: number, roleId: string, dayIndex: number, lean = true) {
|
||||
let result: ActivityDailyGiftsModelType[] = await ActivityDailyGiftsModel.find({ roleId, activityId, dayIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几天某个的活动数据
|
||||
public static async findDataByCellIndex(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityDailyGiftsModelType[] = await ActivityDailyGiftsModel.find({ roleId, acvitityId, dayIndex, cellIndex }).lean(lean);
|
||||
public static async findDataByCellIndex(activityId: number, roleId: string, dayIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityDailyGiftsModelType[] = await ActivityDailyGiftsModel.find({ roleId, activityId, dayIndex, cellIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number) {
|
||||
await ActivityDailyGiftsModel.deleteMany({ roleId, acvitityId, dayIndex, cellIndex });
|
||||
public static async deleteActivity(activityId: number, roleId: string, dayIndex: number, cellIndex: number) {
|
||||
await ActivityDailyGiftsModel.deleteMany({ roleId, activityId, dayIndex, cellIndex });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
|
||||
export default class ActivityFirstGift extends BaseModel {
|
||||
@prop({ required: true })
|
||||
acvitityId: number; // 活动Id
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
@@ -16,27 +16,27 @@ export default class ActivityFirstGift extends BaseModel {
|
||||
|
||||
|
||||
//添加领取记录
|
||||
public static async addRecord(acvitityId: number, roleId: string, index: number) {
|
||||
let result: ActivityFirstGiftModelType = await ActivityFirstGiftModel.findOneAndUpdate({ roleId, acvitityId, },
|
||||
public static async addRecord(activityId: number, roleId: string, index: number) {
|
||||
let result: ActivityFirstGiftModelType = await ActivityFirstGiftModel.findOneAndUpdate({ roleId, activityId, },
|
||||
{ $push: { days: index } }, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//可以领取首充礼包,充值时间记录
|
||||
public static async begin(acvitityId: number, roleId: string) {
|
||||
let result: ActivityFirstGiftModelType = await ActivityFirstGiftModel.findOneAndUpdate({ roleId, acvitityId },
|
||||
public static async begin(activityId: number, roleId: string) {
|
||||
let result: ActivityFirstGiftModelType = await ActivityFirstGiftModel.findOneAndUpdate({ roleId, activityId },
|
||||
{}, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findData(acvitityId: number, roleId: string) {
|
||||
let result: ActivityFirstGiftModelType = await ActivityFirstGiftModel.findOne({ roleId, acvitityId }, {}).lean(true);
|
||||
public static async findData(activityId: number, roleId: string) {
|
||||
let result: ActivityFirstGiftModelType = await ActivityFirstGiftModel.findOne({ roleId, activityId }, {}).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(acvitityId: number, roleId: string, roundIndex: number, index: number,) {
|
||||
await ActivityFirstGiftModel.deleteMany({ roleId, acvitityId, index, roundIndex });
|
||||
public static async deleteActivity(activityId: number, roleId: string, roundIndex: number, index: number,) {
|
||||
await ActivityFirstGiftModel.deleteMany({ roleId, activityId, index, roundIndex });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
|
||||
export default class ActivityGrowth extends BaseModel {
|
||||
@prop({ required: true })
|
||||
acvitityId: number; // 活动Id
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
@@ -27,62 +27,62 @@ export default class ActivityGrowth extends BaseModel {
|
||||
getPointReward: boolean; // 是否兑换领取奖章奖励
|
||||
|
||||
//任务领取记录
|
||||
public static async addCellRecord(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, acvitityId, dayIndex, cellIndex, type },
|
||||
public static async addCellRecord(activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, activityId, dayIndex, cellIndex, type },
|
||||
{ $inc: { receiveRewardCount: count } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//当日奖章领取记录
|
||||
public static async addDayRecord(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, acvitityId, dayIndex, cellIndex },
|
||||
public static async addDayRecord(activityId: number, roleId: string, dayIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, activityId, dayIndex, cellIndex },
|
||||
{ $set: { getPointReward: true } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async setTaskCount(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, acvitityId, dayIndex, cellIndex, type },
|
||||
public static async setTaskCount(activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, activityId, dayIndex, cellIndex, type },
|
||||
{ $set: { totalCount: count } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async addTaskCount(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, addCount: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, acvitityId, dayIndex, cellIndex, type },
|
||||
public static async addTaskCount(activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, addCount: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, activityId, dayIndex, cellIndex, type },
|
||||
{ $inc: { totalCount: addCount } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findData(acvitityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityGrowthModelType[] = await ActivityGrowthModel.find({ roleId, acvitityId }).lean(lean);
|
||||
public static async findData(activityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityGrowthModelType[] = await ActivityGrowthModel.find({ roleId, activityId }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几天的活动数据
|
||||
public static async findDataByDayIndex(acvitityId: number, roleId: string, dayIndex: number, lean = true) {
|
||||
let result: ActivityGrowthModelType[] = await ActivityGrowthModel.find({ roleId, acvitityId, dayIndex }).lean(lean);
|
||||
public static async findDataByDayIndex(activityId: number, roleId: string, dayIndex: number, lean = true) {
|
||||
let result: ActivityGrowthModelType[] = await ActivityGrowthModel.find({ roleId, activityId, dayIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几天某个的活动数据
|
||||
public static async findDataByCellIndex(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityGrowthModelType[] = await ActivityGrowthModel.find({ roleId, acvitityId, dayIndex, cellIndex }).lean(lean);
|
||||
public static async findDataByCellIndex(activityId: number, roleId: string, dayIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityGrowthModelType[] = await ActivityGrowthModel.find({ roleId, activityId, dayIndex, cellIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//新增领取记录
|
||||
public static async addData(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number, count: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, acvitityId, dayIndex, cellIndex },
|
||||
public static async addData(activityId: number, roleId: string, dayIndex: number, cellIndex: number, count: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, activityId, dayIndex, cellIndex },
|
||||
{ $: { count: count } },
|
||||
{ upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(acvitityId: number, roleId: string, dayIndex: number, cellIndex: number) {
|
||||
await ActivityGrowthModel.deleteMany({ roleId, acvitityId, dayIndex, cellIndex });
|
||||
public static async deleteActivity(activityId: number, roleId: string, dayIndex: number, cellIndex: number) {
|
||||
await ActivityGrowthModel.deleteMany({ roleId, activityId, dayIndex, cellIndex });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
|
||||
export default class ActivityGrowthFund extends BaseModel {
|
||||
@prop({ required: true })
|
||||
acvitityId: number; // 活动Id
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
@@ -20,33 +20,33 @@ export default class ActivityGrowthFund extends BaseModel {
|
||||
|
||||
|
||||
//添加领取记录
|
||||
public static async addRecord(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityGrowthFundModelType = await ActivityGrowthFundModel.findOneAndUpdate({ roleId, acvitityId, pageIndex, cellIndex },
|
||||
public static async addRecord(activityId: number, roleId: string, pageIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityGrowthFundModelType = await ActivityGrowthFundModel.findOneAndUpdate({ roleId, activityId, pageIndex, cellIndex },
|
||||
{ $set: { isReceive: true } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findData(acvitityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityGrowthFundModelType[] = await ActivityGrowthFundModel.find({ roleId, acvitityId }).lean(lean);
|
||||
public static async findData(activityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityGrowthFundModelType[] = await ActivityGrowthFundModel.find({ roleId, activityId }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几页的活动数据
|
||||
public static async findDataBypageIndex(acvitityId: number, roleId: string, pageIndex: number, lean = true) {
|
||||
let result: ActivityGrowthFundModelType[] = await ActivityGrowthFundModel.find({ roleId, acvitityId, pageIndex }).lean(lean);
|
||||
public static async findDataBypageIndex(activityId: number, roleId: string, pageIndex: number, lean = true) {
|
||||
let result: ActivityGrowthFundModelType[] = await ActivityGrowthFundModel.find({ roleId, activityId, pageIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第*页的某个的活动数据
|
||||
public static async findDataByCellIndex(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityGrowthFundModelType[] = await ActivityGrowthFundModel.find({ roleId, acvitityId, pageIndex, cellIndex }).lean(lean);
|
||||
public static async findDataByCellIndex(activityId: number, roleId: string, pageIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityGrowthFundModelType[] = await ActivityGrowthFundModel.find({ roleId, activityId, pageIndex, cellIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number) {
|
||||
await ActivityGrowthFundModel.deleteMany({ roleId, acvitityId, pageIndex, cellIndex });
|
||||
public static async deleteActivity(activityId: number, roleId: string, pageIndex: number, cellIndex: number) {
|
||||
await ActivityGrowthFundModel.deleteMany({ roleId, activityId, pageIndex, cellIndex });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
|
||||
export default class ActivitySelfServiceShop extends BaseModel {
|
||||
@prop({ required: true })
|
||||
acvitityId: number; // 活动Id
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roundIndex: number; // 活动第几周期 从1开始,根据活动开始时间计算
|
||||
@prop({ required: true })
|
||||
@@ -24,33 +24,33 @@ export default class ActivitySelfServiceShop extends BaseModel {
|
||||
goods: string; // 商品信息
|
||||
|
||||
//添加购买记录
|
||||
public static async addBuyRecord(acvitityId: number, roleId: string, roundIndex: number, index: number, price: number, priceType: number, goods: string) {
|
||||
public static async addBuyRecord(activityId: number, roleId: string, roundIndex: number, index: number, price: number, priceType: number, goods: string) {
|
||||
await ActivitySelfServiceShopModel.insertMany([
|
||||
{ roleId, acvitityId, roundIndex, index, price, priceType, goods }
|
||||
{ roleId, activityId, roundIndex, index, price, priceType, goods }
|
||||
])
|
||||
}
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findData(acvitityId: number, roleId: string, roundIndex: number, lean = true) {
|
||||
let result: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.find({ roleId, acvitityId, roundIndex }).lean(lean);
|
||||
public static async findData(activityId: number, roleId: string, roundIndex: number, lean = true) {
|
||||
let result: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.find({ roleId, activityId, roundIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几个货架数据
|
||||
public static async findDataByIndex(acvitityId: number, roleId: string, roundIndex: number, index: number, lean = true) {
|
||||
let result: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.find({ roleId, acvitityId, roundIndex, index }).lean(lean);
|
||||
public static async findDataByIndex(activityId: number, roleId: string, roundIndex: number, index: number, lean = true) {
|
||||
let result: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.find({ roleId, activityId, roundIndex, index }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询购买价格类型的数据
|
||||
public static async findDataByPriceType(acvitityId: number, roleId: string, roundIndex: number, priceType: number, lean = true) {
|
||||
let result: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.find({ roleId, acvitityId, priceType, roundIndex }).lean(lean);
|
||||
public static async findDataByPriceType(activityId: number, roleId: string, roundIndex: number, priceType: number, lean = true) {
|
||||
let result: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.find({ roleId, activityId, priceType, roundIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(acvitityId: number, roleId: string, roundIndex: number, index: number,) {
|
||||
await ActivitySelfServiceShopModel.deleteMany({ roleId, acvitityId, index, roundIndex });
|
||||
public static async deleteActivity(activityId: number, roleId: string, roundIndex: number, index: number,) {
|
||||
await ActivitySelfServiceShopModel.deleteMany({ roleId, activityId, index, roundIndex });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
54
shared/db/ActivityShop.ts
Normal file
54
shared/db/ActivityShop.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
|
||||
/**
|
||||
* 购买记录
|
||||
*/
|
||||
|
||||
export class BuyRecord {
|
||||
@prop({ required: true })
|
||||
id: number; //物品id标识
|
||||
@prop({ required: true })
|
||||
time: Date; //购买时间
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 活动系统 - 新手限定、每日限购、每周限购
|
||||
*/
|
||||
@index({ roleId: 1 })
|
||||
|
||||
export default class ActivityShop extends BaseModel {
|
||||
@prop({ required: true })
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
roundIndex: number; // 第几个周期,从1开始
|
||||
@prop({ required: true })
|
||||
records: BuyRecord[]; // 购买记录
|
||||
|
||||
//购买领取奖励的记录
|
||||
public static async addRecord(activityId: number, roleId: string, roundIndex: number, id: number) {
|
||||
let result: ActivityShopModelType = await ActivityShopModel.findOneAndUpdate({ roleId, activityId, roundIndex },
|
||||
{ $push: { records: { id, time: new Date() } } }, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findData(activityId: number, roleId: string, roundIndex: number) {
|
||||
let result: ActivityShopModelType = await ActivityShopModel.findOne({ roleId, activityId, roundIndex }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(activityId: number, roleId: string, roundIndex: number) {
|
||||
await ActivityShopModel.deleteMany({ roleId, activityId, roundIndex });
|
||||
}
|
||||
}
|
||||
|
||||
export const ActivityShopModel = getModelForClass(ActivityShop);
|
||||
|
||||
export interface ActivityShopModelType extends Pick<DocumentType<ActivityShop>, keyof ActivityShop> { }
|
||||
export type ActivityShopModelTypeParam = Partial<ActivityShopModelType>; // 将所有字段变成可选项
|
||||
@@ -8,7 +8,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
|
||||
export default class ActivitySignIn extends BaseModel {
|
||||
@prop({ required: true })
|
||||
acvitityId: number; // 活动Id
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
@@ -17,27 +17,27 @@ export default class ActivitySignIn extends BaseModel {
|
||||
isReceive: boolean; // 是否领取
|
||||
|
||||
//签到记录
|
||||
public static async addSignInRecord(acvitityId: number, roleId: string, dayIndex: number, lean = true) {
|
||||
let result: ActivitySignInModelType = await ActivitySignInModel.findOneAndUpdate({ roleId, acvitityId, dayIndex },
|
||||
public static async addSignInRecord(activityId: number, roleId: string, dayIndex: number, lean = true) {
|
||||
let result: ActivitySignInModelType = await ActivitySignInModel.findOneAndUpdate({ roleId, activityId, dayIndex },
|
||||
{ $set: { isReceive: true } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findData(acvitityId: number, roleId: string, lean = true) {
|
||||
let result: ActivitySignInModelType[] = await ActivitySignInModel.find({ roleId, acvitityId }).lean(lean);
|
||||
public static async findData(activityId: number, roleId: string, lean = true) {
|
||||
let result: ActivitySignInModelType[] = await ActivitySignInModel.find({ roleId, activityId }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几天的活动数据
|
||||
public static async findDataByDayIndex(acvitityId: number, roleId: string, dayIndex: number, lean = true) {
|
||||
let result: ActivitySignInModelType[] = await ActivitySignInModel.find({ roleId, acvitityId, dayIndex }).lean(lean);
|
||||
public static async findDataByDayIndex(activityId: number, roleId: string, dayIndex: number, lean = true) {
|
||||
let result: ActivitySignInModelType[] = await ActivitySignInModel.find({ roleId, activityId, dayIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除签到记录
|
||||
public static async deleteActivity(acvitityId: number, roleId: string, dayIndex: number) {
|
||||
await ActivitySignInModel.deleteMany({ roleId, acvitityId, dayIndex });
|
||||
public static async deleteActivity(activityId: number, roleId: string, dayIndex: number) {
|
||||
await ActivitySignInModel.deleteMany({ roleId, activityId, dayIndex });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
|
||||
export default class ActivityThirtyDays extends BaseModel {
|
||||
@prop({ required: true })
|
||||
acvitityId: number; // 活动Id
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
@@ -23,47 +23,47 @@ export default class ActivityThirtyDays extends BaseModel {
|
||||
isReceive: boolean; // 是否领取过奖励
|
||||
|
||||
//添加领取记录
|
||||
public static async addRecord(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ roleId, acvitityId, pageIndex, cellIndex },
|
||||
public static async addRecord(activityId: number, roleId: string, pageIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ roleId, activityId, pageIndex, cellIndex },
|
||||
{ $set: { isReceive: true } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async addTaskCount(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number, type: number, addCount: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ roleId, acvitityId, pageIndex, cellIndex, type },
|
||||
public static async addTaskCount(activityId: number, roleId: string, pageIndex: number, cellIndex: number, type: number, addCount: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ roleId, activityId, pageIndex, cellIndex, type },
|
||||
{ $inc: { totalCount: addCount } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async setTaskCount(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ roleId, acvitityId, pageIndex, cellIndex, type },
|
||||
public static async setTaskCount(activityId: number, roleId: string, pageIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ roleId, activityId, pageIndex, cellIndex, type },
|
||||
{ $set: { totalCount: count } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findData(acvitityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.find({ roleId, acvitityId }).lean(lean);
|
||||
public static async findData(activityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.find({ roleId, activityId }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几页的活动数据
|
||||
public static async findDataBypageIndex(acvitityId: number, roleId: string, pageIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.find({ roleId, acvitityId, pageIndex }).lean(lean);
|
||||
public static async findDataBypageIndex(activityId: number, roleId: string, pageIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.find({ roleId, activityId, pageIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第*页的某个的活动数据
|
||||
public static async findDataByCellIndex(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.find({ roleId, acvitityId, pageIndex, cellIndex }).lean(lean);
|
||||
public static async findDataByCellIndex(activityId: number, roleId: string, pageIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.find({ roleId, activityId, pageIndex, cellIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number) {
|
||||
await ActivityThirtyDaysModel.deleteMany({ roleId, acvitityId, pageIndex, cellIndex });
|
||||
public static async deleteActivity(activityId: number, roleId: string, pageIndex: number, cellIndex: number) {
|
||||
await ActivityThirtyDaysModel.deleteMany({ roleId, activityId, pageIndex, cellIndex });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
|
||||
export default class ActivityThirtyDaysPointReward extends BaseModel {
|
||||
@prop({ required: true })
|
||||
acvitityId: number; // 活动Id
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
@@ -19,11 +19,11 @@ export default class ActivityThirtyDaysPointReward extends BaseModel {
|
||||
isExpired: boolean; // 是否过期奖励
|
||||
|
||||
//添加过期记录
|
||||
public static async setExpired(acvitityId: number, roleId: string, cells: Array<number>) {
|
||||
public static async setExpired(activityId: number, roleId: string, cells: Array<number>) {
|
||||
let records = [];
|
||||
for (let cellIndex of cells) {
|
||||
let data = {
|
||||
acvitityId,
|
||||
activityId,
|
||||
roleId,
|
||||
cellIndex,
|
||||
isReceive: false,
|
||||
@@ -35,27 +35,27 @@ export default class ActivityThirtyDaysPointReward extends BaseModel {
|
||||
}
|
||||
|
||||
//添加领取记录
|
||||
public static async addRecord(acvitityId: number, roleId: string, cellIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysPointRewardModelType = await ActivityThirtyDaysPointRewardModel.findOneAndUpdate({ roleId, acvitityId, cellIndex },
|
||||
public static async addRecord(activityId: number, roleId: string, cellIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysPointRewardModelType = await ActivityThirtyDaysPointRewardModel.findOneAndUpdate({ roleId, activityId, cellIndex },
|
||||
{ $set: { isReceive: true } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findData(acvitityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityThirtyDaysPointRewardModelType[] = await ActivityThirtyDaysPointRewardModel.find({ roleId, acvitityId }).lean(lean);
|
||||
public static async findData(activityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityThirtyDaysPointRewardModelType[] = await ActivityThirtyDaysPointRewardModel.find({ roleId, activityId }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//第几个活动数据
|
||||
public static async findDataByCellIndex(acvitityId: number, roleId: string, cellIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysPointRewardModelType[] = await ActivityThirtyDaysPointRewardModel.find({ roleId, acvitityId, cellIndex }).lean(lean);
|
||||
public static async findDataByCellIndex(activityId: number, roleId: string, cellIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysPointRewardModelType[] = await ActivityThirtyDaysPointRewardModel.find({ roleId, activityId, cellIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(acvitityId: number, roleId: string, cellIndex: number) {
|
||||
await ActivityThirtyDaysPointRewardModel.deleteMany({ roleId, acvitityId, cellIndex });
|
||||
public static async deleteActivity(activityId: number, roleId: string, cellIndex: number) {
|
||||
await ActivityThirtyDaysPointRewardModel.deleteMany({ roleId, activityId, cellIndex });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ export abstract class ActivityBase {
|
||||
}
|
||||
|
||||
constructor(activityData: ActivityModelType) {
|
||||
this.activityId = activityData.acvitityId;
|
||||
this.activityId = activityData.activityId;
|
||||
this.beginTime = activityData.beginTime;
|
||||
this.endTime = activityData.endTime;
|
||||
this.type = activityData.type;
|
||||
|
||||
75
shared/domain/activityField/limitShopField.ts
Normal file
75
shared/domain/activityField/limitShopField.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { ACTIVITY_RESOURCES_TYPE } from '../../consts';
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityShopModelType } from '../../db/ActivityShop';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
// 每个商品的内容
|
||||
export class ShopItem {
|
||||
id: number; // 商品id
|
||||
reward: string; //任务奖励,格式:1&3&1(类型&id&数量) 类型定义:1.英雄,2.物品
|
||||
countMax: number = 0; //可购买的最大次数,0表示不限制
|
||||
name: string; //名字
|
||||
|
||||
buyCount: number = 0; //购买过的次数
|
||||
|
||||
constructor(data: any) {
|
||||
this.id = data.id;
|
||||
this.reward = data.reward;
|
||||
this.countMax = data.countMax;
|
||||
this.name = data.name;
|
||||
}
|
||||
}
|
||||
|
||||
// 商店数据
|
||||
export class LimitShopData extends ActivityBase {
|
||||
name: string = '';//活动名称
|
||||
interval: number = 0;//周期间隔(秒)
|
||||
list: Array<ShopItem> = [];//商品列表
|
||||
refreshTime: Date;//下次刷新时间
|
||||
roundIndex: number = 1;//周期数从1开始
|
||||
|
||||
public findItem(id: number) {
|
||||
let index = this.list.findIndex(obj => { return obj && obj.id === id });
|
||||
return (index != -1) ? this.list[index] : null
|
||||
}
|
||||
|
||||
//全部领取完成
|
||||
public isComplete() {
|
||||
for (let item of this.list) {
|
||||
if (item.countMax == 0 ||
|
||||
(item.countMax > 0 && item.buyCount < item.countMax)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//解析玩家购买记录
|
||||
public setPlayerRecords(data: ActivityShopModelType) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
let records = data.records ? data.records : [];
|
||||
for (let item of this.list) {
|
||||
let buyRecords = records.filter(obj => { return obj && obj.id === item.id });
|
||||
item.buyCount = buyRecords.length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public initData(data: string) {
|
||||
let dataObj = JSON.parse(data);
|
||||
this.name = dataObj.name;
|
||||
this.interval = dataObj.interval;
|
||||
|
||||
let arr = dataObj.data;
|
||||
for (let obj of arr) {
|
||||
this.list.push(new ShopItem(obj))
|
||||
}
|
||||
}
|
||||
|
||||
constructor(activityData: ActivityModelType) {
|
||||
super(activityData)
|
||||
this.initData(activityData.data)
|
||||
}
|
||||
}
|
||||
@@ -534,7 +534,7 @@ export async function accomplishTask(roleId: string, taskType: TASK_TYPE, count:
|
||||
allActivity = await ActivityModel.findOpenActivityByType(ACTIVITY_TYPE.THIRTY_DAYS, new Date());
|
||||
for (let activity of allActivity) {
|
||||
let thirtyDaysActivity = new ThirtyDaysData(activity);
|
||||
let playerRecords: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.findData(activity.acvitityId, roleId);
|
||||
let playerRecords: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.findData(activity.activityId, roleId);
|
||||
thirtyDaysActivity.setPlayerRecords(playerRecords);
|
||||
let taskArray = thirtyDaysActivity.findUncompleteTaskByType(taskType);
|
||||
for (let task of taskArray) {
|
||||
|
||||
Reference in New Issue
Block a user