diff --git a/game-server/app/servers/activity/handler/popUpShopHandler.ts b/game-server/app/servers/activity/handler/popUpShopHandler.ts index 2f40be650..2e1704752 100644 --- a/game-server/app/servers/activity/handler/popUpShopHandler.ts +++ b/game-server/app/servers/activity/handler/popUpShopHandler.ts @@ -8,6 +8,7 @@ import { PopUpShopData } from '../../../domain/activityField/popUpShopField'; import { addReward, stringToRewardParam } from '../../../services/giftPackageService'; import { RewardParam } from '../../../domain/activityField/rewardField'; import { handleCost } from '../../../services/rewardService'; +import moment = require('moment'); export default function (app: Application) { return new PopUpShopHandler(app); @@ -39,18 +40,19 @@ export class PopUpShopHandler { /** * @description 购买礼包 - * @param {{ activityId: number, id: number}} msg + * @param {{ activityId: number, id: number, beginTime: Date}} msg * @param {BackendSession} session * @memberof PopUpShopHandler */ - async buyGift(msg: { activityId: number, id: number }, session: BackendSession) { - const { activityId, id } = msg; + async buyGift(msg: { activityId: number, id: number, beginTime: Date }, session: BackendSession) { + const { activityId, id, beginTime } = msg; const roleId = session.get('roleId'); const serverId = session.get('serverId'); const sid = session.get('sid'); const roleName = session.get('roleName'); const funcs: number[] = session.get('funcs'); + let beginDate = moment(beginTime).toDate(); let activityData: ActivityModelType = await ActivityModel.findActivity(activityId); if (!activityData) { return resResult(STATUS.ACTIVITY_MISSING); @@ -72,7 +74,7 @@ export class PopUpShopHandler { return resResult(STATUS.ACTIVITY_NEED_PAY); } - let playerRecords: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findOpenDataByTaskId(serverId, activityId, roleId, id, playerData.taskType); + let playerRecords: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findDataByBeginTime(serverId, activityId, roleId, id, playerData.taskType, beginDate); if (!playerRecords) { return resResult(STATUS.ACTIVITY_POP_UP_SHOP_EXPIRE); } @@ -96,7 +98,7 @@ export class PopUpShopHandler { let rewardParamArr: Array = stringToRewardParam(playerData.reward); let result = await addReward(roleId, roleName, sid, serverId, funcs, rewardParamArr) - await ActivityPopUpShopModel.addRecord(serverId, activityId, roleId, id, playerData.taskType, 1); + await ActivityPopUpShopModel.addRecord(serverId, activityId, roleId, id, playerData.taskType, 1, beginDate); playerData.buyCount += 1; return resResult(STATUS.SUCCESS, Object.assign(result, { diff --git a/game-server/app/servers/order/handler/orderHandler.ts b/game-server/app/servers/order/handler/orderHandler.ts index 77f8fbc77..7ad8489ef 100644 --- a/game-server/app/servers/order/handler/orderHandler.ts +++ b/game-server/app/servers/order/handler/orderHandler.ts @@ -24,12 +24,12 @@ export class orderHandler { /** * @description 获取订单号 - * @param {{productID:string, payType:number ,activityId: number }} msg + * @param {{productID:string, payType:number ,activityId: number, paramStr: string }} msg * @param {BackendSession} session * @memberof orderHandler */ - async applyOrder(msg: { productID: string, payType: number, activityId: number }, session: BackendSession) { - const { productID, payType, activityId } = msg; + async applyOrder(msg: { productID: string, payType: number, activityId: number, paramStr: string }, session: BackendSession) { + const { productID, payType, activityId, paramStr } = msg; const roleId = session.get('roleId'); const serverId = session.get('serverId'); @@ -83,7 +83,7 @@ export class orderHandler { console.log('未知支付类型'); return resResult(STATUS.NO_PAY_TYPE); } - await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId); + await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId, paramStr, message); return resResult(STATUS.SUCCESS, { orderInfo: sdkOrderInfo, productInfo, localOrderID }); } @@ -201,12 +201,12 @@ export class orderHandler { /** * @description 支付测试 - * @param {{productID:string, magicWord:string }} msg + * @param {{productID:string, magicWord:string, paramStr: string }} msg * @param {BackendSession} session * @memberof orderHandler */ - async debugOrder(msg: { productID: string, magicWord: string }, session: BackendSession) { - const { magicWord, productID, } = msg; + async debugOrder(msg: { productID: string, magicWord: string, paramStr: string }, session: BackendSession) { + const { magicWord, productID, paramStr } = msg; if (magicWord !== DEBUG_MAGIC_WORD) { return resResult(STATUS.TOKEN_ERR); } @@ -243,7 +243,7 @@ export class orderHandler { } let activityData = activityArray[0]; let activityId = activityData.activityId; - await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId); + await UserOrderModel.applyOrder(serverId, roleId, productID, localOrderID, orderID, price, payType, activityId, paramStr, message); //订单成功 let orderInfo = await UserOrderModel.success(roleId, localOrderID); diff --git a/game-server/app/services/orderService.ts b/game-server/app/services/orderService.ts index 5fc49fec8..0658a605c 100644 --- a/game-server/app/services/orderService.ts +++ b/game-server/app/services/orderService.ts @@ -85,9 +85,9 @@ export async function makeOrder(localOrderID: string, sid: string, orderInfo: Us rewardResult = await makeDailyRMBGiftsReward(roleId, roleInfo.roleName, sid, orderInfo.serverId, roleInfo.funcs, orderInfo.activityId, orderInfo.productID) break; } - case ACTIVITY_TYPE.POP_UP_SHOP: + case ACTIVITY_TYPE.POP_UP_SHOP://弹出礼包 { - rewardResult = await makePopUpShopReward(roleId, roleInfo.roleName, sid, orderInfo.serverId, roleInfo.funcs, orderInfo.activityId, orderInfo.productID) + rewardResult = await makePopUpShopReward(roleId, roleInfo.roleName, sid, orderInfo.serverId, roleInfo.funcs, orderInfo.activityId, orderInfo.productID, orderInfo.paramStr) break; } case ACTIVITY_TYPE.GROWTH_FUND_MAIN_VIP: //主线成长基金(高阶) diff --git a/game-server/app/services/popUpShopService.ts b/game-server/app/services/popUpShopService.ts index e136b820b..e27fd1d11 100644 --- a/game-server/app/services/popUpShopService.ts +++ b/game-server/app/services/popUpShopService.ts @@ -67,7 +67,13 @@ export async function getPlayerPopUpShopData(activityId: number, serverId: numbe * */ export async function makePopUpShopReward(roleId: string, roleName: string, sid: string, serverId: number, funcs: number[], - activityId: number, productID: string) { + activityId: number, productID: string, paramStr: string) { + if (!paramStr) { + return STATUS.ORDER_PARAM_ERROR; + } + let paramObj = JSON.parse(paramStr); + let beginTime = moment(paramObj.beginTime).toDate(); + let activityData: ActivityModelType = await ActivityModel.findActivity(activityId); if (!activityData) { return STATUS.ACTIVITY_MISSING; @@ -81,7 +87,7 @@ export async function makePopUpShopReward(roleId: string, roleName: string, sid: return STATUS.ACTIVITY_NO_PRODUCT; } let playerData = new PopUpShopData(allTaskData[taskIndex], activityId); - let playerRecord: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findOpenDataByTaskId(serverId, activityId, roleId, playerData.id, playerData.taskType); + let playerRecord: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findDataByBeginTime(serverId, activityId, roleId, playerData.id, playerData.taskType, beginTime); if (!playerRecord) { return STATUS.APPLY_ORDER_ERROR; } @@ -95,7 +101,7 @@ export async function makePopUpShopReward(roleId: string, roleName: string, sid: if (playerRecord.buyCount >= playerData.count) { return STATUS.ACTIVITY_REWARDED; } - playerRecord = await ActivityPopUpShopModel.addRecord(serverId, activityId, roleId, playerData.id, playerData.taskType, 1); + playerRecord = await ActivityPopUpShopModel.addRecord(serverId, activityId, roleId, playerData.id, playerData.taskType, 1, beginTime); playerData.setPlayerRecords(playerRecord); let rewardParamArr: Array = stringToRewardParam(playerData.reward); diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index ede17deb2..317849ff9 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -636,7 +636,7 @@ export enum TASK_TYPE { ROLE_TERAPH_STAGE_UP = 82, // 神像进阶 EQUIP_QUALITY_COUNT = 83, // 获得*件品质的*装备 HERO_WAKE_UP_COUNT = 84, // *名武将觉醒 - GUILD_ACTIVITY_END = 85, // 参与*军团活动到结束 + GUILD_JOIN_ACTIVITY_END = 85, // 参与*军团活动到结束 } // 卡池类型 diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index c0de44205..b9a1147e6 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -392,5 +392,6 @@ export const STATUS = { ACTIVITY_TYPE_ERROR: { code: 70010, simStr: '活动类型错误' }, ACTIVITY_NO_PRODUCT: { code: 70011, simStr: '活动数据错误' }, ERROR_TYPE: { code: 70012, simStr: '未知活动类型' }, + ORDER_PARAM_ERROR: { code: 70013, simStr: '订单参数错误' }, } diff --git a/shared/db/ActivityPopUpShop.ts b/shared/db/ActivityPopUpShop.ts index cfe8376c2..f7b55ed39 100644 --- a/shared/db/ActivityPopUpShop.ts +++ b/shared/db/ActivityPopUpShop.ts @@ -1,5 +1,6 @@ import BaseModel from './BaseModel'; import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose'; +import moment = require('moment'); /** @@ -32,11 +33,10 @@ export default class Activity_Pop_Up_Shop extends BaseModel { isPush: boolean; // 是否推送过 //购买记录 - public static async addRecord(serverId: number, activityId: number, roleId: string, id: number, type: number, buyCount: number) { - let nowDate = new Date(); + public static async addRecord(serverId: number, activityId: number, roleId: string, id: number, type: number, buyCount: number, beginTime: Date) { let result: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findOneAndUpdate({ serverId, roleId, activityId, id, type, - beginTime: { $lt: nowDate }, endTime: { $gt: nowDate } + beginTime: beginTime }, { $inc: { buyCount: buyCount } }, { upsert: true, new: true }).lean(true); return result; @@ -61,16 +61,16 @@ export default class Activity_Pop_Up_Shop extends BaseModel { return result; } - //根据活动taskId查询现在正在开启的商店数据 - public static async findOpenDataByTaskId(serverId: number, activityId: number, roleId: string, id: number, type: number) { - let nowDate = new Date(); + //根据活动开始时间查询现在正在开启的商店数据 + public static async findDataByBeginTime(serverId: number, activityId: number, roleId: string, id: number, type: number, beginTime: Date) { + console.log('beginTime', serverId, roleId, activityId, id, type, beginTime) let result: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findOne({ - serverId, roleId, activityId, id, type, - beginTime: { $lt: nowDate }, endTime: { $gt: nowDate } + serverId, roleId, activityId, id, type, beginTime: beginTime }).lean(true); return result; } + //根据活动统计完成任务次数 public static async setTaskCount(serverId: number, activityId: number, roleId: string, id: number, type: number, count: number) { let result: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findOneAndUpdate({ serverId, roleId, activityId, id, type }, diff --git a/shared/db/UserOrder.ts b/shared/db/UserOrder.ts index e8a9cd9b9..677479eeb 100644 --- a/shared/db/UserOrder.ts +++ b/shared/db/UserOrder.ts @@ -29,6 +29,8 @@ export default class UserOrder extends BaseModel { message: string; // 信息 @prop({ required: true }) activityId: number; // 活动ID + @prop({ required: true }) + paramStr: string; // 订单参数 //保存平台订单号 @@ -101,9 +103,9 @@ export default class UserOrder extends BaseModel { //新增订单 - public static async applyOrder(serverId: number, roleId: string, productID: string, localOrderID: string, orderID: string, price: number, payType: number, activityId: number, message: string = '') { + public static async applyOrder(serverId: number, roleId: string, productID: string, localOrderID: string, orderID: string, price: number, payType: number, activityId: number, paramStr: string, message: string) { let result: UserOrderModelType = await UserOrderModel.findOneAndUpdate({ serverId, roleId, productID, localOrderID, orderID, payType, activityId }, - { $set: { price, state: ORDER_STATE.APPLY, message } }, + { $set: { price, state: ORDER_STATE.APPLY, message, paramStr: paramStr ? paramStr : '' } }, { upsert: true, new: true }).lean(true); return result; } diff --git a/shared/pubUtils/taskUtil.ts b/shared/pubUtils/taskUtil.ts index cbf3aa4a7..fe8c5d94c 100644 --- a/shared/pubUtils/taskUtil.ts +++ b/shared/pubUtils/taskUtil.ts @@ -1125,12 +1125,16 @@ export function isComplete(roleId: string, taskType: TASK_TYPE, taskParam: strin addCount = count; break; } - case TASK_TYPE.COM_BATTLE_ASSIST_TEAM: { addCount = count; break; } + case TASK_TYPE.GUILD_JOIN_ACTIVITY_END: + { + addCount = count; + break; + } default: addCount = 0; break; diff --git a/shared/resource/jsons/dic_zyz_taskType.json b/shared/resource/jsons/dic_zyz_taskType.json index 0242c6ca2..a7f0de395 100644 --- a/shared/resource/jsons/dic_zyz_taskType.json +++ b/shared/resource/jsons/dic_zyz_taskType.json @@ -754,5 +754,14 @@ "string": "武将数量", "content": 0, "condition": "herocount" + }, + { + "id": 85, + "name": "军团", + "info": "参与*军团活动到结束", + "param": "aid&", + "string": "武将数量", + "content": "aid-1.蛮夷 2.诸侯 3.粮草,aid=0就是任意军团活动类型", + "condition": "herocount" } ] \ No newline at end of file