🐞 fix(guild): 军团数据跟人,不跟军团

This commit is contained in:
dingchaolin
2023-03-07 14:39:45 +08:00
parent afe96b9fa4
commit 8725d7990e
+1 -13
View File
@@ -153,19 +153,8 @@ export default class UserGuild extends BaseModel {
const update = Object.assign(doc.toJSON(), { guildCode, roleId: role.roleId, role: role._id, job, auth, receiveBoxs, donateCnt, receivedActive, encourageCnt, bossChallengeCnt, receivedWishPool, wishGoods, wishDntCnt, refTimeDaily, refBossTime, trainCount, buyTrainCount, trainTime, trainRewards, refineCnt, refRefineTime }); const update = Object.assign(doc.toJSON(), { guildCode, roleId: role.roleId, role: role._id, job, auth, receiveBoxs, donateCnt, receivedActive, encourageCnt, bossChallengeCnt, receivedWishPool, wishGoods, wishDntCnt, refTimeDaily, refBossTime, trainCount, buyTrainCount, trainTime, trainRewards, refineCnt, refRefineTime });
// trainRewards: 试炼奖励, 无论在任何情况下都不能被清空(次数可以重置,奖励领过就不能再领了,无论在哪个军团) // trainRewards: 试炼奖励, 无论在任何情况下都不能被清空(次数可以重置,奖励领过就不能再领了,无论在哪个军团)
// 【退出军团】 和 【再加入军团】在同一天
if (isToday(role.quitGuildTime)) {
// 同一个军团: 所有数据保留; 不同军团: 许愿池数据清空,当天不允许许愿,其他数据保留
if (guildCode !== lastGuild?.guildCode) {
update.wishGoods = [];
update.receivedWishPool = [];
update.wishDntCnt = 0;
}
} else {
// 【退出军团】 和 【再加入军团】不在同一天; 此处包含: 首次加入军团(lastGuild == null) // 【退出军团】 和 【再加入军团】不在同一天; 此处包含: 首次加入军团(lastGuild == null)
if (lastGuild) { if (!isToday(role.quitGuildTime) && lastGuild) {
// 之前加入过军团 - 清空之前的数据 // 之前加入过军团 - 清空之前的数据
update.receiveBoxs = []; update.receiveBoxs = [];
update.donateCnt = 0; update.donateCnt = 0;
@@ -180,7 +169,6 @@ export default class UserGuild extends BaseModel {
update.trainTime = 0; update.trainTime = 0;
update.refineCnt = []; update.refineCnt = [];
} }
}
delete update._id; delete update._id;
const result: UserGuildType = await UserGuildModel.findOneAndUpdate({ roleId: role.roleId, guildCode, status: USER_GUILD_STATUS.ON }, { $set: update }, { upsert: true, new: true }) const result: UserGuildType = await UserGuildModel.findOneAndUpdate({ roleId: role.roleId, guildCode, status: USER_GUILD_STATUS.ON }, { $set: update }, { upsert: true, new: true })