日志:修复玩家日志记录

This commit is contained in:
luying
2021-12-24 19:45:27 +08:00
parent e0b3436710
commit c782969986
2 changed files with 7 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ import { RoleModel } from '../../../db/Role';
import { gameData } from '../../../pubUtils/data';
import { ITEM_CHANGE_REASON, ITID, RECEIVE_MAIL_TYPE } from '../../../consts';
import { BAG } from '../../../pubUtils/dicParam';
import { saveMailLog } from '../../../pubUtils/logUtil';
export default function(app: Application) {
return new MailHandler(app);
@@ -147,7 +148,7 @@ export class MailHandler {
}
let resGoods = await addItems(roleId, roleName, sid, mailGoods, ITEM_CHANGE_REASON.MAIL);
saveMailLog(session, mails);
return resResult(STATUS.SUCCESS, { mails, goods: resGoods });
}
}

View File

@@ -34,8 +34,10 @@ export async function saveLoginAndOutLog(type: LOG_TYPE, session: any) {
export async function saveCeChangeLog(role: RoleType, inc: number, count: number, type: number, ids: number[]) {
try {
let params = getParamByRole(role);
await UserLogModel.createRecord({ type: LOG_TYPE.CE_CHANGE, ...params, inc, count, ceChangeReason: type, ceChangeIds: ids });
if(inc != 0) {
let params = getParamByRole(role);
await UserLogModel.createRecord({ type: LOG_TYPE.CE_CHANGE, ...params, inc, count, ceChangeReason: type, ceChangeIds: ids });
}
} catch (e) {
console.error(e);
}
@@ -67,6 +69,7 @@ export async function saveItemChangeLog(roleId: string, goods: { id: number, cou
let role = await RoleModel.findByRoleId(roleId, 'userInfo roleId roleName serverId');
let params = getParamByRole(role);
for (let { id, count, inc } of goods) {
if(inc == 0) continue;
let dicGoods = gameData.goods.get(id);
await UserLogModel.createRecord({ type: LOG_TYPE.ITEM_CHANGE, ...params, itemId: id, itemName: dicGoods.name, itid: dicGoods.itid, inc, count, itemChangeReason: reason })
}