背包:装备邮件处理
This commit is contained in:
+6
-2
@@ -1,6 +1,7 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
|
||||
import { findIndex } from 'underscore';
|
||||
import { BAG } from '../pubUtils/dicParam';
|
||||
// const Transaction = require("mongoose-transactions");
|
||||
@index({ roleId: 1, id: 1 })
|
||||
@index({ seqId: 1 })
|
||||
@@ -43,10 +44,13 @@ export default class Item extends BaseModel {
|
||||
return items;
|
||||
}
|
||||
|
||||
public static async increaseItem(roleId: string, id: number, count: number, itemInfo: { roleId: string, roleName: string, id: number, itemName: string, type: number, hid?: number }, lean = true) {
|
||||
public static async increaseItem(roleId: string, id: number, count: number, itemInfo: { roleId: string, roleName: string, id: number, itemName: string, type: number, hid?: number }) {
|
||||
const doc = new ItemModel();
|
||||
const setOnInsert = Object.assign(doc.toJSON(), itemInfo);
|
||||
const items: ItemType = await ItemModel.findOneAndUpdate({ roleId, id }, { $setOnInsert: setOnInsert, $inc: { count } }, { new: true, upsert: true }).lean(lean);
|
||||
let items: ItemType = await ItemModel.findOneAndUpdate({ roleId, id }, { $setOnInsert: setOnInsert, $inc: { count } }, { new: true, upsert: true }).lean();
|
||||
if(items.count > BAG.BAG_GOODS_UPLIMITED) {
|
||||
items = await ItemModel.findOneAndUpdate({ roleId, id, count: { $gte: BAG.BAG_GOODS_UPLIMITED } }, { $set: { count: BAG.BAG_GOODS_UPLIMITED } }, { new: true }).lean();
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,11 @@ export default class ServerMail extends MailTemp {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async getMailById(_id: string, lean = true) {
|
||||
const result: ServerMailType = await ServerMailModel.findOne({ _id }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 创建邮件
|
||||
* @param params
|
||||
|
||||
Reference in New Issue
Block a user