diff --git a/game-server/app/services/connectorService.ts b/game-server/app/services/connectorService.ts index 85e6f2bcf..d03d54182 100644 --- a/game-server/app/services/connectorService.ts +++ b/game-server/app/services/connectorService.ts @@ -34,6 +34,8 @@ import UserGuild, { UserGuildType } from '../db/UserGuild'; import { setMedianCe } from './guildActivityService'; import { getAllOnlineRoles } from './redisService'; import Item from '../db/Item'; +import { PvpDefenseModel } from '../db/PvpDefense'; +import { findPvpDefAllByRoleId } from './pvpService'; export async function pushData(role: RoleType, session: FrontendOrBackendSession, pushType: 'entry'|'refresh' = 'entry') { try{ @@ -92,8 +94,7 @@ export async function pushData(role: RoleType, session: FrontendOrBackendSession case 'dungeon': // 秘境 return await getDungeonData(role); case 'pvp': // pvp - const hasSeasonReward = await getPvpEntryData(roleId); - return { hasSeasonReward } + return await getPvpEntryData(roleId); case 'gacha': return await getGachaList(roleId); case 'school': @@ -175,7 +176,14 @@ async function getPvpEntryData(roleId: string) { let { oldSeasonData, show} = pvpSeasonResult; // 旧赛季结算的时候,会在pvpSeasonResult表中存上一赛季的时间,并更新show字段 - return oldSeasonData.seasonEndTime <= nowSeconds() && show; + let hasSeasonReward = oldSeasonData.seasonEndTime <= nowSeconds() && show; + let pvpDefense = await PvpDefenseModel.findByRoleIdIncludeAll(roleId); + if(pvpDefense) { + let { pvpDefense, } = await findPvpDefAllByRoleId(roleId); + let { challengeCnt, receivedBox, score } = pvpDefense; + + return { hasSeasonReward, challengeCnt, score, receivedBox } + } } /** diff --git a/game-server/app/services/pvpService.ts b/game-server/app/services/pvpService.ts index 7cb999fad..e65ca1d1b 100644 --- a/game-server/app/services/pvpService.ts +++ b/game-server/app/services/pvpService.ts @@ -486,7 +486,7 @@ export async function findPvpDefAllByRoleId(roleId: string) { pvpDefense.challengeRefTime = challengeRefTime; } pvpDefense.seasonNum = seasonNum; - let {challengeCnt, challengeRefTime} = refresh(pvpDefense.challengeCnt, pvpDefense.challengeRefTime, seasonNum); + let {challengeCnt, challengeRefTime} = refresh(pvpDefense.challengeCnt, pvpDefense.challengeRefTime, seasonEndTime); let { refOppCnt, refOppTime, shouldRefOpp } = getRefOppCnt(pvpDefense.refOppCnt, pvpDefense.refOppTime); // 刷新次数 if (challengeCnt != pvpDefense.challengeCnt || refOppCnt != pvpDefense.refOppCnt || shouldRefOpp) { let update: pvpUpdateInter = { diff --git a/gm-server/app/controller/activity.ts b/gm-server/app/controller/activity.ts index 340d1e36f..da31d1b1b 100644 --- a/gm-server/app/controller/activity.ts +++ b/gm-server/app/controller/activity.ts @@ -12,12 +12,16 @@ export default class ActivityController extends Controller { public async updateActivity() { const { ctx } = this; const { activityId, groupId, beginTime, endTime, type, data } = ctx.request.body; - ctx.body = await ctx.service.activity.updateActivity(activityId, groupId, beginTime, endTime, type, data); + let checkActivity = await ctx.service.activity.checkActivityEditable(activityId); + if(checkActivity) return ctx.body = checkActivity; + return ctx.body = await ctx.service.activity.updateActivity(activityId, groupId, beginTime, endTime, type, data); } public async deleteActivity() { const { ctx } = this; const { activityId } = ctx.request.body; + let checkActivity = await ctx.service.activity.checkActivityEditable(activityId); + if(checkActivity) return ctx.body = checkActivity; ctx.body = await ctx.service.activity.deleteActivity(activityId); } diff --git a/gm-server/app/service/Activity.ts b/gm-server/app/service/Activity.ts index aaa3be213..67750a32c 100644 --- a/gm-server/app/service/Activity.ts +++ b/gm-server/app/service/Activity.ts @@ -1,9 +1,10 @@ import { Service } from 'egg'; -import { STATUS } from '@consts'; +import { STATUS, ACTIVITY_TYPE } from '@consts'; import { ActivityModel } from '@db/Activity'; import { ActivityGroupModel } from '@db/ActivityGroup'; import { ServerlistModel } from '@db/Serverlist'; import { GMUserType } from '@db/GMUser'; +import { SignInData } from '@domain/activityField/signInField'; /** * Test Service @@ -27,6 +28,29 @@ export default class Activity extends Service { }); } + public async checkActivityEditable(activityId: number) { + let now = new Date(); + let activity = await ActivityModel.findActivity(activityId); + if(!activity) { + return this.ctx.service.utils.resResult(STATUS.ACTIVITY_MISSING); + } + if(this.app.config.env == 'production') { + if(activity.beginTime < now && activity.endTime > now) { + + if(activity.type == ACTIVITY_TYPE.SIGN_IN || activity.type == ACTIVITY_TYPE.SIGN_IN_VIP) { + // 签到活动的不显示期内也可以编辑 + let signInObj = new SignInData(activity); + if(signInObj.beginTime < now.getTime() && signInObj.endTime > now.getTime() ) { + return this.ctx.service.utils.resResult(STATUS.GM_CAN_NOT_EDIT_ACT); + } + } else { + return this.ctx.service.utils.resResult(STATUS.GM_CAN_NOT_EDIT_ACT); + } + } + } + return 0 + } + public async updateActivity(activityId: number | string, groupId: number, beginTime: number, endTime: number, type: number, data: string) { const { ctx } = this; let gmuser: GMUserType = ctx.user; diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index b9a1147e6..7dca339c8 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -379,6 +379,7 @@ export const STATUS = { GM_PVP_DEFENSE_HERO_NOT_FOUND: { code: 60013, simStr: '该守阵没有该武将' }, GM_JSON_FORMAT_ERR: { code: 60005, simStr: 'json格式错误' }, GM_CAN_NOT_DEL_ACT_GROUP: { code: 60006, simStr: '活动组有指向的服务器或活动,不可删除' }, + GM_CAN_NOT_EDIT_ACT: { code: 60007, simStr: '活动期间不可编辑活动' }, // 支付相关状态 70000 - 79999 NO_PRODUCT_ID: { code: 70001, simStr: '无效商品' }, NO_PAY_TYPE: { code: 70002, simStr: '无效支付类型' }, diff --git a/shared/pubUtils/taskUtil.ts b/shared/pubUtils/taskUtil.ts index fe8c5d94c..10897673c 100644 --- a/shared/pubUtils/taskUtil.ts +++ b/shared/pubUtils/taskUtil.ts @@ -1,6 +1,6 @@ import { gameData } from './data'; import { DicTask } from './dictionary/DicTask'; -import { TASK_TYPE, ABI_STAGE, WAR_TYPE, GUILD_JOB, TASK_FUN_TYPE, FUNCS_ID, STATUS } from '../consts'; +import { TASK_TYPE, ABI_STAGE, WAR_TYPE, GUILD_JOB, TASK_FUN_TYPE, FUNCS_ID } from '../consts'; import { UserTaskRecModel, UserTaskRecType } from '../db/UserTaskRec' import { RoleType, RoleModel } from '../db/Role'; import { TaskParam, TaskListReturn } from '../domain/roleField/task'; @@ -9,7 +9,7 @@ import { HeroType } from '../db/Hero'; import { EquipType, EquipModel } from '../db/Equip'; import { ItemInter } from './interface'; import { DailyChallengesData } from '../domain/activityField/dailyChallengesField'; -import { resResult, splitString } from './util'; +import { splitString } from './util'; import { ActivityModel, ActivityModelType } from '../db/Activity'; import { ACTIVITY_TYPE } from '../consts/constModules/activityConst'; import { ActivityGrowthModel } from '../db/ActivityGrowth'; @@ -648,7 +648,7 @@ export async function accomplishTask(serverId: number, roleId: string, taskType: //寻宝骑兵活动任务 let tempData: ServerTempModelType = await ServerTempModel.findData(serverId); if (tempData) { - let huntActivityId = tempData.huntActivityId; + // let huntActivityId = tempData.huntActivityId; let huntBeginTime = tempData.huntBeginTime; let huntEndTime = tempData.huntEndTime; let huntRoundIndex = tempData.huntRoundIndex;