许愿池
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
export const IT_TYPE = {
|
||||
BLUEPRT: 28,
|
||||
EQUIP_PIECE: 3,
|
||||
EQUIP: 2,
|
||||
HERO_PIECE: 7,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -152,6 +152,8 @@ export const STATUS = {
|
||||
GUILD_DONATE_TIMES_NOT_ENOUGH: { code: 20922, simStr: '今日捐献的次数不够' },
|
||||
GUILD_DONATE_BOXS_IS_GOT: { code: 20923, simStr: '该捐献宝箱已领取' },
|
||||
GUILD_DONATE_BOXS_NOT_GOT: { code: 20924, simStr: '该捐献宝箱未达到领取条件' },
|
||||
GUILD_WISH_POOL_NOT_OWN_EQUIP: { code: 20926, simStr: '未拥有此装备或碎片,不能许愿' },
|
||||
GUILD_WISH_POOL_NOT_OWN_HERO: { code: 20927, simStr: '未拥有此武将或碎片,不能许愿' },
|
||||
|
||||
GUILD_SCRIPT_IS_OPENED_TODAY: { code: 20950, simStr: '今日演武场已开启' },
|
||||
GUILD_SCRIPT_NOT_OPENED: { code: 20951, simStr: '演武场未开启' },
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ export interface DicGoods {
|
||||
readonly nextJewelId?: number;
|
||||
readonly specialCount?: number;
|
||||
readonly nextSpecialId?: number;
|
||||
// 对应的装备id
|
||||
readonly equipId?: number;
|
||||
}
|
||||
|
||||
const str = readJsonFile(FILENAME.DIC_GOODS);
|
||||
@@ -85,7 +87,8 @@ const DicGoodsKeys: KeysEnum<DicGoods> = {
|
||||
count: true,
|
||||
nextJewelId: true,
|
||||
specialCount: true,
|
||||
nextSpecialId: true
|
||||
nextSpecialId: true,
|
||||
equipId: true
|
||||
}
|
||||
export const dicJewel = new Map<number, DicGoods>();
|
||||
export const dicGoods = new Map<number, DicGoods>();
|
||||
@@ -98,6 +101,11 @@ arr.forEach(o => {
|
||||
o.specialAttr = parseSpecialAttr(o.specialAttr);
|
||||
o.specialMaterial = parseSpecialMaterial(o.specialMaterial);
|
||||
o.randomEffect = parseNumberList(o.randomEffect);
|
||||
if (o.goodType == IT_TYPE.EQUIP_PIECE) {
|
||||
let good = findWhere(arr, { pieceId: o.good_id });
|
||||
if (!!good)
|
||||
o.equipId = good.good_id;
|
||||
}
|
||||
dicGoods.set(o.good_id, _.pick(o, Object.keys(DicGoodsKeys)));
|
||||
|
||||
if (o.itid == IT_TYPE.BLUEPRT) {
|
||||
|
||||
Reference in New Issue
Block a user