🐞 fix(guild): 修复重复进军团无限制领取试炼奖励

This commit is contained in:
dingchaolin
2023-02-28 18:13:27 +08:00
parent 1cff94ca95
commit 93aade8be9

View File

@@ -145,13 +145,14 @@ export default class UserGuild extends BaseModel {
public static async createUserGuild(guildCode: string, role: RoleType, isLeader: boolean) {
const lastGuild = await UserGuildModel.findMyLastGuild(role.roleId, '+refTimeDaily');
let { receiveBoxs = [], donateCnt = 0, receivedActive = [], encourageCnt = 0, bossChallengeCnt = 0, receivedWishPool = [], wishGoods = [], wishDntCnt = 0, refTimeDaily, refBossTime, trainCount, buyTrainCount, trainTime } = lastGuild||{};
let { receiveBoxs = [], donateCnt = 0, receivedActive = [], encourageCnt = 0, bossChallengeCnt = 0, receivedWishPool = [], wishGoods = [], wishDntCnt = 0, refTimeDaily, refBossTime, trainCount, buyTrainCount, trainTime, trainRewards = [] } = lastGuild||{};
const doc = new UserGuildModel();
let job = isLeader? GUILD_JOB.DAJIANGJUN: GUILD_JOB.SHIBING;
let auth = isLeader? GUILD_AUTH.LEADER: GUILD_AUTH.MEMBER;
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 });
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 });
// trainRewards: 试炼奖励, 无论在任何情况下都不能被清空(次数可以重置,奖励领过就不能再领了,无论在哪个军团)
// 【退出军团】 和 【再加入军团】在同一天
if (isToday(role.quitGuildTime)) {
// 同一个军团: 所有数据保留; 不同军团: 许愿池数据清空,当天不允许许愿,其他数据保留