许愿池
This commit is contained in:
@@ -154,6 +154,12 @@ export default class Equip extends BaseModel {
|
||||
const user: EquipType[] = await EquipModel.find(searchObj).lean(lean);
|
||||
return user;
|
||||
}
|
||||
|
||||
public static async getEquipsByIds(roleId: string, ids: Array<number>) {
|
||||
let result = await EquipModel.find({ roleId, id: { $in: ids } });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const EquipModel = getModelForClass(Equip);
|
||||
|
||||
@@ -24,12 +24,12 @@ export default class Item extends BaseModel {
|
||||
|
||||
|
||||
public static async findbyRole(roleId: string, lean = true) {
|
||||
const items: ItemType[] = await ItemModel.find({ roleId }).select('id count type').lean(lean);
|
||||
const items: ItemType[] = await ItemModel.find({ roleId, count: {$gte: 0} }).select('id count type').lean(lean);
|
||||
return items;
|
||||
}
|
||||
|
||||
public static async findbyRoleAndIds(roleId: string, ids: Array<number>, lean = true) {
|
||||
const items: ItemType[] = await ItemModel.find({ roleId, id: { $in: ids } }).select('id count type').lean(lean);
|
||||
const items: ItemType[] = await ItemModel.find({ roleId, id: { $in: ids }, count: {$gte: 0} }).select('id count type').lean(lean);
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,10 +83,10 @@ export default class UserGuild extends BaseModel {
|
||||
@prop({ required: true, default: [], type: Number })
|
||||
receiveBoxs: Array<number>;
|
||||
|
||||
@prop({ required: true })
|
||||
@prop({ required: true, default: 0 })
|
||||
wishDntCnt: number;//今天许愿池捐献次数
|
||||
|
||||
@prop({ required: true })
|
||||
@prop({ required: true, default: 0 })
|
||||
donateCnt: number;//今天捐献所次数
|
||||
|
||||
public static async getMyAuth(roleId: string, guildCode?: string, userGuild?: UserGuildType) {
|
||||
@@ -192,6 +192,16 @@ export default class UserGuild extends BaseModel {
|
||||
const result: UserGuildType = await UserGuildModel.findOneAndUpdate({ roleId, status: USER_GUILD_STATUS.ON }, { $set: update, $push: pushData }, { new: true }).select(select).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async donateGoods(roleId: string, wishDntCnt: number, select?: string, lean = true) {
|
||||
const result: UserGuildType = await UserGuildModel.findOneAndUpdate({ roleId, status: USER_GUILD_STATUS.ON }, { $inc: { wishDntCnt } }, { new: true }).select(select).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async donateUpdate(roleId: string, id: string, select?: string, lean = true) {
|
||||
const result: UserGuildType = await UserGuildModel.findOneAndUpdate({ roleId, status: USER_GUILD_STATUS.ON, 'wishGoods.id': id }, { $inc: { 'wishGoods.$.receiveCnt': 1, 'wishGoods.$.drawCnt': 1} }, { new: true }).select(select).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const UserGuildModel = getModelForClass(UserGuild);
|
||||
|
||||
@@ -12,10 +12,10 @@ export default class WishPoolReport extends BaseModel {
|
||||
dntTime: number; //捐献时间
|
||||
|
||||
@prop({ required: true })
|
||||
roleId: string; //被捐献人
|
||||
wishRoleId: string; //被捐献人
|
||||
|
||||
@prop({ required: true })
|
||||
roleName: string; //捐赠人
|
||||
wishRoleName: string; //捐赠人
|
||||
|
||||
@prop({ required: true })
|
||||
goodId: number; //捐献物品
|
||||
@@ -29,9 +29,9 @@ export default class WishPoolReport extends BaseModel {
|
||||
@prop({ required: true })
|
||||
dntRoleName: string; //捐赠人
|
||||
|
||||
public static async addReport(guildCode: string, roleId: string, roleName: string, dntRoleId: string, dntRoleName: string, goodId: number, count: number, lean = true) {
|
||||
public static async addReport(guildCode: string, wishRoleId: string, wishRoleName: string, dntRoleId: string, dntRoleName: string, goodId: number, count: number, lean = true) {
|
||||
const doc = new WishPoolReportModel();
|
||||
const report = Object.assign(doc.toJSON(), { guildCode, roleId, roleName, dntRoleId, dntRoleName, goodId, dntTime: nowSeconds(), count });
|
||||
const report = Object.assign(doc.toJSON(), { guildCode, wishRoleId, wishRoleName, dntRoleId, dntRoleName, goodId, dntTime: nowSeconds(), count });
|
||||
await WishPoolReportModel.create(report);
|
||||
return report;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user