🐞 fix(guild): 修复军团退出重进数据重置问题

This commit is contained in:
dingchaolin
2023-02-27 20:31:12 +08:00
parent b75f21fcf3
commit 6f3859df16
4 changed files with 75 additions and 6 deletions
@@ -8,13 +8,13 @@ import { gameData, getGoodById, getWishPoolReward } from '../../../pubUtils/data
import { addItems, checkGoods, checkHeroEquips, checkHeroes, getHonourObject, handleCost } from '../../../services/role/rewardService';
import { ITID, CONSUME_TYPE } from '../../../consts/constModules/itemConst';
import { GUILD_POINT_WAYS, GUILD_STRUCTURE, WISH_POOL_TYPE } from '../../../consts/constModules/guildConst';
import { getWishPool, getUserGuildWithRefActive, addActive } from '../../../services/guildService';
import { getWishPool, getUserGuildWithRefActive, addActive, canWishToday } from '../../../services/guildService';
import { findIndex, findWhere } from 'underscore';
import { RoleModel } from '../../../db/Role';
import { getRoleOnlineInfo } from '../../../services/redisService';
import { ARMY } from '../../../pubUtils/dicParam';
import { guildInter } from '../../../pubUtils/interface';
import { getSeconds, getZeroPoint, nowSeconds } from '../../../pubUtils/timeUtil';
import { getSeconds, getZeroPoint, nowSeconds, isToday } from '../../../pubUtils/timeUtil';
import { sendMessageToUserWithSuc } from '../../../services/pushService';
import { isGoodsHidden } from '../../../services/dataService';
export default function(app: Application) {
@@ -51,6 +51,11 @@ export class WishPoolHandler {
let userGuild = await getUserGuildWithRefActive(roleId);
if (!userGuild) return resResult(STATUS.WRONG_PARMS);
// 退出A军团 和 新入B军团 在同一天, 且在A军团已经许过愿,那么此时不允许许愿
if (!await canWishToday(roleId)) {
return resResult(STATUS.HAS_REACH_WISH_COUNT_LIMIT);
}
const { guildCode: code, wishGoods, receivedWishPool } = userGuild;
let { lv } = await GuildModel.findGuild(code, serverId, 'lv');
+31 -1
View File
@@ -29,6 +29,7 @@ import { BattleRecordModel } from "../db/BattleRecord";
import { BossInstanceModel } from "../db/BossInstance";
import { pick } from "underscore";
import { memberJoinGuildToLeague } from "./gvg/gvgTeamService";
import { isToday } from '../pubUtils/timeUtil';
export async function getMyGuildInfo(roleId: string, sid: string, userGuild: UserGuildType, guild: GuildType, serverId: number, session: FrontendOrBackendSession) {
@@ -141,7 +142,10 @@ export async function joinGuild(code: string, guildName: string, lv: number, rol
}
//成长任务-加入军团
await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_JOIN);
if (!isToday(role.quitGuildTime)) {
// 离开军团 和 加入进团 不是同一天,才新建初始化任务(包含首次加入)
await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_JOIN);
}
return { status: 0, guild, userGuild, roleName: role.roleName, memberCnt: guild.memberCnt, guildCe: guild.guildCe }
}
@@ -234,6 +238,32 @@ export async function getUserGuildWithRefActive(roleId: string, select?: string)
return userGuild;
}
/**
* 今天在军团中是否能许愿
*
* @export
* @param {string} roleId
*/
export async function canWishToday(roleId: string): Promise<Boolean> {
let role = await RoleModel.findByRoleId(roleId);
if (!role) {
return false;
}
let userGuild = await UserGuildModel.findMyLastGuild(roleId, ' wishGoods');
if (!userGuild) {
return true;
}
// 今天退出过军团 & 在退出的军团许过愿
if (isToday(role.quitGuildTime) && (userGuild.wishGoods && userGuild.wishGoods.length > 0)) {
// 新加入的军团不允许许愿
return false;
}
return true;
}
async function sendUnreceivedWishPool(wishGoods: WishGood[], roleId: string) {
wishGoods.map(async function ({ donateNames, goodId, drawCnt }) {
let goodInfo = getGoodById(goodId)