活动:寻宝骑兵活动接口
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, ACTIVITY_RESOURCES_TYPE, ACTIVITY_TYPE } from '../../../consts';
|
||||
import { getPlayerTreasureHuntData, getTreasureHuntData } from '../../../services/treasureHuntService';
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
return new TreasureHuntHandler(app);
|
||||
}
|
||||
|
||||
export class TreasureHuntHandler {
|
||||
constructor(private app: Application) {
|
||||
}
|
||||
|
||||
/************************寻宝骑兵活动****************************/
|
||||
|
||||
/**
|
||||
* @description 获取寻宝骑兵活动的数据
|
||||
* @param {BackendSession} session
|
||||
* @memberof TreasureHuntHandler
|
||||
*/
|
||||
async getTreasureHuntActivity(msg: { activityId: number }, session: BackendSession) {
|
||||
const { activityId } = msg;
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData } = await getTreasureHuntData(serverId);
|
||||
if (!activityData) {
|
||||
return resResult(STATUS.ACTIVITY_MISSING, {});
|
||||
}
|
||||
let playerData = await getPlayerTreasureHuntData(activityId, serverId, roleId, huntRoundIndex, huntBeginTime, huntEndTime);
|
||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||
|
||||
return resResult(STATUS.SUCCESS, playerData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 寻宝骑兵购买每日商店中的商品
|
||||
* @param {BackendSession} session
|
||||
* @memberof TreasureHuntHandler
|
||||
*/
|
||||
async buyGoods(msg: { activityId: number }, session: BackendSession) {
|
||||
const { activityId } = msg;
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
let { huntActivityId, huntBeginTime, huntEndTime, huntRoundIndex, activityData } = await getTreasureHuntData(serverId);
|
||||
if (!activityData) {
|
||||
return resResult(STATUS.ACTIVITY_MISSING, {});
|
||||
}
|
||||
if (activityId !== huntActivityId) {
|
||||
return resResult(STATUS.ACTIVITY_MISSING, {});
|
||||
}
|
||||
|
||||
let playerData = await getPlayerTreasureHuntData(activityId, serverId, roleId, huntRoundIndex, huntBeginTime, huntEndTime,);
|
||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||
|
||||
return resResult(STATUS.SUCCESS, playerData);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user