邮件
This commit is contained in:
@@ -258,14 +258,15 @@ export class GuildTrainHandler {
|
|||||||
|
|
||||||
let { shilianRewardRatio } = getTrainBaseByLv(trainLv);
|
let { shilianRewardRatio } = getTrainBaseByLv(trainLv);
|
||||||
let { heroRewards, trainInstances } = getArmyTrainJuDian(trainId);
|
let { heroRewards, trainInstances } = getArmyTrainJuDian(trainId);
|
||||||
let { progress } = findWhere(trainInstances, {hid});
|
let { progress } = findWhere(trainInstances, { hid });
|
||||||
|
console.log('progress = ' + progress);
|
||||||
let guildTrain = await GuildTrainModel.findTrainInstanceBoxByIndex(code, trainId, hid, progress);
|
let guildTrain = await GuildTrainModel.findTrainInstanceBoxByIndex(code, trainId, hid, progress);
|
||||||
if (!guildTrain) {
|
if (!guildTrain) {
|
||||||
res.releaseCallback();//解锁
|
res.releaseCallback();//解锁
|
||||||
return resResult(STATUS.GUILD_TRAIN_SCRIPT_NOT_OPENED);
|
return resResult(STATUS.GUILD_TRAIN_SCRIPT_NOT_OPENED);
|
||||||
}
|
}
|
||||||
let trainInstance = findWhere(guildTrain.trainInstances, { hid });
|
let trainInstance = findWhere(guildTrain.trainInstances, { hid });
|
||||||
if (trainInstance.endTime > nowSeconds())
|
if (trainInstance.endTime < nowSeconds())
|
||||||
return resResult(STATUS.GUILD_TRAIN_BOX_IS_OVER_TIME);
|
return resResult(STATUS.GUILD_TRAIN_BOX_IS_OVER_TIME);
|
||||||
let trainBox = findWhere(trainInstance.trainBoxs, { index })
|
let trainBox = findWhere(trainInstance.trainBoxs, { index })
|
||||||
if (!!trainBox)
|
if (!!trainBox)
|
||||||
|
|||||||
@@ -53,17 +53,20 @@ export class RoleHandler {
|
|||||||
return resResult(STATUS.WRONG_PARMS);
|
return resResult(STATUS.WRONG_PARMS);
|
||||||
}
|
}
|
||||||
} else {//一键删除
|
} else {//一键删除
|
||||||
let groupMailIds = await GroupMailModel.findReadAndRewardsMails(roleId);
|
|
||||||
await GroupMailModel.updateMailStatus(groupMailIds, MAIL_STATUS.DELETE, roleId);
|
|
||||||
let mailIds = await MailModel.findReadAndRewardsMails(roleId);
|
|
||||||
await MailModel.updateMailStatus(mailIds, MAIL_STATUS.DELETE);
|
|
||||||
let mails = [];
|
let mails = [];
|
||||||
groupMailIds.map((id)=>{
|
let resGroupMailIds = await GroupMailModel.findReadAndRewardsMails(roleId);
|
||||||
mails.push({id, status: MAIL_STATUS.DELETE, mailType: MAIL_TYPE.GROUPMAIL});
|
let groupMailIds: string[] = resGroupMailIds.map(({_id})=>{
|
||||||
|
mails.push({id:_id, status: MAIL_STATUS.DELETE, mailType: MAIL_TYPE.GROUPMAIL});
|
||||||
|
return _id;
|
||||||
});
|
});
|
||||||
mailIds.map((id)=>{
|
await GroupMailModel.updateMailStatus(groupMailIds, MAIL_STATUS.DELETE, roleId);
|
||||||
mails.push({id, status: MAIL_STATUS.DELETE, mailType: MAIL_TYPE.SINGLEMAIL});
|
let resMailIds = await MailModel.findReadAndRewardsMails(roleId);
|
||||||
|
let mailIds: string[] = resMailIds.map(({_id})=>{
|
||||||
|
mails.push({id: _id, status: MAIL_STATUS.DELETE, mailType: MAIL_TYPE.SINGLEMAIL});
|
||||||
|
return _id;
|
||||||
});
|
});
|
||||||
|
await MailModel.updateMailStatus(mailIds, MAIL_STATUS.DELETE);
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { mails });
|
return resResult(STATUS.SUCCESS, { mails });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,6 +179,9 @@ export const STATUS = {
|
|||||||
GUILD_TRAIN_IS_NOT_COMPLETE: { code: 20968, simStr: '军团该训练场没有完成' },
|
GUILD_TRAIN_IS_NOT_COMPLETE: { code: 20968, simStr: '军团该训练场没有完成' },
|
||||||
GUILD_TRAIN_QUALITY_REWARD_IS_GOT: { code: 20969, simStr: '军团训练进阶奖励已经领取' },
|
GUILD_TRAIN_QUALITY_REWARD_IS_GOT: { code: 20969, simStr: '军团训练进阶奖励已经领取' },
|
||||||
GUILD_PERSITION_TREE_NOT_LIGHT: { code: 20970, simStr: '军团前置科技树未研发' },
|
GUILD_PERSITION_TREE_NOT_LIGHT: { code: 20970, simStr: '军团前置科技树未研发' },
|
||||||
|
GUILD_TRAIN_BOX_IS_OVER_TIME: { code: 20971, simStr: '军团宝箱超时' },
|
||||||
|
GUILD_TRAIN_BOX_INDEX_IS_GOT:{ code: 20972, simStr: '该位置试炼宝箱已经领取过,请重新选择' },
|
||||||
|
GUILD_TRAIN_BOX_IS_GOT: { code: 20973, simStr: '玩家已经领取该试炼宝箱' },
|
||||||
// 通用 30000 - 30099
|
// 通用 30000 - 30099
|
||||||
DIC_DATA_NOT_FOUND: { code: 30000, simStr: '数据表未找到' },
|
DIC_DATA_NOT_FOUND: { code: 30000, simStr: '数据表未找到' },
|
||||||
ROLE_MATERIAL_NOT_ENOUGH: { code: 30001, simStr: '材料数量不足' },
|
ROLE_MATERIAL_NOT_ENOUGH: { code: 30001, simStr: '材料数量不足' },
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ export default class GroupMail extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async findReadAndRewardsMails(roleId: string, lean = true) {
|
public static async findReadAndRewardsMails(roleId: string, lean = true) {
|
||||||
const ids: string[] = await GroupMailModel.find({ 'sendRoles.roleId': roleId, sendTime:{$lte: nowSeconds()}, $or:[ {$and: [{'sendRoles.status': MAIL_STATUS.READ, goods: []}]}, {'sendRoles.status': MAIL_STATUS.RECEIVED}] }).select('_id').lean(lean);
|
const ids: GroupMailType[] = await GroupMailModel.find({ 'sendRoles.roleId': roleId, sendTime:{$lte: nowSeconds()}, $or:[ {$and: [{'sendRoles.status': MAIL_STATUS.READ, goods: []}]}, {'sendRoles.status': MAIL_STATUS.RECEIVED}] }).select('_id').lean(lean);
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export default class GuildTrain extends BaseModel {
|
|||||||
|
|
||||||
public static async updateGuildTrainProgress(guildCode: string, trainId: number, hid:number, progress: number, ranks:Array<Rank>, isComplete: boolean,lean = true) {
|
public static async updateGuildTrainProgress(guildCode: string, trainId: number, hid:number, progress: number, ranks:Array<Rank>, isComplete: boolean,lean = true) {
|
||||||
const guildTrain: GuildTrainType = await GuildTrainModel.findOneAndUpdate({ guildCode, trainId, 'trainInstances.hid':hid},
|
const guildTrain: GuildTrainType = await GuildTrainModel.findOneAndUpdate({ guildCode, trainId, 'trainInstances.hid':hid},
|
||||||
{ $set: {'trainInstances.$.progress': progress, ranks, isComplete,'trainInstances.$.endTime': nowSeconds() + 24*60*60} },{new: true}).lean(lean);
|
{ $set: {'trainInstances.$.progress': progress, ranks, isComplete,'trainInstances.$.endTime': (nowSeconds() + 24 * 60 * 60)} },{new: true}).lean(lean);
|
||||||
|
|
||||||
return guildTrain;
|
return guildTrain;
|
||||||
}
|
}
|
||||||
@@ -83,9 +83,8 @@ export default class GuildTrain extends BaseModel {
|
|||||||
return guildTrain;
|
return guildTrain;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async findTrainInstanceBoxByIndex(guildCode: string, roleId: string, trainId: number, hid: number, index: number, progress: number, time: number, locked = false, lean = true) {
|
public static async findTrainInstanceBoxByIndex(guildCode: string, trainId: number, hid: number, progress: number, locked = false, lean = true) {
|
||||||
const guildTrain: GuildTrainType = await GuildTrainModel.findOne({ guildCode, trainId, locked, 'trainInstances.hid': hid,
|
const guildTrain: GuildTrainType = await GuildTrainModel.findOne({ guildCode, trainId, locked, 'trainInstances.hid': hid, 'trainInstances.progress': {$gte: progress} }).lean(lean);
|
||||||
'trainInstances.trainBoxs.index':{$ne:index },'trainInstances.trainBoxs.roleId':{$ne:roleId }, 'trainInstances.progress': {$gte: progress}, 'trainInstances.endTime':{$gte: time}}).lean(lean);
|
|
||||||
return guildTrain;
|
return guildTrain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ export default class Mail extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async findReadAndRewardsMails(roleId: string, lean = true) {
|
public static async findReadAndRewardsMails(roleId: string, lean = true) {
|
||||||
const ids: string[] = await MailModel.find({ roleId, $or: [{ $and: [{ status: MAIL_STATUS.READ, goods: [] }] }, { status: MAIL_STATUS.RECEIVED }], sendTime:{$lte: nowSeconds()} }).select('_id').lean(lean);
|
const ids: MailType[] = await MailModel.find({ roleId, $or: [{ $and: [{ status: MAIL_STATUS.READ, goods: [] }] }, { status: MAIL_STATUS.RECEIVED }], sendTime:{$lte: nowSeconds()} }).select('_id').lean(lean);
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user