背包:装备邮件处理

This commit is contained in:
luying
2021-08-03 14:00:42 +08:00
parent e4f3a932f9
commit 76aedd5425
7 changed files with 112 additions and 41 deletions
+12
View File
@@ -692,4 +692,16 @@ export enum SERVER_STATUS {
export enum WHITE_LIST_TYPE {
IP = 1, // ip地址
TEL = 2, // 玩家手机号
}
// 获取道具类型
export enum HANDLE_REWARD_TYPE {
RECEIVE = 1, // 获取
COST = 2 // 消耗
}
// 领取邮件类型
export enum RECEIVE_MAIL_TYPE {
SINGLE = 1, // 领取单个
ALL = 2, // 一件领取
}
+3 -1
View File
@@ -340,12 +340,14 @@ export const STATUS = {
GACHA_TURNTABLE_POINT_NOT_ENOUGH: { code: 31105, simStr: '转盘积分不足' },
GACHA_HAS_VISITED: { code: 31106, simStr: '该武将已拜访过' },
GACHA_VISITED_COUNT_OVER: { code: 31107, simStr: '今天武将拜访已超过次数' },
// 礼包码 31201-31300
GIFT_CODE_USED_NUM_MAX: { code: 31201, simStr: '礼包码使用次数超过' },
YOU_HAVE_USED_THIS_CODE: { code: 31202, simStr: '您已使用过该码' },
GIFT_CODE_NOT_START: { code: 31203, simStr: '礼包码未生效' },
GIFT_CODE_HAS_EXPIRED: { code: 31204, simStr: '礼包码已失效' },
// 邮件相关 31301-31400
MAIL_HAS_RECEIVE: { code: 31301, simStr: '邮件已领取'},
EQUIP_IS_OVER: { code: 31302, simStr: '装备已超过上限,无法领取' },
// 社交相关状态 40000 - 49999
SYS_CHANNEL_AUTH_NOT_ENOUGH: { code: 40000, simStr: '无法在系统频道发送消息' },
+6 -2
View File
@@ -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;
}
+5
View File
@@ -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