✨ feat(节日活动): 添加划龙舟活动
This commit is contained in:
@@ -67,6 +67,7 @@ export enum ACTIVITY_TYPE {
|
||||
MONTHLY_FUND = 52, // 月基金
|
||||
REBATE = 53, // 返利
|
||||
WEBVIEW = 54, // 平台活动页面
|
||||
DRAGON_BOAT = 55, // 龙舟
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1161,6 +1161,8 @@ export enum ITEM_CHANGE_REASON {
|
||||
ACT_MONTHLY_FUND_BUY = 183, // 月基金一次性购买
|
||||
ACT_MONTHLY_FUND_SIGN = 184, // 月基金签到
|
||||
RECEIVE_REBATE = 185, // 领取返利
|
||||
ACT_DRAGON_BOAT = 186, // 龙舟奖励
|
||||
ACT_DRAGON_BOAT_BUY_COST = 187, // 购买龙舟挑战奖励
|
||||
}
|
||||
|
||||
export enum TA_EVENT {
|
||||
|
||||
@@ -672,11 +672,17 @@ export const STATUS = {
|
||||
ACTIVITY_MONTHLY_FUND_NOT_BOUGHT: { code: 50060, simStr: '月基金未购买' },
|
||||
ACTIVITY_MONTHLY_FUND_NOT_FOUND: { code: 50061, simStr: '未找到该配置' },
|
||||
ACTIVITY_MONTHLY_FUND_LOCK: { code: 50062, simStr: '本次签到暂未解锁' },
|
||||
ACTIVITY_MONTHLY_FUND_HAS_SIGN: { code: 60063, simStr: '本次签到奖励已领取' },
|
||||
ACTIVITY_PUBLIC_ACCOUNT_WAIT: { code: 60064, simStr: '请在公众号输入口令' },
|
||||
ACTIVITY_PUBLIC_ACCOUNT_RECEIVED: { code: 60065, simStr: '已领取' },
|
||||
ACTIVITY_REBATE_DAY_NOT_REACH: { code: 60066, simStr: '暂不可领取' },
|
||||
ACTIVITY_REBATE_HAS_RECEIVED: { code: 60067, simStr: '奖励已领取' },
|
||||
ACTIVITY_MONTHLY_FUND_HAS_SIGN: { code: 50063, simStr: '本次签到奖励已领取' },
|
||||
ACTIVITY_PUBLIC_ACCOUNT_WAIT: { code: 50064, simStr: '请在公众号输入口令' },
|
||||
ACTIVITY_PUBLIC_ACCOUNT_RECEIVED: { code: 50065, simStr: '已领取' },
|
||||
ACTIVITY_REBATE_DAY_NOT_REACH: { code: 50066, simStr: '暂不可领取' },
|
||||
ACTIVITY_REBATE_HAS_RECEIVED: { code: 50067, simStr: '奖励已领取' },
|
||||
ACTIVITY_DRAGON_BOAT_ROUTE_NOTFOUND: { code: 50068, simStr: '未找到该节点' },
|
||||
ACTIVITY_DRAGON_BOAT_COUNT_OVER: { code: 50069, simStr: '挑战次数不足' },
|
||||
ACTIVITY_DRAGON_BOAT_PRE_NOT_PASS: { code: 50070, simStr: '前置节点未挑战' },
|
||||
ACTIVITY_DRAGON_BOAT_ROUTE_HAS_PASS: { code: 50071, simStr: '该节点已经挑战过了' },
|
||||
ACTIVITY_DRAGON_BOAT_BUY_COUNT_OVER: { code: 50072, simStr: '购买挑战次数不足' },
|
||||
ACTIVITY_DRAGON_BOAT_CANNOT_BUY: { code: 50073, simStr: '不可在免费次数未用完的时候购买次数' },
|
||||
|
||||
// GM后台相关状态 60000 - 69999
|
||||
GM_ERR_PASSWORD: { code: 60001, simStr: '账号或密码错误' },
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
|
||||
/**
|
||||
* 划龙舟
|
||||
*/
|
||||
class RecordReward {
|
||||
@prop({ required: true })
|
||||
id: number;
|
||||
@prop({ required: true })
|
||||
count: number;
|
||||
}
|
||||
|
||||
class BoatRecord {
|
||||
@prop({ required: true })
|
||||
todayIndex: number;
|
||||
|
||||
@prop({ required: true })
|
||||
id: number; // 划过的节点
|
||||
|
||||
@prop({ required: true })
|
||||
time: Date; // 时间
|
||||
|
||||
@prop({ required: true, type: RecordReward, _id: false })
|
||||
rewards: RecordReward[]; // 奖励
|
||||
}
|
||||
|
||||
@index({ roleId: 1, activityId: 1 })
|
||||
|
||||
export default class Activity_Dragon_Boat extends BaseModel {
|
||||
@prop({ required: true })
|
||||
serverId: number; // 服Id
|
||||
|
||||
@prop({ required: true })
|
||||
activityId: number; // 活动Id
|
||||
|
||||
@prop({ required: true })
|
||||
roundIndex: number; // 第几轮
|
||||
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
|
||||
@prop({ required: true })
|
||||
buyCnt: number; // 购买次数
|
||||
|
||||
@prop({ required: true, type: BoatRecord, _id: false })
|
||||
record: BoatRecord[]; // 划船记录
|
||||
|
||||
public static async findData(serverId: number, activityId: number, roundIndex: number, roleId: string) {
|
||||
let result: ActivityDragonBoatModelType = await ActivityDragonBoatModel.findOne({ serverId, roleId, activityId, roundIndex }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async record(serverId: number, activityId: number, roundIndex: number, roleId: string, record: BoatRecord) {
|
||||
let result: ActivityDragonBoatModelType = await ActivityDragonBoatModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex }, { $push: { record }, $setOnInsert: { buyCnt: 0 } }, { new: true, upsert: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async buyCnt(serverId: number, activityId: number, roundIndex: number, roleId: string, count: number) {
|
||||
let result: ActivityDragonBoatModelType = await ActivityDragonBoatModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex }, { $inc: { buyCnt: count }, $setOnInsert: { record: [] } }, { new: true, upsert: true }).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const ActivityDragonBoatModel = getModelForClass(Activity_Dragon_Boat);
|
||||
|
||||
export interface ActivityDragonBoatModelType extends Pick<DocumentType<Activity_Dragon_Boat>, keyof Activity_Dragon_Boat> { }
|
||||
export type ActivityDragonBoatModelTypeParam = Partial<ActivityDragonBoatModelType>; // 将所有字段变成可选项
|
||||
@@ -0,0 +1,109 @@
|
||||
// 节日活动 - 划龙舟
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityDragonBoatModelType } from '../../db/ActivityDragonBoat';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
// 后台格式
|
||||
interface RouteInDb {
|
||||
id: number; // 唯一id,对应 dic_zyz_duanwu_dragonBoat的id
|
||||
preId: number; // 前一个的节点,对应dic_zyz_duanwu_dragonBoat的id
|
||||
type: number; // 节点显示类型,1-普通奖励 2-高级奖励 3-漩涡
|
||||
reward: string; // 到了这个节点可以获得的奖励,type&id&count
|
||||
}
|
||||
|
||||
interface DragonBoatDataInDb {
|
||||
buyCost: string; // 购买一次划船次数的消耗,type&id&count
|
||||
dailyBuyCnt: number; // 每天可以购买的次数
|
||||
freeCnt: number; // 每天可以免费划船的次数
|
||||
routes: RouteInDb[]; // 划船路径
|
||||
}
|
||||
|
||||
class RouteData {
|
||||
id: number; // 唯一id,对应 dic_zyz_duanwu_dragonBoat的id
|
||||
preId: number; // 前一个的节点,对应dic_zyz_duanwu_dragonBoat的id
|
||||
type: number; // 节点显示类型,1-普通奖励 2-高级奖励 3-漩涡
|
||||
reward: string; // 到了这个节点可以获得的奖励,type&id&count
|
||||
resultReward: {id: number, count: number}[];
|
||||
|
||||
hasPass: boolean = false; // 是否经过过这个点
|
||||
|
||||
constructor(data: RouteInDb) {
|
||||
this.id = data.id;
|
||||
this.preId = data.preId;
|
||||
this.type = data.type;
|
||||
this.reward = data.reward;
|
||||
}
|
||||
|
||||
public setPass(reward: {id: number, count: number}[]) {
|
||||
this.hasPass = true;
|
||||
this.resultReward = reward;
|
||||
}
|
||||
|
||||
public getShowResult() {
|
||||
let { id, type, reward, hasPass } = this;
|
||||
return { id, type, reward, hasPass }
|
||||
}
|
||||
}
|
||||
|
||||
export class DragonBoatData extends ActivityBase {
|
||||
buyCost: string; // 购买一次划船次数的消耗,type&id&count
|
||||
dailyBuyCnt: number; // 每天可以购买的次数
|
||||
freeCnt: number; // 每天可以免费划船的次数
|
||||
routes: RouteData[] = []; // 划船路径
|
||||
|
||||
maxBuyCnt: number = 0; // 累积到现在可以购买的次数
|
||||
buyCnt: number = 0; // 累积到现在已经购买了的次数
|
||||
todayPlayCnt: number = 0; // 今天玩的次数
|
||||
playCnt: number = 0; // 总计玩的次数
|
||||
|
||||
|
||||
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
|
||||
super(activityData, createTime, serverTime)
|
||||
this.initData(activityData.data)
|
||||
}
|
||||
|
||||
public initData(data: string): void {
|
||||
let dataObj: DragonBoatDataInDb = JSON.parse(data);
|
||||
if(!dataObj) return;
|
||||
|
||||
this.buyCost = dataObj.buyCost||'&';
|
||||
this.dailyBuyCnt = dataObj.dailyBuyCnt||0;
|
||||
this.freeCnt = dataObj.freeCnt||0;
|
||||
this.maxBuyCnt = this.todayIndex * this.dailyBuyCnt;
|
||||
for(let data of (dataObj.routes||[])) {
|
||||
this.routes.push(new RouteData(data));
|
||||
}
|
||||
}
|
||||
|
||||
public setPlayerRecords(playerData: ActivityDragonBoatModelType) {
|
||||
if(!playerData) return;
|
||||
this.buyCnt = playerData.buyCnt||0;
|
||||
this.todayPlayCnt = 0;
|
||||
this.playCnt = 0;
|
||||
for(let { id, todayIndex, rewards } of (playerData.record||[])) {
|
||||
if(todayIndex == this.todayIndex) this.todayPlayCnt ++;
|
||||
this.playCnt ++;
|
||||
let route = this.routes.find(cur => cur.id == id);
|
||||
if(route) route.setPass(rewards);
|
||||
}
|
||||
}
|
||||
|
||||
public findRoute(id: number) {
|
||||
return this.routes.find(cur => cur.id == id);
|
||||
}
|
||||
|
||||
public getShowResult() {
|
||||
return {
|
||||
...this.getBaseKeys(),
|
||||
buyCost: this.buyCost,
|
||||
dailyBuyCnt: this.dailyBuyCnt,
|
||||
freeCnt: this.freeCnt,
|
||||
maxBuyCnt: this.maxBuyCnt,
|
||||
buyCnt: this.buyCnt,
|
||||
todayPlayCnt: this.todayPlayCnt,
|
||||
playCnt: this.playCnt,
|
||||
routes: this.routes.map(route => route.getShowResult()),
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,8 @@ interface RefreshShopPageInDb {
|
||||
viewcount: number;
|
||||
preNeedBuyCnt: number; // 添加:上一页需要购买的
|
||||
name: string;
|
||||
items: RefreshShopItemInDb[]
|
||||
items: RefreshShopItemInDb[];
|
||||
type: number;
|
||||
}
|
||||
|
||||
interface RefreshShopItemInDb {
|
||||
@@ -91,6 +92,7 @@ export class RefreshShopPage {
|
||||
viewCount: number; //随机可购买的商品个数
|
||||
preNeedBuyCnt: number; // 添加:上一页需要购买的
|
||||
items: Array<RefreshShopItem> = [];//商品列表
|
||||
type: number = 1; // 1-限时商店 2-限时返场商店
|
||||
constructor(data: RefreshShopPageInDb) {
|
||||
this.pageIndex = data.pageIndex;
|
||||
this.name = data.name;
|
||||
@@ -99,6 +101,7 @@ export class RefreshShopPage {
|
||||
}
|
||||
this.preNeedBuyCnt = data.preNeedBuyCnt;
|
||||
this.viewCount = data.viewcount ? data.viewcount : this.items.length;
|
||||
if(data.type) this.type = data.type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -298,5 +298,11 @@
|
||||
"activityType": 54,
|
||||
"name": "WEBVIEW",
|
||||
"string": "平台活动网页"
|
||||
},
|
||||
{
|
||||
"id": 55,
|
||||
"activityType": 55,
|
||||
"name": "DRAGON_BOAT",
|
||||
"string": "龙舟"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user