邮件,异地登录bug
This commit is contained in:
+3
-9
@@ -1,7 +1,7 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
|
||||
const _ = require('underscore');
|
||||
// const Transaction = require('mongoose-transactions');
|
||||
// const Transaction = require("mongoose-transactions");
|
||||
@index({ roleId: 1, id: 1 })
|
||||
@index({ seqId: 1 })
|
||||
@modelOptions({ schemaOptions: { id: false } })
|
||||
@@ -86,14 +86,8 @@ export default class Item extends BaseModel {
|
||||
// let hasError: boolean = false, result = new Array();
|
||||
// try {
|
||||
// for (let { id, count, ratio } of items) {
|
||||
// if (ratio) ratio = -1;
|
||||
// await transaction.update({ roleId, id, count: { $gte: count } }, { $inc: { count: ratio * count } }, { new: true});
|
||||
// const rec: ItemType = await transaction.findOneAndUpdate({ roleId, id, count: { $gte: count } }, { $inc: { count: ratio * count } }, { new: true}).lean(lean);
|
||||
// if (!!rec) {
|
||||
// result.push({ id: rec.id, count: rec.count });
|
||||
// } else {
|
||||
// hasError = true; break;
|
||||
// }
|
||||
// if (!ratio) ratio = -1;
|
||||
// await transaction.update("Item", { roleId, id, count: { $gte: count } }, { $inc: { count: ratio * count } }, { new: true});
|
||||
// }
|
||||
// await transaction.run();
|
||||
// return {hasError, result};
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
import { RewardInter } from '../pubUtils/interface';
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
|
||||
@index({ roleId: 1 })
|
||||
|
||||
export default class Mail extends BaseModel {
|
||||
@prop({ required: true })
|
||||
roleId: number;
|
||||
|
||||
@prop({ required: true })
|
||||
seqId: number;
|
||||
|
||||
@prop({ required: true })
|
||||
mailId: number;
|
||||
|
||||
@prop({ required: true })
|
||||
goods: Array<RewardInter>;
|
||||
|
||||
@prop({ required: true, default: nowSeconds() })
|
||||
sendTime: number;
|
||||
|
||||
@prop({ required: true })
|
||||
sendName: string;
|
||||
|
||||
public static async addMails( mails: Array<MailType>) {
|
||||
await MailModel.insertMany(mails);
|
||||
}
|
||||
|
||||
public static async addMail(params:{ goods: Array<RewardInter>, sendName: string, mailId: number, sendTime?: number}) {
|
||||
const doc = new MailModel();
|
||||
const mail = Object.assign(doc.toJSON(), params);
|
||||
const mailInfo: MailType = await MailModel.create(mail);
|
||||
return mailInfo;
|
||||
}
|
||||
}
|
||||
|
||||
export const MailModel = getModelForClass(Mail);
|
||||
|
||||
export interface MailType extends Pick<DocumentType<Mail>, keyof Mail> { };
|
||||
@@ -233,14 +233,14 @@ export default class PvpDefense extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async getPvpDef(limitNum: number, lean = true) {
|
||||
let result: Array<PvpDefenseType> = await PvpDefenseModel.find().sort({ score: -1 }).limit(limitNum).lean(lean);
|
||||
public static async getPvpDef(limit: number, page: number, lean = true) {
|
||||
let result: Array<PvpDefenseType> = await PvpDefenseModel.find().sort({ score: -1 }).limit(limit).skip((page) * limit).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async getRank(page = 1, limit = 1000, lean = true) {
|
||||
let sortBy = { score: -1, updatedAt: 1 };
|
||||
const ranks: PvpDefenseType[] = await PvpDefenseModel.find().limit(limit).skip(page - 1).select('roleId role score updatedAt')
|
||||
const ranks: PvpDefenseType[] = await PvpDefenseModel.find().select('roleId role score updatedAt')
|
||||
.populate('role', 'roleId roleName headHid sHid title lv vLv')
|
||||
.sort(sortBy).limit(limit).skip((page - 1) * limit).lean(lean);
|
||||
return ranks;
|
||||
|
||||
Reference in New Issue
Block a user