数数:埋点
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ITID, CONSUME_TYPE, ITEM_TABLE, REDIS_KEY, TASK_TYPE, CURRENCY, CURRENCY_TYPE, MAIL_TYPE, HANDLE_REWARD_TYPE, HERO_SYSTEM_TYPE, CURRENCY_BY_TYPE, ITEM_CHANGE_REASON } from './../consts';
|
||||
import { ITID, CONSUME_TYPE, ITEM_TABLE, REDIS_KEY, TASK_TYPE, CURRENCY, CURRENCY_TYPE, MAIL_TYPE, HANDLE_REWARD_TYPE, HERO_SYSTEM_TYPE, CURRENCY_BY_TYPE, ITEM_CHANGE_REASON, TA_USERSET_TYPE, TA_EVENT } from './../consts';
|
||||
import { EquipModel, EquipType } from './../db/Equip';
|
||||
import { getRandSingleEelm, resResult } from '../pubUtils/util';
|
||||
import { RoleModel, RoleType } from '../db/Role';
|
||||
@@ -25,6 +25,7 @@ import { CreateHeroes } from '../pubUtils/roleUtil';
|
||||
import { SkinUpdate } from '../db/Skin';
|
||||
import { getInitHeroById } from './roleService';
|
||||
import { getActivities } from './activity/activityService';
|
||||
import { reportTAEvent, reportTAUserSet } from './sdkService';
|
||||
|
||||
export class CheckMeterial {
|
||||
private roleId: string;
|
||||
@@ -150,11 +151,22 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
|
||||
|
||||
//消耗玩家货币
|
||||
if (gold.length > 0 || coin.length > 0) {
|
||||
let costGold = gold.reduce((pre, cur) => pre + cur.count, 0);
|
||||
let costCoin = coin.reduce((pre, cur) => pre + cur, 0);
|
||||
role = await RoleModel.decreaseGoldAndCoin(roleId, gold, costCoin);
|
||||
pinus.app.get('channelService').pushMessageByUids('onPlayerDataChange', resResult(STATUS.SUCCESS, {
|
||||
gold: role.gold, coin: role.coin, totalCost: role.totalCost
|
||||
}), uids);
|
||||
|
||||
if(costGold > 0) {
|
||||
reportTAEvent(roleId, TA_EVENT.ITEM_CONSUME, getGoldEventProperties(costGold, role.gold, reason));
|
||||
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_gold: role.gold });
|
||||
}
|
||||
if(costCoin > 0) {
|
||||
reportTAEvent(roleId, TA_EVENT.ITEM_CONSUME, getCoinEventProperties(costCoin, role.coin, reason));
|
||||
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_coin: role.coin });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -214,8 +226,9 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
|
||||
// 3. 货币推送
|
||||
if(gold.length > 0 || coin.length > 0 || ap > 0) {
|
||||
let { ap: addAp } = await setAp(roleId, role.lv, ap, sid);
|
||||
let { ap: addAp } = await setAp(roleId, null, role.lv, ap, sid, reason);
|
||||
let incCoin = coin.reduce((pre, cur) => pre + cur, 0);
|
||||
let incGold = gold.reduce((pre, cur) => pre + cur.count, 0);
|
||||
role = await RoleModel.increaseGoldAndCoin(roleId, gold, incCoin);
|
||||
pinus.app.get('channelService').pushMessageByUids('onPlayerDataChange', resResult(STATUS.SUCCESS, {
|
||||
gold: role.gold, coin: role.coin, ap: addAp
|
||||
@@ -224,11 +237,15 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
gold.forEach(({ count }) => {
|
||||
showItems.push(getGoldObject(count));
|
||||
});
|
||||
reportTAEvent(roleId, TA_EVENT.ITEM_GET, getGoldEventProperties(incGold, role.gold, reason));
|
||||
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_gold: role.gold });
|
||||
}
|
||||
if(coin.length > 0) {
|
||||
coin.forEach(count => {
|
||||
showItems.push(getCoinObject(count));
|
||||
});
|
||||
reportTAEvent(roleId, TA_EVENT.ITEM_GET, getCoinEventProperties(incCoin, role.coin, reason));
|
||||
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_coin: role.coin });
|
||||
}
|
||||
if(ap > 0) {
|
||||
showItems.push(getApObject(ap));
|
||||
@@ -280,6 +297,18 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
return showItems;
|
||||
}
|
||||
|
||||
function getGoldEventProperties(inc: number, count: number, reason: ITEM_CHANGE_REASON) {
|
||||
let id = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD);
|
||||
let dicGoods = gameData.goods.get(id);
|
||||
return { item_id: id, item_name: dicGoods.name, item_itid: dicGoods.itid, change_count: inc, change_after: count, change_reason: reason }
|
||||
}
|
||||
|
||||
function getCoinEventProperties(inc: number, count: number, reason: ITEM_CHANGE_REASON) {
|
||||
let id = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN);
|
||||
let dicGoods = gameData.goods.get(id);
|
||||
return { item_id: id, item_name: dicGoods.name, item_itid: dicGoods.itid, change_count: inc, change_after: count, change_reason: reason }
|
||||
}
|
||||
|
||||
export function combineItems(items: { id?: number, count?: number }[]) {
|
||||
let result: { id: number, count: number }[] = [];
|
||||
for(let { id, count = 1 } of items) {
|
||||
|
||||
Reference in New Issue
Block a user