活动:弹出礼包订单添加参数
This commit is contained in:
@@ -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<RewardParam> = 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, {
|
||||
|
||||
Reference in New Issue
Block a user