活动:月卡领取
This commit is contained in:
@@ -7,10 +7,10 @@ import { addReward, stringToRewardParam, useGiftPackage } from '../../../service
|
|||||||
import { ActivityFirstGiftModel } from '../../../db/ActivityFirstGift';
|
import { ActivityFirstGiftModel } from '../../../db/ActivityFirstGift';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
return new firstGiftHandler(app);
|
return new FirstGiftHandler(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
export class firstGiftHandler {
|
export class FirstGiftHandler {
|
||||||
constructor(private app: Application) {
|
constructor(private app: Application) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ export class firstGiftHandler {
|
|||||||
* @description 获取首充礼包数据
|
* @description 获取首充礼包数据
|
||||||
* @param {{ }} msg
|
* @param {{ }} msg
|
||||||
* @param {BackendSession} session
|
* @param {BackendSession} session
|
||||||
* @memberof firstGiftHandler
|
* @memberof FirstGiftHandler
|
||||||
*/
|
*/
|
||||||
async getFirstGiftActivity(msg: {}, session: BackendSession) {
|
async getFirstGiftActivity(msg: {}, session: BackendSession) {
|
||||||
const { } = msg;
|
const { } = msg;
|
||||||
@@ -44,7 +44,7 @@ export class firstGiftHandler {
|
|||||||
* @description 领取礼包奖励
|
* @description 领取礼包奖励
|
||||||
* @param {{ activityId: number, index: number}} msg
|
* @param {{ activityId: number, index: number}} msg
|
||||||
* @param {BackendSession} session
|
* @param {BackendSession} session
|
||||||
* @memberof firstGiftHandler
|
* @memberof FirstGiftHandler
|
||||||
*/
|
*/
|
||||||
async getFirstGiftReward(msg: { activityId: number, index: number }, session: BackendSession) {
|
async getFirstGiftReward(msg: { activityId: number, index: number }, session: BackendSession) {
|
||||||
const { activityId, index } = msg;
|
const { activityId, index } = msg;
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import { ActivityGrowthFundModel } from '../../../db/ActivityGrowthFund';
|
|||||||
|
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
return new SevenDaysHandler(app);
|
return new GrowthFundHandler(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SevenDaysHandler {
|
export class GrowthFundHandler {
|
||||||
constructor(private app: Application) {
|
constructor(private app: Application) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ export class SevenDaysHandler {
|
|||||||
* @description 获取成长基金活动数据
|
* @description 获取成长基金活动数据
|
||||||
* @param {{ type: number}} msg
|
* @param {{ type: number}} msg
|
||||||
* @param {BackendSession} session
|
* @param {BackendSession} session
|
||||||
* @memberof SevenDaysHandler
|
* @memberof GrowthFundHandler
|
||||||
*/
|
*/
|
||||||
async getGrowthFundActivity(msg: { type: number }, session: BackendSession) {
|
async getGrowthFundActivity(msg: { type: number }, session: BackendSession) {
|
||||||
const { type } = msg;
|
const { type } = msg;
|
||||||
@@ -39,7 +39,7 @@ export class SevenDaysHandler {
|
|||||||
* @description 获取成长基金奖励
|
* @description 获取成长基金奖励
|
||||||
* @param {{ activityId: number, pageIndex: number, cellIndex: number}} msg
|
* @param {{ activityId: number, pageIndex: number, cellIndex: number}} msg
|
||||||
* @param {BackendSession} session
|
* @param {BackendSession} session
|
||||||
* @memberof SevenDaysHandler
|
* @memberof GrowthFundHandler
|
||||||
*/
|
*/
|
||||||
async getGrowthFundCellReward(msg: { activityId: number, pageIndex: number, cellIndex: number }, session: BackendSession) {
|
async getGrowthFundCellReward(msg: { activityId: number, pageIndex: number, cellIndex: number }, session: BackendSession) {
|
||||||
const { activityId, pageIndex, cellIndex } = msg;
|
const { activityId, pageIndex, cellIndex } = msg;
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import { ActivityShopModel } from '../../../db/ActivityShop';
|
|||||||
import moment = require('moment');
|
import moment = require('moment');
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
return new limitPackageHandler(app);
|
return new LimitPackageHandler(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
export class limitPackageHandler {
|
export class LimitPackageHandler {
|
||||||
constructor(private app: Application) {
|
constructor(private app: Application) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ export class limitPackageHandler {
|
|||||||
* @description 获取新手限定活动数据
|
* @description 获取新手限定活动数据
|
||||||
* @param {{ activityId:number}} msg
|
* @param {{ activityId:number}} msg
|
||||||
* @param {BackendSession} session
|
* @param {BackendSession} session
|
||||||
* @memberof limitPackageHandler
|
* @memberof LimitPackageHandler
|
||||||
*/
|
*/
|
||||||
async getNewPlayerLimitPackageActivity(msg: { activityId: number }, session: BackendSession) {
|
async getNewPlayerLimitPackageActivity(msg: { activityId: number }, session: BackendSession) {
|
||||||
const { activityId } = msg;
|
const { activityId } = msg;
|
||||||
@@ -40,7 +40,7 @@ export class limitPackageHandler {
|
|||||||
* @description 获取每日/每周限购礼包数据
|
* @description 获取每日/每周限购礼包数据
|
||||||
* @param {{ activityId:number, type:number }} msg
|
* @param {{ activityId:number, type:number }} msg
|
||||||
* @param {BackendSession} session
|
* @param {BackendSession} session
|
||||||
* @memberof limitPackageHandler
|
* @memberof LimitPackageHandler
|
||||||
*/
|
*/
|
||||||
async getLimitPackageActivity(msg: { activityId: number, type: number }, session: BackendSession) {
|
async getLimitPackageActivity(msg: { activityId: number, type: number }, session: BackendSession) {
|
||||||
const { activityId, type } = msg;
|
const { activityId, type } = msg;
|
||||||
@@ -59,7 +59,7 @@ export class limitPackageHandler {
|
|||||||
* @description 购买礼包
|
* @description 购买礼包
|
||||||
* @param {{ activityId: number, roundIndex: number, id: number}} msg
|
* @param {{ activityId: number, roundIndex: number, id: number}} msg
|
||||||
* @param {BackendSession} session
|
* @param {BackendSession} session
|
||||||
* @memberof limitPackageHandler
|
* @memberof LimitPackageHandler
|
||||||
*/
|
*/
|
||||||
async buyGood(msg: { activityId: number, roundIndex: number, id: number }, session: BackendSession) {
|
async buyGood(msg: { activityId: number, roundIndex: number, id: number }, session: BackendSession) {
|
||||||
const { activityId, roundIndex, id, } = msg;
|
const { activityId, roundIndex, id, } = msg;
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { Application, BackendSession } from 'pinus';
|
||||||
|
import { resResult } from '../../../pubUtils/util';
|
||||||
|
import { STATUS, ACTIVITY_RESOURCES_TYPE, ACTIVITY_TYPE } from '../../../consts';
|
||||||
|
import { getPlayerMonthlyTicketData, makeMonthlyTicketReward, getPlayerMonthlyTicketDayReward } from '../../../services/monthlyTicketService';
|
||||||
|
import moment = require('moment');
|
||||||
|
|
||||||
|
|
||||||
|
export default function (app: Application) {
|
||||||
|
return new MonthlyTicketHandler(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
export class MonthlyTicketHandler {
|
||||||
|
constructor(private app: Application) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************月卡活动****************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取月卡活动数据
|
||||||
|
* @param {BackendSession} session
|
||||||
|
* @memberof MonthlyTicketHandler
|
||||||
|
*/
|
||||||
|
async getMonthlyTicketActivity(msg: { activityId: number }, session: BackendSession) {
|
||||||
|
const { activityId } = msg;
|
||||||
|
const roleId = session.get('roleId');
|
||||||
|
const serverId = session.get('serverId');
|
||||||
|
|
||||||
|
let playerData = await getPlayerMonthlyTicketData(activityId, serverId, roleId);
|
||||||
|
if (!playerData) return resResult(STATUS.ACTIVITY_MISSING);
|
||||||
|
return resResult(STATUS.SUCCESS, playerData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 领取月卡奖品
|
||||||
|
* @param {BackendSession} session
|
||||||
|
* @memberof MonthlyTicketHandler
|
||||||
|
*/
|
||||||
|
async getMonthlyTicketReward(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 result = await getPlayerMonthlyTicketDayReward(roleId, roleName, sid, serverId, funcs, activityId)
|
||||||
|
if (result) {
|
||||||
|
return resResult(STATUS.SUCCESS, result);
|
||||||
|
}
|
||||||
|
return resResult(STATUS.NO_MOTHLY_TICKET_REWARD);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,10 +10,10 @@ import Activity, { ActivityModel, ActivityModelType } from '../../../db/Activity
|
|||||||
import { addSelfServiceShopGiftReward, getActivityData, getPlayerActivityData } from '../../../services/selfServiceShopActivityService';
|
import { addSelfServiceShopGiftReward, getActivityData, getPlayerActivityData } from '../../../services/selfServiceShopActivityService';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
return new thirtyDaysHandler(app);
|
return new SelfServiceShopHandler(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
export class thirtyDaysHandler {
|
export class SelfServiceShopHandler {
|
||||||
constructor(private app: Application) {
|
constructor(private app: Application) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ export class thirtyDaysHandler {
|
|||||||
* @description 获取自助商店数据
|
* @description 获取自助商店数据
|
||||||
* @param {{ }} msg
|
* @param {{ }} msg
|
||||||
* @param {BackendSession} session
|
* @param {BackendSession} session
|
||||||
* @memberof thirtyDaysHandler
|
* @memberof SelfServiceShopHandler
|
||||||
*/
|
*/
|
||||||
async getSelfServiceShopActivity(msg: {}, session: BackendSession) {
|
async getSelfServiceShopActivity(msg: {}, session: BackendSession) {
|
||||||
const { } = msg;
|
const { } = msg;
|
||||||
@@ -40,7 +40,7 @@ export class thirtyDaysHandler {
|
|||||||
* @description 购买礼包
|
* @description 购买礼包
|
||||||
* @param {{ activityId: number, roundIndex: number, index: number, cellIndex: number}} msg
|
* @param {{ activityId: number, roundIndex: number, index: number, cellIndex: number}} msg
|
||||||
* @param {BackendSession} session
|
* @param {BackendSession} session
|
||||||
* @memberof thirtyDaysHandler
|
* @memberof SelfServiceShopHandler
|
||||||
*/
|
*/
|
||||||
async buyGift(msg: { activityId: number, roundIndex: number, index: number }, session: BackendSession) {
|
async buyGift(msg: { activityId: number, roundIndex: number, index: number }, session: BackendSession) {
|
||||||
const { activityId, roundIndex, index } = msg;
|
const { activityId, roundIndex, index } = msg;
|
||||||
@@ -80,7 +80,7 @@ export class thirtyDaysHandler {
|
|||||||
* @description 操作礼包
|
* @description 操作礼包
|
||||||
* @param {{ activityId: number, roundIndex: number, index: number, cellIndex: number, gift: number, rewardIndex: number}} msg
|
* @param {{ activityId: number, roundIndex: number, index: number, cellIndex: number, gift: number, rewardIndex: number}} msg
|
||||||
* @param {BackendSession} session
|
* @param {BackendSession} session
|
||||||
* @memberof thirtyDaysHandler
|
* @memberof SelfServiceShopHandler
|
||||||
*/
|
*/
|
||||||
async saveGood(msg: { activityId: number, roundIndex: number, index: number, cellIndex: number, gift: number, rewardIndex: number }, session: BackendSession) {
|
async saveGood(msg: { activityId: number, roundIndex: number, index: number, cellIndex: number, gift: number, rewardIndex: number }, session: BackendSession) {
|
||||||
const { activityId, roundIndex, index, cellIndex, gift, rewardIndex } = msg;
|
const { activityId, roundIndex, index, cellIndex, gift, rewardIndex } = msg;
|
||||||
|
|||||||
@@ -6,15 +6,14 @@ import { ThirtyDaysData, ThirtyDaysItem, ThirtyDaysPointItem } from '../../../do
|
|||||||
import { addItems, createHeroes } from '../../../services/rewardService';
|
import { addItems, createHeroes } from '../../../services/rewardService';
|
||||||
import { ActivityThirtyDaysModel } from '../../../db/ActivityThirtyDays';
|
import { ActivityThirtyDaysModel } from '../../../db/ActivityThirtyDays';
|
||||||
import { ActivityThirtyDaysPointRewardModel } from '../../../db/ActivityThirtyDaysPointReward';
|
import { ActivityThirtyDaysPointRewardModel } from '../../../db/ActivityThirtyDaysPointReward';
|
||||||
import { RoleModel } from '../../../db/Role';
|
|
||||||
import moment = require('moment');
|
import moment = require('moment');
|
||||||
import { ActivityModel, ActivityModelType } from '../../../db/Activity';
|
import { ActivityModel, ActivityModelType } from '../../../db/Activity';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
return new thirtyDaysHandler(app);
|
return new ThirtyDaysHandler(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
export class thirtyDaysHandler {
|
export class ThirtyDaysHandler {
|
||||||
constructor(private app: Application) {
|
constructor(private app: Application) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ export class thirtyDaysHandler {
|
|||||||
* @description 获取30目标活动数据
|
* @description 获取30目标活动数据
|
||||||
* @param {{ }} msg
|
* @param {{ }} msg
|
||||||
* @param {BackendSession} session
|
* @param {BackendSession} session
|
||||||
* @memberof thirtyDaysHandler
|
* @memberof ThirtyDaysHandler
|
||||||
*/
|
*/
|
||||||
async getThirtyDaysActivity(msg: {}, session: BackendSession) {
|
async getThirtyDaysActivity(msg: {}, session: BackendSession) {
|
||||||
const { } = msg;
|
const { } = msg;
|
||||||
@@ -43,7 +42,7 @@ export class thirtyDaysHandler {
|
|||||||
* @description 获取30天完成任务的奖励
|
* @description 获取30天完成任务的奖励
|
||||||
* @param {{ activityId: number, pageIndex: number, cellIndex: number}} msg
|
* @param {{ activityId: number, pageIndex: number, cellIndex: number}} msg
|
||||||
* @param {BackendSession} session
|
* @param {BackendSession} session
|
||||||
* @memberof thirtyDaysHandler
|
* @memberof ThirtyDaysHandler
|
||||||
*/
|
*/
|
||||||
async getThirtyDaysCellReward(msg: { activityId: number, pageIndex: number, cellIndex: number }, session: BackendSession) {
|
async getThirtyDaysCellReward(msg: { activityId: number, pageIndex: number, cellIndex: number }, session: BackendSession) {
|
||||||
const { activityId, pageIndex, cellIndex } = msg;
|
const { activityId, pageIndex, cellIndex } = msg;
|
||||||
@@ -113,7 +112,7 @@ export class thirtyDaysHandler {
|
|||||||
* @description 点数兑换奖励
|
* @description 点数兑换奖励
|
||||||
* @param {{ activityId: number, cellIndex: number}} msg
|
* @param {{ activityId: number, cellIndex: number}} msg
|
||||||
* @param {BackendSession} session
|
* @param {BackendSession} session
|
||||||
* @memberof thirtyDaysHandler
|
* @memberof ThirtyDaysHandler
|
||||||
*/
|
*/
|
||||||
async getThirtyDaysPointReward(msg: { activityId: number, cellIndex: number }, session: BackendSession) {
|
async getThirtyDaysPointReward(msg: { activityId: number, cellIndex: number }, session: BackendSession) {
|
||||||
const { activityId, cellIndex } = msg;
|
const { activityId, cellIndex } = msg;
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
import { ACTIVITY_TYPE, TASK_TYPE } from '../consts';
|
||||||
|
import { ActivityModel, ActivityModelType } from '../db/Activity';
|
||||||
|
import { ActivityMonthlyTicketModel, ActivityMonthlyTicketModelType } from '../db/ActivityMonthlyTicket';
|
||||||
|
import { RewardParam } from '../domain/activityField/rewardField';
|
||||||
|
import { MonthlyTicketData } from '../domain/activityField/monthlyTicketField';
|
||||||
|
import { addReward, stringToRewardParam } from './giftPackageService';
|
||||||
|
import moment = require('moment');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取活动数据
|
||||||
|
*
|
||||||
|
* @param {number} serverId 区Id
|
||||||
|
* @param {number} type 活动类型 ACTIVITY_TYPE
|
||||||
|
* @param {string} roleId 角色Id
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
export async function monthlyTicketActivity(serverId: number, roleId: string, type: number) {
|
||||||
|
let activityArray: ActivityModelType[] = await ActivityModel.findOpenActivityByType(type, new Date())
|
||||||
|
activityArray = activityArray.sort((a, b) => {
|
||||||
|
return b.activityId - a.activityId
|
||||||
|
});
|
||||||
|
if (activityArray.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
let activityData = activityArray[0];
|
||||||
|
let playerData = await getPlayerMonthlyTicketData(activityData.activityId, serverId, roleId);
|
||||||
|
return playerData
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 玩家活动数据
|
||||||
|
*
|
||||||
|
* @param {number} serverId 区Id
|
||||||
|
* @param {number} activityId 活动Id
|
||||||
|
* @param {string} roleId 角色Id
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export async function getPlayerMonthlyTicketData(activityId: number, serverId: number, roleId: string) {
|
||||||
|
let activityData: ActivityModelType = await ActivityModel.findActivity(activityId, true);
|
||||||
|
let playerRecord: ActivityMonthlyTicketModelType = await ActivityMonthlyTicketModel.findMonthlyTicket(serverId, roleId, activityId);
|
||||||
|
let playerData = new MonthlyTicketData(activityData);
|
||||||
|
playerData.setPlayerRecords(playerRecord);
|
||||||
|
return playerData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 玩家月卡当天的奖励
|
||||||
|
*
|
||||||
|
* @param {number} serverId 区Id
|
||||||
|
* @param {number} activityId 活动Id
|
||||||
|
* @param {string} roleId 角色Id
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export async function getPlayerMonthlyTicketDayReward(roleId: string, roleName: string, sid: string, serverId: number, funcs: number[],
|
||||||
|
activityId: number,) {
|
||||||
|
let activityData: ActivityModelType = await ActivityModel.findActivity(activityId, true);
|
||||||
|
let playerRecord: ActivityMonthlyTicketModelType = await ActivityMonthlyTicketModel.findMonthlyTicket(serverId, roleId, activityId);
|
||||||
|
if (!playerRecord) {//没有购买过
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
let playerData = new MonthlyTicketData(activityData);
|
||||||
|
playerData.setPlayerRecords(playerRecord);
|
||||||
|
if (playerData.isOpen) {
|
||||||
|
if (playerData.todayIndex > playerData.dayIndex) {//今天还没领取
|
||||||
|
await ActivityMonthlyTicketModel.setDayIndex(serverId, roleId, activityId, playerData.todayIndex);
|
||||||
|
let rewardParamArr: Array<RewardParam> = stringToRewardParam(playerData.baseReward);
|
||||||
|
let result = await addReward(roleId, roleName, sid, serverId, funcs, rewardParamArr)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结算首次购买月卡的奖励
|
||||||
|
*
|
||||||
|
* @param {number} serverId 区Id
|
||||||
|
* @param {number} activityId 活动Id
|
||||||
|
* @param {string} roleId 角色Id
|
||||||
|
* @param {string} productID 商品ID
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export async function makeMonthlyTicketReward(roleId: string, roleName: string, sid: string, serverId: number, funcs: number[],
|
||||||
|
activityId: number, productID: string) {
|
||||||
|
let activityData: ActivityModelType = await ActivityModel.findActivity(activityId, true);
|
||||||
|
let playerData = new MonthlyTicketData(activityData);
|
||||||
|
|
||||||
|
let endTime = moment(new Date()).startOf('d').add(playerData.days, 'day').toDate();
|
||||||
|
console.log('endTime', moment(new Date()).startOf('d'), endTime, playerData.days)
|
||||||
|
await ActivityMonthlyTicketModel.buyMonthlyTicket(serverId, roleId, activityId, activityData.type, endTime)
|
||||||
|
|
||||||
|
let firstReward = playerData.firstReward;
|
||||||
|
let rewardParamArr: Array<RewardParam> = stringToRewardParam(firstReward);
|
||||||
|
let result = await addReward(roleId, roleName, sid, serverId, funcs, rewardParamArr)
|
||||||
|
return result
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import { ACTIVITY_TYPE, ORDER_STATE } from '../consts';
|
|||||||
import { dicRMB } from '../pubUtils/dictionary/DicRMB';
|
import { dicRMB } from '../pubUtils/dictionary/DicRMB';
|
||||||
import { makeYuanbaoShopReward } from './yuanbaoService';
|
import { makeYuanbaoShopReward } from './yuanbaoService';
|
||||||
import { RoleModel } from '../db/Role';
|
import { RoleModel } from '../db/Role';
|
||||||
|
import { makeMonthlyTicketReward } from './monthlyTicketService';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -51,6 +52,13 @@ export async function makeOrder(localOrderID: string, sid: string) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ACTIVITY_TYPE.MONTHLY_TICKET_1:
|
||||||
|
case ACTIVITY_TYPE.MONTHLY_TICKET_2:
|
||||||
|
{
|
||||||
|
let resule = await makeMonthlyTicketReward(roleId, roleInfo.roleName, sid, orderInfo.serverId, roleInfo.funcs, orderInfo.activityId, orderInfo.productID)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return '未知商品类型';
|
return '未知商品类型';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ export enum ACTIVITY_TYPE {
|
|||||||
LIMIT_PACKAGE_SHOP_DAILY = 16, // 每日限购礼包,RMB购买礼包
|
LIMIT_PACKAGE_SHOP_DAILY = 16, // 每日限购礼包,RMB购买礼包
|
||||||
LIMIT_PACKAGE_SHOP_WEEKLY = 17, // 每周限购礼包,RMB购买礼包
|
LIMIT_PACKAGE_SHOP_WEEKLY = 17, // 每周限购礼包,RMB购买礼包
|
||||||
YUAN_BAO_SHOP = 18, // 元宝充值商店
|
YUAN_BAO_SHOP = 18, // 元宝充值商店
|
||||||
|
MONTHLY_TICKET_1 = 19, // 月卡1(普通)
|
||||||
|
MONTHLY_TICKET_2 = 20, // 月卡2(至尊)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -375,6 +375,7 @@ export const STATUS = {
|
|||||||
APPLY_ORDER_ERROR: { code: 70005, simStr: '下单失败' },
|
APPLY_ORDER_ERROR: { code: 70005, simStr: '下单失败' },
|
||||||
ORDER_ERROR: { code: 70006, simStr: '订单错误' },
|
ORDER_ERROR: { code: 70006, simStr: '订单错误' },
|
||||||
PRICE_ERROR: { code: 70007, simStr: '价格错误' },
|
PRICE_ERROR: { code: 70007, simStr: '价格错误' },
|
||||||
NO_PAY: { code: 70008, simStr: '未支付' }
|
NO_PAY: { code: 70008, simStr: '未支付' },
|
||||||
|
NO_MOTHLY_TICKET_REWARD: { code: 70009, simStr: '没有可领取的月卡奖励' }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import BaseModel from './BaseModel';
|
||||||
|
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||||
|
import { ORDER_STATE } from '../consts';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 月卡
|
||||||
|
*/
|
||||||
|
@index({ roleId: 1 })
|
||||||
|
|
||||||
|
export default class ActivityMonthlyTicket extends BaseModel {
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
activityType: number; // 活动类型
|
||||||
|
@prop({ required: true })
|
||||||
|
activityId: number; // 活动ID
|
||||||
|
@prop({ required: true })
|
||||||
|
serverId: number; // 区号
|
||||||
|
@prop({ required: true })
|
||||||
|
roleId: string; // 用户id
|
||||||
|
@prop({ required: true })
|
||||||
|
endTime: Date; // 结束时间
|
||||||
|
@prop({ required: true })
|
||||||
|
dayIndex: number; // 结算到第几天,从0开始,1表示第一天已经领取过(包括邮件发放)
|
||||||
|
|
||||||
|
|
||||||
|
//记录领取的天数
|
||||||
|
public static async setDayIndex(serverId: number, roleId: string, activityId: number, dayIndex: number) {
|
||||||
|
let result: ActivityMonthlyTicketModelType = await ActivityMonthlyTicketModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex: { $lt: dayIndex } },
|
||||||
|
{ $set: { dayIndex } },
|
||||||
|
{ new: true }).lean(true);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询月卡详情
|
||||||
|
public static async findMonthlyTicket(serverId: number, roleId: string, activityId: number) {
|
||||||
|
let result: ActivityMonthlyTicketModelType = await ActivityMonthlyTicketModel.findOne({ serverId, roleId, activityId }).lean(true);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//购买月卡
|
||||||
|
public static async buyMonthlyTicket(serverId: number, roleId: string, activityId: number, activityType: number, endTime: Date) {
|
||||||
|
await ActivityMonthlyTicketModel.findOneAndUpdate({ serverId, roleId, activityId, activityType }, { $set: { endTime, dayIndex: 0 } }, { upsert: true, new: true }).lean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ActivityMonthlyTicketModel = getModelForClass(ActivityMonthlyTicket);
|
||||||
|
|
||||||
|
export interface ActivityMonthlyTicketModelType extends Pick<DocumentType<ActivityMonthlyTicket>, keyof ActivityMonthlyTicket> { }
|
||||||
|
export type ActivityMonthlyTicketModelTypeParam = Partial<ActivityMonthlyTicketModelType>; // 将所有字段变成可选项
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import moment = require('moment');
|
||||||
|
import { ActivityModelType } from '../../db/Activity';
|
||||||
|
import { ActivityMonthlyTicketModelType } from '../../db/ActivityMonthlyTicket';
|
||||||
|
import { deltaDays } from '../../pubUtils/util';
|
||||||
|
import { ActivityBase } from './activityField';
|
||||||
|
|
||||||
|
|
||||||
|
// 月卡数据
|
||||||
|
export class MonthlyTicketData extends ActivityBase {
|
||||||
|
|
||||||
|
name: string = '';//名称
|
||||||
|
id: number = 0;//序列
|
||||||
|
productID: string = '';//商品id
|
||||||
|
price: number = 0;//价格
|
||||||
|
days: number = 0;//持续天数
|
||||||
|
baseReward: string = '';//每天领取的奖励
|
||||||
|
firstReward: string = '';//首次购买获得的奖励
|
||||||
|
|
||||||
|
endTime: number = 0;//结束时间
|
||||||
|
dayIndex: number = 0;//已经领取了几天
|
||||||
|
isOpen: boolean = false;//是否开启中
|
||||||
|
todayIndex: number = 0;//现在可以领取第几天的奖励
|
||||||
|
//解析玩家领取记录
|
||||||
|
public setPlayerRecords(data: ActivityMonthlyTicketModelType) {
|
||||||
|
if (!data) {//没有购买月卡
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.dayIndex = data.dayIndex;
|
||||||
|
this.endTime = moment(data.endTime).valueOf();
|
||||||
|
if (moment(new Date).valueOf() < this.endTime) {
|
||||||
|
this.isOpen = true;
|
||||||
|
this.todayIndex = deltaDays(data.createdAt, new Date) + 1;
|
||||||
|
} else {
|
||||||
|
this.todayIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public initData(data: string) {
|
||||||
|
let dataObj = JSON.parse(data);
|
||||||
|
|
||||||
|
this.id = dataObj.id;
|
||||||
|
this.name = dataObj.name;
|
||||||
|
this.productID = dataObj.productID;
|
||||||
|
this.price = dataObj.price;
|
||||||
|
this.days = dataObj.days;
|
||||||
|
this.baseReward = dataObj.baseReward;
|
||||||
|
this.firstReward = dataObj.firstReward;
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(activityData: ActivityModelType) {
|
||||||
|
super(activityData)
|
||||||
|
this.initData(activityData.data)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user