日志:添加玩家日志
This commit is contained in:
@@ -7,7 +7,7 @@ import { Application, HandlerService, pinus, } from 'pinus';
|
||||
import { FrontendSession } from 'pinus';
|
||||
import { HeroModel } from './../../../db/Hero';
|
||||
import { genCode, generateStr, resResult } from '../../../pubUtils/util';
|
||||
import { COM_BTL_QUALITY, HERO_SELECT, DEBUG_MAGIC_WORD, REDIS_KEY, TASK_TYPE, ENTERY_ROLE_PICK, COUNTER, DEFAULT_LV, TA_USERSET_TYPE } from '../../../consts';
|
||||
import { COM_BTL_QUALITY, HERO_SELECT, DEBUG_MAGIC_WORD, REDIS_KEY, TASK_TYPE, ENTERY_ROLE_PICK, COUNTER, DEFAULT_LV, TA_USERSET_TYPE, LOG_TYPE } from '../../../consts';
|
||||
import { getAp } from '../../../services/actionPointService';
|
||||
import { ItemModel } from '../../../db/Item';
|
||||
import { SkinModel } from '../../../db/Skin';
|
||||
@@ -25,6 +25,7 @@ import { setComBtlOnUserLeave } from '../../../services/comBattleService';
|
||||
import Counter from '../../../db/Counter';
|
||||
import { getExpByLv } from '../../../pubUtils/data';
|
||||
import { reportTAUserSet } from '../../../services/sdkService';
|
||||
import { saveLoginAndOutLog } from '../../../pubUtils/logUtil';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -69,6 +70,7 @@ export class EntryHandler {
|
||||
let serverName = this.app.getServerId();
|
||||
await roleLogin(role.roleId, user.userCode, serverName, user.pkgName); // 保存在线用户
|
||||
await this.addSession(role, session);
|
||||
saveLoginAndOutLog(LOG_TYPE.LOGIN, session);
|
||||
|
||||
// put user into channel
|
||||
// console.log(JSON.stringify(self.app.rpc.battle))
|
||||
@@ -224,6 +226,7 @@ export class EntryHandler {
|
||||
if(teamCode) { // 如果有寻宝中的队伍,那么等于战败
|
||||
setComBtlOnUserLeave(roleId, teamCode)
|
||||
}
|
||||
saveLoginAndOutLog(LOG_TYPE.LOGINOUT, session);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -342,10 +342,10 @@ function randomQuestion(num: number) {
|
||||
let rid:Array<number> = [], result = [];
|
||||
while(num > 0) {
|
||||
let dicQuestion = getRandSingleEelm(questions);
|
||||
let {id, question, answer, correct} = dicQuestion;
|
||||
let {id, question, answer } = dicQuestion;
|
||||
if(rid.includes(id)) continue;
|
||||
rid.push(id);
|
||||
result.push({id, question, answer, correct});
|
||||
result.push({id, question, answer});
|
||||
num--;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -27,6 +27,7 @@ import { checkOrderALI } from './pay/aliPay';
|
||||
import { getRoleOnlineInfo } from './redisService';
|
||||
import { PayCallback37Data } from '../domain/sdk';
|
||||
import { reportTAEvent, reportTAUserSet } from './sdkService';
|
||||
import { savePayLog } from '../pubUtils/logUtil';
|
||||
|
||||
|
||||
/**
|
||||
@@ -160,6 +161,7 @@ export async function settleOrder(order: UserOrderModelType, serverId: number, s
|
||||
if (result.code !== 0) {//结算失败
|
||||
console.log(`支付失败..... ${JSON.stringify(result)}`)
|
||||
reportTAEvent(order.roleId, TA_EVENT.RECHARGE_FAIL, { pay_id: order.localOrderID, charge_id: order.productID, pay_name: order.message, pay_amount: order.price, pay_channel: order.payType })
|
||||
savePayLog(order);
|
||||
return resResult(result);
|
||||
}
|
||||
//推送
|
||||
@@ -181,7 +183,7 @@ export async function settleOrder(order: UserOrderModelType, serverId: number, s
|
||||
reportTAUserSet(TA_USERSET_TYPE.SET_ONCE, order.roleId, { first_pay_time: new Date() });
|
||||
reportTAUserSet(TA_USERSET_TYPE.SET, order.roleId, { last_pay_time: new Date() });
|
||||
reportTAUserSet(TA_USERSET_TYPE.ADD, order.roleId, { total_revenue: order.price });
|
||||
|
||||
savePayLog(order);
|
||||
return result.data;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import { SkinUpdate } from '../db/Skin';
|
||||
import { getInitHeroById } from './roleService';
|
||||
import { getActivities } from './activity/activityService';
|
||||
import { reportTAEvent, reportTAUserSet } from './sdkService';
|
||||
import { saveCoinChangeLog, saveFigureInfoLog, saveGoldChangeLog, saveItemChangeLog } from '../pubUtils/logUtil';
|
||||
|
||||
export class CheckMeterial {
|
||||
private roleId: string;
|
||||
@@ -120,6 +121,7 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
|
||||
let { hasError, result } = await ItemModel.decreaseItems(roleId, items);
|
||||
if (hasError) return false;
|
||||
pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, { goods: result.map(cur => ({...cur, reason })) }), uids);
|
||||
saveItemChangeLog(roleId, result, reason);
|
||||
}
|
||||
|
||||
//删除装备
|
||||
@@ -146,6 +148,7 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
|
||||
|
||||
|
||||
let equips = await EquipModel.deleteEquips(roleId, equipSeqIds);
|
||||
saveItemChangeLog(roleId, equips.map(equip => ({ id: equip.id, count: equip.count, inc: -1 })), reason);
|
||||
pinus.app.get('channelService').pushMessageByUids('onEquipDel', resResult(STATUS.SUCCESS, { equips: equips.map(equip => ({ seqId: equip.seqId, id: equip.id, inc: -1, reason })) }), uids);
|
||||
}
|
||||
|
||||
@@ -161,10 +164,12 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
|
||||
if(costGold > 0) {
|
||||
reportTAEvent(roleId, TA_EVENT.ITEM_CONSUME, getGoldEventProperties(costGold, role.gold, reason));
|
||||
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_gold: role.gold });
|
||||
saveGoldChangeLog(roleId, role.gold, -1 * costGold, reason);
|
||||
}
|
||||
if(costCoin > 0) {
|
||||
reportTAEvent(roleId, TA_EVENT.ITEM_CONSUME, getCoinEventProperties(costCoin, role.coin, reason));
|
||||
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_coin: role.coin });
|
||||
saveCoinChangeLog(roleId, role.coin, -1 * costCoin, reason);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -205,6 +210,7 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
if (equipInfos.length > 0) {
|
||||
let { serverId } = await RoleModel.findByRoleId(roleId);
|
||||
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY_COUNT, equipInfos.length, { equips: equipInfos.map(obj => { return { quality: obj.quality } }) })
|
||||
saveItemChangeLog(roleId, equipInfos, reason);
|
||||
}
|
||||
// 发邮件的
|
||||
if(mailEquips.length > 0) {
|
||||
@@ -219,8 +225,10 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
showItems.push({ id: item.id, count: item.count });
|
||||
}
|
||||
//背包除去装备推送
|
||||
if (!!itemInfos.length)
|
||||
pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, { goods: itemInfos }), uids);
|
||||
if (!!itemInfos.length) {
|
||||
pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, { goods: itemInfos }), uids);
|
||||
saveItemChangeLog(roleId, itemInfos, reason);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -239,6 +247,7 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
});
|
||||
reportTAEvent(roleId, TA_EVENT.ITEM_GET, getGoldEventProperties(incGold, role.gold, reason));
|
||||
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_gold: role.gold });
|
||||
saveGoldChangeLog(roleId, role.gold, incGold, reason );
|
||||
}
|
||||
if(coin.length > 0) {
|
||||
coin.forEach(count => {
|
||||
@@ -246,6 +255,7 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
});
|
||||
reportTAEvent(roleId, TA_EVENT.ITEM_GET, getCoinEventProperties(incCoin, role.coin, reason));
|
||||
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_coin: role.coin });
|
||||
saveCoinChangeLog(roleId, role.coin, incCoin, reason);
|
||||
}
|
||||
if(ap > 0) {
|
||||
showItems.push(getApObject(ap));
|
||||
@@ -256,7 +266,7 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
let figureInfos:{ heads: Figure[], frames: Figure[], spines: Figure[] }[] = []; // 头像变化推送信息
|
||||
if(skins.length > 0) {
|
||||
let heroskins: {skins: HeroSkin[], hid: number}[] = []; // 皮肤推送信息
|
||||
let skinInfos: {id: number, hid: number, inc: number, reason: number }[] = [];
|
||||
let skinInfos: {id: number, hid: number, count: number, inc: number, reason: number }[] = [];
|
||||
let calAllHeroResult = undefined; // 全局战力变化推送
|
||||
|
||||
for (let skinId of skins) {//皮肤推送
|
||||
@@ -268,11 +278,12 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
heroskins.push({ skins: result.hero.skins, hid: result.hero.hid });
|
||||
if(result.calAllHeroResult) calAllHeroResult = result.calAllHeroResult;
|
||||
}
|
||||
skinInfos.push({ id: skinId, hid: result.hero?.hid||0, inc: 1, reason })
|
||||
skinInfos.push({ id: skinId, hid: result.hero?.hid||0, count: 1, inc: 1, reason })
|
||||
}
|
||||
}
|
||||
if (!!skinInfos.length) {
|
||||
pushHeroSkinMsg(heroskins, skinInfos, uids); // 推送onHeroSkinChange
|
||||
saveItemChangeLog(roleId, skinInfos, reason);
|
||||
}
|
||||
// 推送全局加成信息
|
||||
if(calAllHeroResult) await pushCalAllHeroCe(roleId, sid, calAllHeroResult);
|
||||
@@ -291,6 +302,7 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
if(!!figureInfos && figureInfos.length > 0) {
|
||||
for(let figureInfo of figureInfos) {
|
||||
pinus.app.get('channelService').pushMessageByUids('onHeadChange', resResult(STATUS.SUCCESS, { ...figureInfo }), uids);
|
||||
saveFigureInfoLog(roleId, figureInfo, reason)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user