军团:fix拒绝邀请未删除条目,升级建筑去锁
This commit is contained in:
@@ -338,7 +338,7 @@ export class GuildHandler {
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.GET_APPLY_LIST, roleId);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const result = await UserGuildApplyModel.getListByGuild(code, lastApplyCode);
|
||||
const result = await UserGuildApplyModel.findApplyByGuild(code, lastApplyCode);
|
||||
const list = [];
|
||||
for(let cur of result) {
|
||||
let role = <RoleType>cur.role;
|
||||
@@ -385,7 +385,7 @@ export class GuildHandler {
|
||||
await sendMail(MAIL_TYPE.GUILD_APPLY_REFUSE, roleId, roleName, [guild.name]);
|
||||
}
|
||||
|
||||
await UserGuildApplyModel.deleteApplyByApplyCode(applyCodeList);
|
||||
await UserGuildApplyModel.deleteByApplyCode(applyCodeList);
|
||||
}
|
||||
|
||||
return resResult(STATUS.SUCCESS, { roleIds });
|
||||
@@ -460,7 +460,7 @@ export class GuildHandler {
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.GET_INVITATION_LIST, roleId);
|
||||
if(!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
const result = await UserGuildApplyModel.getListByRole(roleId, lastApplyCode);
|
||||
const result = await UserGuildApplyModel.findInviteByRole(roleId, lastApplyCode);
|
||||
const list = result.map(cur => {
|
||||
let guild = <GuildType>cur.guild;
|
||||
let leader = <RoleType>guild.leader;
|
||||
@@ -505,7 +505,7 @@ export class GuildHandler {
|
||||
|
||||
code = guild.code;
|
||||
}
|
||||
await UserGuildApplyModel.deleteApplyByApplyCode([applyCode]); // 删除这条邀请
|
||||
await UserGuildApplyModel.deleteByApplyCode([applyCode]); // 删除这条邀请
|
||||
|
||||
return resResult(STATUS.SUCCESS, { applyCode, code, isReceived, hasGuild: isReceived });
|
||||
}
|
||||
@@ -727,44 +727,30 @@ export class GuildHandler {
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.UP_STRUCTURE, roleId, code);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
let res:any = await lockData(serverId, DATA_NAME.UP_STRUCTURE, code);// 加锁
|
||||
if (!!res.err) return resResult(STATUS.REDLOCK_ERR);
|
||||
|
||||
const guild = await GuildModel.findByCode(code, serverId, 'lv structure');
|
||||
if(!guild) {
|
||||
res.releaseCallback();//解锁
|
||||
return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
}
|
||||
|
||||
const { lv, structure } = guild;
|
||||
const curStructure = structure.find(cur => cur.id == id);
|
||||
if(!curStructure) {
|
||||
res.releaseCallback(); //解锁
|
||||
return resResult(STATUS.GUILD_STRUCTURE_NOT_FOUND);
|
||||
}
|
||||
if(id != GUILD_STRUCTURE.ARMY_CENTER && curStructure.lv >= lv) { // 中军大帐以外建筑物
|
||||
if(curStructure.lv >= lv) {
|
||||
res.releaseCallback(); //解锁
|
||||
return resResult(STATUS.GUILD_STRUCTURE_LV_MAX);
|
||||
}
|
||||
}
|
||||
if(!hasStructureConsume(id, curStructure.lv + 1)) {
|
||||
res.releaseCallback(); //解锁
|
||||
return resResult(STATUS.GUILD_STRUCTURE_LV_MAX);
|
||||
}
|
||||
const cost = getStructureConsume(id, curStructure.lv);
|
||||
const costResult = await GuildModel.costFund(code, cost);
|
||||
if(!costResult) {
|
||||
res.releaseCallback(); //解锁
|
||||
|
||||
const result = await GuildModel.upStructure(code, id, cost, 'code fund structure lv');
|
||||
if(!result) {
|
||||
return resResult(STATUS.GUILD_FUND_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
const result = await GuildModel.upStructure(code, id, 'code fund structure lv');
|
||||
if(!result) {
|
||||
res.releaseCallback(); //解锁
|
||||
return resResult(STATUS.GUILD_STRUCTURE_NOT_FOUND);
|
||||
}
|
||||
res.releaseCallback(); //解锁
|
||||
const resultStructure = result.structure.find(cur => cur.id == id);
|
||||
|
||||
// 修改信息
|
||||
|
||||
@@ -5,7 +5,6 @@ export enum DATA_NAME {
|
||||
GUILD = 'Guild',
|
||||
GUILD_REFINE = 'GuildRefine',
|
||||
GUILD_ASSIST_REFINE = 'GuildAssistRefine',
|
||||
UP_STRUCTURE = 'GuildStructure',
|
||||
JOIN_GUILD = 'JoinGuild',
|
||||
REFRESH_ACTIVE = 'GuildRefActive',
|
||||
WEEKLY_GUILD_SUM = 'WeeklyGuildSum', // 每周结算活跃和奖励
|
||||
|
||||
@@ -182,12 +182,12 @@ export default class Guild extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async upStructure(code: string, id: number, select?: string) {
|
||||
public static async upStructure(code: string, id: number, cost: number, select?: string) {
|
||||
if (id == GUILD_STRUCTURE.ARMY_CENTER) {
|
||||
const result: GuildType = await GuildModel.findOneAndUpdate({ code, 'structure.id': id }, { $inc: { 'structure.$.lv': 1, lv: 1 }, $set: { isMemberMax: false } }, { new: true }).select(select).lean();
|
||||
const result: GuildType = await GuildModel.findOneAndUpdate({ code, 'structure.id': id, fund: { $gte: cost } }, { $inc: { 'structure.$.lv': 1, lv: 1, fund: -1 * cost }, $set: { isMemberMax: false } }, { new: true }).select(select).lean();
|
||||
return result;
|
||||
} else {
|
||||
const result: GuildType = await GuildModel.findOneAndUpdate({ code, 'structure.id': id }, { $inc: { 'structure.$.lv': 1 } }, { new: true }).select(select).lean();
|
||||
const result: GuildType = await GuildModel.findOneAndUpdate({ code, 'structure.id': id, fund: { $gte: cost } }, { $inc: { 'structure.$.lv': 1, fund: -1 * cost } }, { new: true }).select(select).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ export default class UserGuildApply extends BaseModel {
|
||||
}
|
||||
|
||||
// 根据唯一code批量删除
|
||||
public static async deleteApplyByApplyCode(applyCodeList: string[]) {
|
||||
const result = await UserGuildApplyModel.deleteMany({ applyCode: { $in: applyCodeList}, type: GUILD_APPLY_TYPE.APPLY });
|
||||
public static async deleteByApplyCode(applyCodeList: string[]) {
|
||||
const result = await UserGuildApplyModel.deleteMany({ applyCode: { $in: applyCodeList} });
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export default class UserGuildApply extends BaseModel {
|
||||
}
|
||||
|
||||
// 查询公会收到的申请
|
||||
public static async getListByGuild(code: string, lastApplyCode: string) {
|
||||
public static async findApplyByGuild(code: string, lastApplyCode: string) {
|
||||
let condition = { guildCode: code, type: GUILD_APPLY_TYPE.APPLY };
|
||||
if(lastApplyCode) {
|
||||
const lastApply = await this.findByCode(lastApplyCode);
|
||||
@@ -85,7 +85,7 @@ export default class UserGuildApply extends BaseModel {
|
||||
}
|
||||
|
||||
// 查询玩家的邀请列表
|
||||
public static async getListByRole(roleId: string, lastApplyCode: string) {
|
||||
public static async findInviteByRole(roleId: string, lastApplyCode: string) {
|
||||
let condition = { roleId, type: GUILD_APPLY_TYPE.INVITE };
|
||||
if(lastApplyCode) {
|
||||
const lastApply = await this.findByCode(lastApplyCode);
|
||||
|
||||
Reference in New Issue
Block a user