许愿池继承问题
This commit is contained in:
@@ -49,12 +49,12 @@ export class WishPoolHandler {
|
||||
let userGuild = await refreshUserGuild(myUserGuild, roleId);
|
||||
if (!userGuild) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
const { guildCode: code, wishGoods, receivedWishPool, createdAt } = userGuild;
|
||||
const { guildCode: code, wishGoods, receivedWishPool } = userGuild;
|
||||
|
||||
let { lv } = await GuildModel.findGuild(code, serverId, 'lv');
|
||||
let len = wishGoods.filter(cur => cur.type == type).length;
|
||||
|
||||
if(receivedWishPool.indexOf(type) != -1 && getSeconds(createdAt) > getZeroPoint()) {
|
||||
if(receivedWishPool.indexOf(type) != -1) {
|
||||
return resResult(STATUS.HAS_REACH_WISH_COUNT_LIMIT);
|
||||
}
|
||||
if (len >= ARMY.ARMY_WISH_TIMES) //今日已经许愿过
|
||||
@@ -70,7 +70,7 @@ export class WishPoolHandler {
|
||||
|
||||
const id = genCode(6);
|
||||
let { wishGoods: resWishGoods } = await UserGuildModel.pushAndUpdate(roleId, {}, { wishGoods: { type, goodId, count, receiveCnt: 0, drawCnt: 0, id, donateNames:[]} }, 'wishGoods');
|
||||
return resResult(STATUS.SUCCESS, { wishGoods: resWishGoods });
|
||||
return resResult(STATUS.SUCCESS, { wishGoods: resWishGoods, receivedWishPool });
|
||||
}
|
||||
|
||||
// 捐赠
|
||||
@@ -147,7 +147,7 @@ export class WishPoolHandler {
|
||||
if (!result)
|
||||
resResult(STATUS.INTERNAL_ERR);
|
||||
let goods = await addItems(roleId, roleName, sid, [{ id : goodId, count: drawCnt }], ITEM_CHANGE_REASON.WISH_POOL_RECEIVE);
|
||||
return resResult(STATUS.SUCCESS, { goods, wishGoods });
|
||||
return resResult(STATUS.SUCCESS, { goods, wishGoods, receivedWishPool });
|
||||
}
|
||||
|
||||
async getReports(msg: guildInter & {}, session: BackendSession) {
|
||||
|
||||
@@ -370,16 +370,23 @@ export async function settleGuildWeekly() {
|
||||
|
||||
|
||||
export async function getWishPool(userGuild: UserGuildType) {
|
||||
const { guildCode: code, wishDntCnt, wishGoods } = userGuild;
|
||||
let { guildCode: code, wishDntCnt, wishGoods, receivedWishPool, refTimeDaily } = userGuild;
|
||||
|
||||
const now = new Date();
|
||||
let isRefDaily = shouldRefresh(refTimeDaily, now);
|
||||
// console.log('####### isRefDaily', isRefDaily, refTimeDaily, now)
|
||||
if (isRefDaily) {
|
||||
wishGoods = []; receivedWishPool = [], wishDntCnt = 0;
|
||||
}
|
||||
|
||||
let userGuilds = await UserGuildModel.getWishPoolGoods(code, ' wishDntCnt wishGoods roleId');
|
||||
let list = [];
|
||||
userGuilds.map(({ wishGoods, roleId }) => {
|
||||
wishGoods.map(({ type, goodId, count, receiveCnt, drawCnt, id }) => {
|
||||
userGuilds.forEach(({ wishGoods, roleId }) => {
|
||||
wishGoods.forEach(({ type, goodId, count, receiveCnt, drawCnt, id }) => {
|
||||
list.push({ type, goodId, count, receiveCnt, drawCnt, id, roleId })
|
||||
});
|
||||
});
|
||||
return { list, wishDntCnt: wishDntCnt || 0, wishGoods };
|
||||
return { list, wishDntCnt: wishDntCnt || 0, wishGoods, receivedWishPool };
|
||||
}
|
||||
|
||||
export function setUserGuildSession(session:FrontendOrBackendSession, myUserGuild: UserGuildType) {
|
||||
|
||||
@@ -144,14 +144,12 @@ 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 = [], refTimeDaily, refBossTime } = lastGuild||{};
|
||||
|
||||
|
||||
let { receiveBoxs = [], donateCnt = 0, receivedActive = [], encourageCnt = 0, bossChallengeCnt = 0, receivedWishPool = [], refTimeDaily, refBossTime, trainCount, buyTrainCount, trainTime } = 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, refTimeDaily, refBossTime });
|
||||
const update = Object.assign(doc.toJSON(), { guildCode, roleId: role.roleId, role: role._id, job, auth, receiveBoxs, donateCnt, receivedActive, encourageCnt, bossChallengeCnt, receivedWishPool, refTimeDaily, refBossTime, trainCount, buyTrainCount, trainTime });
|
||||
delete update._id;
|
||||
|
||||
const result: UserGuildType = await UserGuildModel.findOneAndUpdate({ roleId: role.roleId, guildCode, status: USER_GUILD_STATUS.ON }, { $set: update }, { upsert: true, new: true })
|
||||
|
||||
Reference in New Issue
Block a user