活动:添加区服id表示

This commit is contained in:
qiaoxin
2021-05-15 18:32:51 +08:00
parent 909481df40
commit 498a846f91
10 changed files with 44 additions and 37 deletions

View File

@@ -8,6 +8,8 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
@index({ roleId: 1 })
export default class ActivitySelfServiceShop extends BaseModel {
@prop({ required: true })
serverId: number; // 服
@prop({ required: true })
activityId: number; // 活动Id
@prop({ required: true })
@@ -24,33 +26,33 @@ export default class ActivitySelfServiceShop extends BaseModel {
goods: string; // 商品信息
//添加购买记录
public static async addBuyRecord(activityId: number, roleId: string, roundIndex: number, index: number, price: number, priceType: number, goods: string) {
public static async addBuyRecord(serverId: number, activityId: number, roleId: string, roundIndex: number, index: number, price: number, priceType: number, goods: string) {
await ActivitySelfServiceShopModel.insertMany([
{ roleId, activityId, roundIndex, index, price, priceType, goods }
{ serverId, roleId, activityId, roundIndex, index, price, priceType, goods }
])
}
//根据活动id查询活动数据
public static async findData(activityId: number, roleId: string, roundIndex: number, lean = true) {
let result: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.find({ roleId, activityId, roundIndex }).lean(lean);
public static async findData(serverId: number, activityId: number, roleId: string, roundIndex: number, lean = true) {
let result: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.find({ serverId, roleId, activityId, roundIndex }).lean(lean);
return result;
}
//查询第几个货架数据
public static async findDataByIndex(activityId: number, roleId: string, roundIndex: number, index: number, lean = true) {
let result: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.find({ roleId, activityId, roundIndex, index }).lean(lean);
public static async findDataByIndex(serverId: number, activityId: number, roleId: string, roundIndex: number, index: number, lean = true) {
let result: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.find({ serverId, roleId, activityId, roundIndex, index }).lean(lean);
return result;
}
//查询购买价格类型的数据
public static async findDataByPriceType(activityId: number, roleId: string, roundIndex: number, priceType: number, lean = true) {
let result: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.find({ roleId, activityId, priceType, roundIndex }).lean(lean);
public static async findDataByPriceType(serverId: number, activityId: number, roleId: string, roundIndex: number, priceType: number, lean = true) {
let result: ActivitySelfServiceShopModelType[] = await ActivitySelfServiceShopModel.find({ serverId, roleId, activityId, priceType, roundIndex }).lean(lean);
return result;
}
//删除活动领取记录
public static async deleteActivity(activityId: number, roleId: string, roundIndex: number, index: number,) {
await ActivitySelfServiceShopModel.deleteMany({ roleId, activityId, index, roundIndex });
public static async deleteActivity(serverId: number, activityId: number, roleId: string, roundIndex: number, index: number,) {
await ActivitySelfServiceShopModel.deleteMany({ serverId, roleId, activityId, index, roundIndex });
}
}