diff --git a/game-server/app/servers/gm/handler/gmHandler.ts b/game-server/app/servers/gm/handler/gmHandler.ts index 513d2c08c..a7b1d4419 100644 --- a/game-server/app/servers/gm/handler/gmHandler.ts +++ b/game-server/app/servers/gm/handler/gmHandler.ts @@ -86,6 +86,7 @@ export class GmHandler { if(needSend) { let f = new SendMailFun(); let code = await f.setWithGmMail(gmmail); + if(!code) return resResult(STATUS.GM_MAIL_CAN_NOT_SENT); if (mailType == GM_MAIL_TYPE.SINGLE || mailType == GM_MAIL_TYPE.GROUP) { let roleIds = receivers.filter(cur => cur.env == this.app.get('env')).map(cur => cur.roleId); diff --git a/game-server/app/services/activity/signInService.ts b/game-server/app/services/activity/signInService.ts index eb333a78a..f7ef6da66 100644 --- a/game-server/app/services/activity/signInService.ts +++ b/game-server/app/services/activity/signInService.ts @@ -82,10 +82,7 @@ export async function getPlayerSignInData(activityId: number, serverId: number, let serverTime = await getServerCreateTime(serverId); let playerData = new SignInData(activityData, createTime, serverTime); - console.log('##### getPlayerSignInData',activityId, roleId, playerData.roundIndex, playerData) let playerRecords: ActivitySignInModelType = await ActivitySignInModel.findData(activityId, roleId, playerData.roundIndex); - - console.log('##### getPlayerSignInData playerData', playerRecords, !!playerRecords) playerData.setPlayerRecords(playerRecords); return playerData; } diff --git a/game-server/app/services/gmService.ts b/game-server/app/services/gmService.ts index 685e15000..54c4202bb 100644 --- a/game-server/app/services/gmService.ts +++ b/game-server/app/services/gmService.ts @@ -169,8 +169,10 @@ export async function sendOpenServerMail(type: 'openMail'|'circleMail', mail: St if(needSend) { let f = new SendMailFun(); let code = await f.setWithGmMail(gmmail); - await f.createServerMails(code, [newServer.id]); - await f.pushToUsers(); + if(code) { + await f.createServerMails(code, [newServer.id]); + await f.pushToUsers(); + } } return true; } @@ -320,7 +322,6 @@ export async function getParamStr(activity: ActivityModelType, productID: string pkg = _pkg; item = _item; } } - console.log('&&&&&', item) if(item.isPushing) { param['code'] = item.code; } else { diff --git a/game-server/app/services/mailService.ts b/game-server/app/services/mailService.ts index e916ba138..f5a50c507 100644 --- a/game-server/app/services/mailService.ts +++ b/game-server/app/services/mailService.ts @@ -5,7 +5,7 @@ import { ServerMailModel, ServerMailType } from '../db/ServerMail'; import { getRoleOnlineInfo } from "./redisService"; import { pinus } from "pinus"; import { gameData } from "../pubUtils/data"; -import { nowSeconds } from '../pubUtils/timeUtil'; +import { getCurDay, nowSeconds } from '../pubUtils/timeUtil'; import { STATUS } from '../consts/statusCode'; import { genCode, resResult } from '../pubUtils/util'; import { GM_MAIL_TYPE, ITID, MAIL_STATUS, MAIL_TIME_TYPE, MAIL_TYPE, PUSH_ROUTE, SEND_NAME, SEND_TITLE } from "../consts"; @@ -106,7 +106,20 @@ class MailTemp { } else if (gmmail.timeType == MAIL_TIME_TYPE.DELAY) { this.sendTime = gmmail.startTime; } else if (gmmail.timeType == MAIL_TIME_TYPE.CIRCLE) { - this.sendTime = moment(moment().format('YYYY-MM-DD ' + gmmail.circleHour)).unix(); + let time = moment(moment().format('YYYY-MM-DD ' + gmmail.circleHour)).unix(); + if(time < nowSeconds()) { + if(gmmail.circleDay == 0) { + time += 86400; + } else { + let date = getCurDay(true); // 今天星期几 + if(date < gmmail.circleDay) { + time += (gmmail.circleDay - date) * 86400; + } else { + time += (7 + date - gmmail.circleDay) * 86400; + } + } + } + this.sendTime = time; } this.endTime = this.sendTime + gmmail.expire * 60 * 60; this.sendName = gmmail.sendName; @@ -114,7 +127,7 @@ class MailTemp { this.content = gmmail.content; this.hasGoods = gmmail.hasGoods; this.goods = gmmail.goods; - return gmmail; + return true; } private getContent(content: string, params: string[] = []) { @@ -164,7 +177,8 @@ export class SendMailFun { // 从GMMail表读取数据 public async setWithGmMail(gmmail: GMMailType) { let mailTemp = new MailTemp(); - mailTemp.setWithGmMail(gmmail); + let canSet = mailTemp.setWithGmMail(gmmail); + if(!canSet) return false this.mailTemps.set(mailTemp.code, mailTemp); return mailTemp.code; } diff --git a/game-server/app/services/redisService.ts b/game-server/app/services/redisService.ts index 8f411af04..34f23caf1 100644 --- a/game-server/app/services/redisService.ts +++ b/game-server/app/services/redisService.ts @@ -1,7 +1,6 @@ -import { ACTIVITY_TYPE, COM_BTL_QUALITY, getRedisKeyByRankType, GUILD_ACTIVITY_TYPE } from './../consts'; +import { ACTIVITY_TYPE, getRedisKeyByRankType, GUILD_ACTIVITY_TYPE } from './../consts'; import * as Redis from 'redis'; import {REDIS_KEY} from '../consts' -import { GameModel } from "../db/Game"; import { pinus, ServerInfo } from 'pinus'; import { GuildRankParam, GuildLeader, RankParam, LineupParam } from '../domain/rank'; import { comBtlRanges } from '../pubUtils/data'; diff --git a/game-server/app/services/timeTaskService.ts b/game-server/app/services/timeTaskService.ts index 471de8ba7..f9b614144 100644 --- a/game-server/app/services/timeTaskService.ts +++ b/game-server/app/services/timeTaskService.ts @@ -427,10 +427,11 @@ async function sendCircleMail() { let gmmails = await GMMailModel.findCircleMails(pinus.app.get('env')); let f = new SendMailFun(); for(let gmmail of gmmails) { - let { receivers, mailType, sendTimes } = gmmail; + let { receivers, mailType, sendTimes, circleStart, circleEnd } = gmmail; let code = await f.setWithGmMail(gmmail); + if(!code) continue; let mapTemp = f.getMailTemp(code); - if(sendTimes.indexOf(mapTemp.sendTime) == -1) { + if(sendTimes.indexOf(mapTemp.sendTime) == -1 && circleStart <= mapTemp.sendTime && circleEnd >= mapTemp.sendTime) { if(mailType == GM_MAIL_TYPE.SINGLE) { await f.createSingleMails(code, receivers.map(cur => cur.roleId)); } else if (mailType == GM_MAIL_TYPE.GROUP) { diff --git a/gm-server/app/service/Game.ts b/gm-server/app/service/Game.ts index eb3574f01..ff4cdf92d 100644 --- a/gm-server/app/service/Game.ts +++ b/gm-server/app/service/Game.ts @@ -1,6 +1,5 @@ import { Service } from 'egg'; import { STATUS } from '@consts'; -// import { GameModel } from '@db/Game'; import { ServerlistModel } from '@db/Serverlist'; import { gameData } from '@pubUtils/data'; import { DicHero } from '@pubUtils/dictionary/DicHero'; diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index b9222767e..417870e2a 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -498,6 +498,7 @@ export const STATUS = { GM_MARQUEE_CANCEL_ERR: { code: 60023, simStr: '取消失败' }, GM_MAIL_NOT_FOUND: { code: 60024, simStr: '未找到该邮件' }, GM_MAIL_HAS_SENT: { code: 60025, simStr: '邮件已经审批过了' }, + GM_MAIL_CAN_NOT_SENT: { code: 60026, simStr: '邮件不可发送' }, // 支付相关状态 70000 - 79999 NO_PRODUCT_ID: { code: 70001, simStr: '无效商品' }, NO_PAY_TYPE: { code: 70002, simStr: '无效支付类型' }, diff --git a/shared/db/GroupMail.ts b/shared/db/GroupMail.ts index 9ba13e6f4..d1efba83f 100644 --- a/shared/db/GroupMail.ts +++ b/shared/db/GroupMail.ts @@ -33,6 +33,7 @@ export default class GroupMail extends MailTemp { {'roleStatus.roleId': roleId}, {'roleStatus.status': { $in: [ MAIL_STATUS.CREATE, MAIL_STATUS.READ, MAIL_STATUS.RECEIVED ] }} ], + sendTime: { $lte: nowSeconds() } , endTime: { $gte: nowSeconds() } }).populate('mail').lean(); return result; diff --git a/shared/db/Mail.ts b/shared/db/Mail.ts index fba9d8e57..c7225ef6f 100644 --- a/shared/db/Mail.ts +++ b/shared/db/Mail.ts @@ -21,6 +21,7 @@ export default class Mail extends MailTemp { const result: MailType[] = await MailModel.find({ roleId, status: { $in: [ MAIL_STATUS.CREATE, MAIL_STATUS.READ, MAIL_STATUS.RECEIVED ] }, + sendTime: { $lte: nowSeconds()} , endTime: { $gte: nowSeconds() } }).populate('mail').lean(); return result; diff --git a/shared/db/ServerMail.ts b/shared/db/ServerMail.ts index 61ee895d6..eda880d2c 100644 --- a/shared/db/ServerMail.ts +++ b/shared/db/ServerMail.ts @@ -33,6 +33,7 @@ export default class ServerMail extends MailTemp { const result: ServerMailType[] = await ServerMailModel.find({ serverId, delRoles: { $ne: roleId }, + sendTime: { $lte: nowSeconds() } , endTime: { $gte: nowSeconds() } }).populate('mail').lean(); return result;