59 lines
2.1 KiB
TypeScript
59 lines
2.1 KiB
TypeScript
import { Application, BackendSession } from 'pinus';
|
|
import { resResult } from '../../../pubUtils/util';
|
|
import { STATUS, } from '../../../consts';
|
|
import { getPlayerPopUpShopData, makeDailyRMBGiftsReward } from '../../../services/popUpShopService';
|
|
|
|
export default function (app: Application) {
|
|
return new PopUpShopHandler(app);
|
|
}
|
|
|
|
export class PopUpShopHandler {
|
|
constructor(private app: Application) {
|
|
}
|
|
|
|
/************************弹出式商店****************************/
|
|
|
|
/**
|
|
* @description 获取弹出式商店数据
|
|
* @param {{ }} msg
|
|
* @param {{ activityId: number}} msg
|
|
* @param {BackendSession} session
|
|
* @memberof PopUpShopHandler
|
|
*/
|
|
async getPopUpShopActivity(msg: { activityId: number }, session: BackendSession) {
|
|
const { activityId } = msg;
|
|
const roleId = session.get('roleId');
|
|
const serverId = session.get('serverId');
|
|
|
|
let playerData = await getPlayerPopUpShopData(activityId, serverId, roleId)
|
|
if (!playerData) return resResult(STATUS.ACTIVITY_THIRTY_DAYS_END);
|
|
|
|
return resResult(STATUS.SUCCESS, { playerData });
|
|
}
|
|
|
|
/**
|
|
* @description 购买礼包
|
|
* @param {{ activityId: number}} msg
|
|
* @param {BackendSession} session
|
|
* @memberof PopUpShopHandler
|
|
*/
|
|
async buyGift(msg: { activityId: number }, session: BackendSession) {
|
|
const { activityId } = 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 playerData = await getPlayerPopUpShopData(activityId, serverId, roleId)
|
|
if (!playerData) return resResult(STATUS.ACTIVITY_THIRTY_DAYS_END);
|
|
// let item = playerData.findTodayItem();
|
|
// let productID = item.productID;
|
|
// let resulet = await makeDailyRMBGiftsReward(roleId, roleName, sid, serverId, funcs,
|
|
// activityId, productID)
|
|
|
|
return resResult(STATUS.SUCCESS, {});
|
|
}
|
|
|
|
}
|