活动:添加活动接口
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { ACTIVITY_TYPE, LAND_TYPE, SERVER_OPEN_TIME, STATUS, TASK_TYPE, CURRENCY_TYPE, CURRENCY_BY_TYPE, BANK_TYPE, ACTIVITY_RESOURCES_TYPE } from '../../../consts';
|
||||
import { LAND_TYPE, STATUS, CURRENCY_TYPE, CURRENCY_BY_TYPE, BANK_TYPE, ACTIVITY_RESOURCES_TYPE } from '../../../consts';
|
||||
import { ActivityMonopolyModel, ActivityMonopolyModelType } from '../../../db/ActivityMonopoly';
|
||||
import { ActivityMonopolyLandModel, ActivityMonopolyLandModelType } from '../../../db/ActivityMonopolyLand';
|
||||
import { ActivityModel } from '../../../db/Activity';
|
||||
import { getPlayerMonopolyData, nextPosition } from '../../../services/activity/monopolyService';
|
||||
import { random } from 'underscore';
|
||||
import { handleCost } from '../../../services/rewardService';
|
||||
import { addReward, stringToConsumeParam, stringToRewardParam } from '../../../services/activity/giftPackageService';
|
||||
import { getPlayerRefreshShopData, getPlayerRefreshShopDataByRoundIndex } from '../../../services/activity/refreshShopService';
|
||||
import { getPlayerRefreshShopDataByRoundIndex } from '../../../services/activity/refreshShopService';
|
||||
import { ActivityRefreshShopModel } from '../../../db/ActivityRefreshShop';
|
||||
|
||||
export default function (app: Application) {
|
||||
@@ -199,25 +198,25 @@ export class ActivityMonopolyHandler {
|
||||
|
||||
/**
|
||||
* @description 购买非RMB商品
|
||||
* @param {{ activityId: number, roundIndex: number, id: number, pageIndex: number}} msg
|
||||
* @param {{ monopolyActivityId:number, shopActivityId: number, roundIndex: number, id: number, pageIndex: number}} msg
|
||||
* @param {BackendSession} session
|
||||
* @memberof RefreshShopHandler
|
||||
*/
|
||||
async buyGood(msg: { activityId: number, roundIndex: number, id: number, pageIndex: number }, session: BackendSession) {
|
||||
const { activityId, roundIndex, id, pageIndex } = msg;
|
||||
async buyGood(msg: { monopolyActivityId, shopActivityId: number, roundIndex: number, id: number, pageIndex: number }, session: BackendSession) {
|
||||
const { monopolyActivityId, shopActivityId, roundIndex, id, pageIndex } = 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 playerMonopolyData: ActivityMonopolyModelType = await ActivityMonopolyModel.findData(serverId, activityId, roleId);
|
||||
let playerData = await getPlayerMonopolyData(activityId, serverId, roleId)
|
||||
let playerMonopolyData: ActivityMonopolyModelType = await ActivityMonopolyModel.findData(serverId, monopolyActivityId, roleId);
|
||||
let playerData = await getPlayerMonopolyData(monopolyActivityId, serverId, roleId)
|
||||
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||
let landItem = playerData.findMonopolyItem(playerMonopolyData.curPosition)
|
||||
if (landItem.stopCount > landItem.shoppingCountMax) {
|
||||
return resResult(STATUS.SHOP_CLOSED);
|
||||
}
|
||||
let playerShopData = await getPlayerRefreshShopDataByRoundIndex(activityId, serverId, roleId, landItem.stopCount);
|
||||
let playerShopData = await getPlayerRefreshShopDataByRoundIndex(shopActivityId, serverId, roleId, landItem.stopCount);
|
||||
if (!playerShopData) {
|
||||
return resResult(STATUS.ACTIVITY_MISSING);
|
||||
}
|
||||
@@ -245,11 +244,11 @@ export class ActivityMonopolyHandler {
|
||||
let rewardArray = stringToRewardParam(item.reward)
|
||||
let result = await addReward(roleId, roleName, sid, serverId, funcs, rewardArray);
|
||||
|
||||
await ActivityRefreshShopModel.addRecord(activityId, roleId, roundIndex, pageIndex, id);
|
||||
await ActivityRefreshShopModel.addRecord(shopActivityId, roleId, roundIndex, pageIndex, id);
|
||||
|
||||
item.buyCount += 1;
|
||||
return resResult(STATUS.SUCCESS, Object.assign(result, {
|
||||
param: { activityId, roundIndex, id },
|
||||
param: { shopActivityId, monopolyActivityId, roundIndex, id },
|
||||
item: item
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user