活动:寻宝骑兵添加首页奖励内容
This commit is contained in:
@@ -1,91 +0,0 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
import { ORDER_STATE } from '../consts';
|
||||
|
||||
/**
|
||||
* 玩家寻宝猎人活动数据
|
||||
*/
|
||||
@index({ roleId: 1 })
|
||||
|
||||
export default class ActivityTreasureHunt extends BaseModel {
|
||||
|
||||
@prop({ required: true })
|
||||
serverId: number; // 区号
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户id
|
||||
@prop({ required: true })
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roundIndex: number; // 周期Id
|
||||
|
||||
|
||||
|
||||
//保存平台订单号
|
||||
public static async saveOrderID(roleId: string, localOrderID: string, aliOrderID: string) {
|
||||
let result: ActivityTreasureHuntType = await ActivityTreasureHuntModel.findOneAndUpdate({ roleId, localOrderID },
|
||||
{ $set: { orderID: aliOrderID } },
|
||||
{ new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//校验订单
|
||||
public static async check(roleId: string, localOrderID: string, message: string = '') {
|
||||
let result: ActivityTreasureHuntType = await ActivityTreasureHuntModel.findOneAndUpdate({ roleId, localOrderID, state: { $ne: ORDER_STATE.RESULT_SUCCESS } },
|
||||
{ $set: { state: ORDER_STATE.CHECK_ORDER, message } },
|
||||
{ new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//订单支付失败
|
||||
public static async fail(roleId: string, localOrderID: string, message: string = '') {
|
||||
let result: ActivityTreasureHuntType = await ActivityTreasureHuntModel.findOneAndUpdate({ roleId, localOrderID, state: { $ne: ORDER_STATE.RESULT_SUCCESS } },
|
||||
{ $set: { state: ORDER_STATE.RESULT_FAIL, message } },
|
||||
{ new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//订单支付成功
|
||||
public static async success(roleId: string, localOrderID: string, message: string = '') {
|
||||
let result: ActivityTreasureHuntType = await ActivityTreasureHuntModel.findOneAndUpdate({ roleId, localOrderID, state: { $ne: ORDER_STATE.RESULT_SUCCESS } },
|
||||
{ $set: { state: ORDER_STATE.RESULT_SUCCESS, message } },
|
||||
{ new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询订单详情
|
||||
public static async findOrderByProductID(productID: string, roleId: string, activityId: number) {
|
||||
let result: ActivityTreasureHuntType[] = await ActivityTreasureHuntModel.find({ productID, roleId, activityId }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询订单详情
|
||||
public static async findPlayerOrder(productID: string, roleId: string, activityId: number, limit: number) {
|
||||
let result: ActivityTreasureHuntType[] = await ActivityTreasureHuntModel.find({ productID, roleId, activityId }, {}).limit(limit).sort({ createdAt: -1 }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询订单详情
|
||||
public static async findOrderByActivityID(activityId: number, roleId: string,) {
|
||||
let result: ActivityTreasureHuntType[] = await ActivityTreasureHuntModel.find({ activityId, roleId }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询订单详情
|
||||
public static async findOrder(localOrderID: string) {
|
||||
let result: ActivityTreasureHuntType = await ActivityTreasureHuntModel.findOne({ localOrderID }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//新增订单
|
||||
public static async applyOrder(serverId: number, roleId: string, productID: string, localOrderID: string, orderID: string, price: number, payType: number, activityId: number, message: string = '') {
|
||||
let result: ActivityTreasureHuntType = await ActivityTreasureHuntModel.findOneAndUpdate({ serverId, roleId, productID, localOrderID, orderID, payType, activityId },
|
||||
{ $set: { price, state: ORDER_STATE.APPLY, message } },
|
||||
{ upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const ActivityTreasureHuntModel = getModelForClass(ActivityTreasureHunt);
|
||||
|
||||
export interface ActivityTreasureHuntType extends Pick<DocumentType<ActivityTreasureHunt>, keyof ActivityTreasureHunt> { }
|
||||
export type ActivityTreasureHuntTypeParam = Partial<ActivityTreasureHuntType>; // 将所有字段变成可选项
|
||||
40
shared/db/ActivityTreasureHuntFirstPage.ts
Normal file
40
shared/db/ActivityTreasureHuntFirstPage.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 活动系统 - 寻宝骑兵-首页奖励
|
||||
*/
|
||||
@index({ roleId: 1 })
|
||||
|
||||
export default class Activity_Treasure_Hunt_First_Page {
|
||||
@prop({ required: true })
|
||||
serverId: number; // 区Id
|
||||
@prop({ required: true })
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
roundIndex: number; // 回合数
|
||||
@prop({ required: true })
|
||||
isReceive: boolean; // 是否领取
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findData(serverId: number, activityId: number, roleId: string, roundIndex: number) {
|
||||
let result: ActivityTreasureHuntFirstPageModelType = await ActivityTreasureHuntFirstPageModel.findOne({ serverId, roleId, activityId, roundIndex }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//领取奖励的记录
|
||||
public static async receiveReward(serverId: number, activityId: number, roleId: string, roundIndex: number,) {
|
||||
let result: ActivityTreasureHuntFirstPageModelType = await ActivityTreasureHuntFirstPageModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex },
|
||||
{ $set: { isReceive: true } }, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const ActivityTreasureHuntFirstPageModel = getModelForClass(Activity_Treasure_Hunt_First_Page);
|
||||
|
||||
export interface ActivityTreasureHuntFirstPageModelType extends Pick<DocumentType<Activity_Treasure_Hunt_First_Page>, keyof Activity_Treasure_Hunt_First_Page> { }
|
||||
export type ActivityTreasureHuntFirstPageModelTypeParam = Partial<ActivityTreasureHuntFirstPageModelType>; // 将所有字段变成可选项
|
||||
@@ -19,47 +19,12 @@ export default class Activity_Treasure_Hunt_Task extends ActivityGrowth {
|
||||
return result;
|
||||
}
|
||||
|
||||
// //根据活动统计完成任务次数
|
||||
// public static async setTaskCount(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
// let result: ActivityTreasureHuntTaskModelType = await ActivityTreasureHuntTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, cellIndex, type },
|
||||
// { $set: { totalCount: count } }, { upsert: true, new: true }).lean(lean);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// //根据活动统计完成任务次数
|
||||
// public static async addTaskCount(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number, type: number, addCount: number, lean = true) {
|
||||
// let result: ActivityTreasureHuntTaskModelType = await ActivityTreasureHuntTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, cellIndex, type },
|
||||
// { $inc: { totalCount: addCount } }, { upsert: true, new: true }).lean(lean);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// //根据活动记录统计数据
|
||||
// public static async addTaskRecord(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number, type: number, data: string,) {
|
||||
// let result: ActivityTreasureHuntTaskModelType = await ActivityTreasureHuntTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, cellIndex, type },
|
||||
// { $set: { data: data } }, { upsert: true, new: true }).lean(true);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
|
||||
// //根据活动id查询活动数据
|
||||
// public static async findTaskData(serverId: number, activityId: number, roleId: string, roundIndex: number) {
|
||||
// let result: ActivityTreasureHuntTaskModelType[] = await ActivityTreasureHuntTaskModel.find({ serverId, roleId, activityId }).lean(true);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
//查询第几天的活动数据
|
||||
public static async findDataByRoundIndex(serverId: number, activityId: number, roleId: string, roundIndex: number) {
|
||||
let result: ActivityTreasureHuntTaskModelType[] = await ActivityTreasureHuntTaskModel.find({ serverId, roleId, activityId, roundIndex }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几天某个的活动数据
|
||||
// public static async findDataByCellIndex(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number, type: number,) {
|
||||
// let result: ActivityTreasureHuntTaskModelType = await ActivityTreasureHuntTaskModel.findOne({ serverId, roleId, activityId, roundIndex, cellIndex, type }).lean(true);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number) {
|
||||
await ActivityTreasureHuntTaskModel.deleteMany({ serverId, roleId, activityId, roundIndex, cellIndex });
|
||||
|
||||
Reference in New Issue
Block a user