import { Application, BackendSession, HandlerService, } from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { STATUS } from '../../../consts';
import { getPlayerYuanbaoShopData } from '../../../services/activity/yuanbaoService';


export default function (app: Application) {
    new HandlerService(app, {});
    return new YuanbaoShopHandler(app);
}

export class YuanbaoShopHandler {
    constructor(private app: Application) {
    }

    /************************元宝商店****************************/

    /**
    * @description 获取商店活动数据
    * @param {BackendSession} session
    * @memberof YuanbaoShopHandler
    */
    async getShopActivity(msg: { activityId: number }, session: BackendSession) {
        const { activityId } = msg;
        const roleId = session.get('roleId');
        const serverId = session.get('serverId');

        let playerData = await getPlayerYuanbaoShopData(activityId, serverId, roleId);
        if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);

        return resResult(STATUS.SUCCESS, playerData);
    }
}
