Merge branch 'master' into feature/backend
# Conflicts: # game-server/app/servers/connector/handler/entryHandler.ts # game-server/app/servers/role/handler/itemHandler.ts # shared/consts/constModules/sysConst.ts # shared/pubUtils/util.ts # web-server/app.ts # web-server/app/service/Auth.ts
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import { ActionPointModel, ActionPointType } from '../db/ActionPoint';
|
||||
import { TASK_TYPE, STATUS } from '../consts';
|
||||
import { TASK_TYPE, STATUS, TA_EVENT, ITEM_CHANGE_REASON } from '../consts';
|
||||
import { checkActivityTask, checkTask } from './taskService';
|
||||
import { getDicApByLv } from '../pubUtils/data';
|
||||
import { pinus } from 'pinus';
|
||||
@@ -11,24 +11,26 @@ import { resResult, shouldRefresh } from '../pubUtils/util';
|
||||
import { RoleModel } from '../db/Role';
|
||||
import { pick } from 'underscore';
|
||||
import { AP } from '../pubUtils/dicParam';
|
||||
import { reportTAEvent } from './sdkService';
|
||||
|
||||
/**
|
||||
* 获取当前体力
|
||||
* @param roleId 玩家id
|
||||
* @param lv 玩家等级
|
||||
*/
|
||||
export async function getAp(roleId: string, lv: number, fromGetAp = false) {
|
||||
export async function getAp(roleId: string, ip: string, lv: number, fromGetAp = false) {
|
||||
let dataAp = await ActionPointModel.getAp(roleId);
|
||||
return getApWithDataAp(lv, dataAp, fromGetAp);
|
||||
return getApWithDataAp(roleId, ip, lv, dataAp, fromGetAp);
|
||||
}
|
||||
|
||||
function getApWithDataAp(lv: number, dataAp: ActionPointType, fromGetAp = false) {
|
||||
function getApWithDataAp(roleId: string, ip: string, lv: number, dataAp: ActionPointType, fromGetAp = false) {
|
||||
|
||||
const now = Date.now();
|
||||
const dicAp = getDicApByLv(lv);
|
||||
const maxAp = dicAp.maxAp; // 最大体力值
|
||||
const per = AP.PERAPRESTORETIME * 1000; // 恢复时间(ms)
|
||||
let { ap, refTime, buyRefTime = 0, buyTimes = 0 } = dataAp;
|
||||
let oldAp = ap;
|
||||
|
||||
if(shouldRefresh(new Date(buyRefTime), new Date())) {
|
||||
buyTimes = 0;
|
||||
@@ -52,6 +54,10 @@ function getApWithDataAp(lv: number, dataAp: ActionPointType, fromGetAp = false)
|
||||
result = { ap, maxAp, refTime, apRemainTime, apMaxRemainTime, isOver: false, buyTimes, buyRefTime };
|
||||
}
|
||||
}
|
||||
if(result.ap > oldAp) {
|
||||
reportTAEvent(roleId, TA_EVENT.AP_GET, { change_count: oldAp - result.ap, change_after: result.ap, change_reason: ITEM_CHANGE_REASON.AP_RECOVERY })
|
||||
}
|
||||
|
||||
return fromGetAp?result: pick(result, ['ap', 'maxAp', 'apRemainTime', 'apMaxRemainTime', 'buyTimes']);
|
||||
}
|
||||
|
||||
@@ -62,10 +68,10 @@ function getApWithDataAp(lv: number, dataAp: ActionPointType, fromGetAp = false)
|
||||
* @param changeAp 体力变化,正是加,负是减
|
||||
* @param sid
|
||||
*/
|
||||
export async function setAp(roleId: string, lv: number, changeAp: number, sid: string) {
|
||||
export async function setAp(roleId: string, ip: string, lv: number, changeAp: number, sid: string, reason: ITEM_CHANGE_REASON) {
|
||||
const now = Date.now();
|
||||
const dicAp = getDicApByLv(lv);
|
||||
let ApResult = await getAp(roleId, lv, true);
|
||||
let ApResult = await getAp(roleId, ip, lv, true);
|
||||
let { ap, maxAp, refTime, apRemainTime, apMaxRemainTime, isOver, buyTimes } = ApResult; // 更新ap
|
||||
ap += changeAp;
|
||||
if (ap >= maxAp) { // 溢出
|
||||
@@ -85,8 +91,11 @@ export async function setAp(roleId: string, lv: number, changeAp: number, sid: s
|
||||
await checkTask(roleId, sid, TASK_TYPE.BATTLE_COST_AP, -1 * changeAp, true, {});
|
||||
let { serverId } = await RoleModel.findByRoleId(roleId);
|
||||
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_COST_AP, -1 * changeAp,);
|
||||
reportTAEvent(roleId, TA_EVENT.AP_CONSUME, { change_count: -1 * changeAp, change_after: ap, change_reason: reason }, ip)
|
||||
} else {
|
||||
reportTAEvent(roleId, TA_EVENT.AP_GET, { change_count: changeAp, change_after: ap, change_reason: reason }, ip)
|
||||
}
|
||||
let apJson = await getApWithDataAp(lv, dataAp);
|
||||
let apJson = await getApWithDataAp(roleId, ip, lv, dataAp);
|
||||
|
||||
if (changeAp != 0) {
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
@@ -96,10 +105,10 @@ export async function setAp(roleId: string, lv: number, changeAp: number, sid: s
|
||||
return apJson
|
||||
}
|
||||
|
||||
export async function setApBuyTimes(roleId: string, lv: number, sid: string, incTimes: number) {
|
||||
export async function setApBuyTimes(roleId: string, ip: string, lv: number, sid: string, incTimes: number) {
|
||||
if(incTimes <= 0) return false;
|
||||
|
||||
let ApResult = await getAp(roleId, lv, true);
|
||||
let ApResult = await getAp(roleId, ip, lv, true);
|
||||
let { ap, maxAp, refTime, apRemainTime, apMaxRemainTime, buyTimes, buyRefTime } = ApResult; // 更新ap
|
||||
|
||||
if(shouldRefresh(new Date(buyRefTime), new Date())) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ACTIVITY_TYPE, STATUS } from '../../consts';
|
||||
import { ACTIVITY_TYPE, ITEM_CHANGE_REASON, STATUS } from '../../consts';
|
||||
import { ActivityModel, ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityDailyRMBGiftsModel, ActivityDailyRMBGiftsModelType } from '../../db/ActivityDailyRMBGifts';
|
||||
import { DailyRMBGiftsData } from '../../domain/activityField/dailyRMBGiftsField';
|
||||
@@ -100,7 +100,7 @@ export async function makeDailyRMBGiftsReward(roleId: string, roleName: string,
|
||||
}
|
||||
}
|
||||
let rewardParamArr: Array<RewardParam> = stringToRewardParam(item.reward);
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr)
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.DAILY_RMB_GIFT)
|
||||
await ActivityDailyRMBGiftsModel.receiveRecord(serverId, activityId, roleId, moment(playerData.beginTime).toDate(), [item.id]);
|
||||
item.isReceive = true;
|
||||
return {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { GIFT_PACKAGE_TYPE, ACTIVITY_RESOURCES_TYPE } from '../../consts';
|
||||
import { GIFT_PACKAGE_TYPE, ACTIVITY_RESOURCES_TYPE, ITEM_CHANGE_REASON } from '../../consts';
|
||||
import { gameData } from '../../pubUtils/data';
|
||||
import { addItems, createHeroes } from './../rewardService';
|
||||
import { RewardParam } from '../../domain/activityField/rewardField';
|
||||
@@ -39,7 +39,7 @@ export async function useGiftPackage(roleId: string, roleName: string, sid: stri
|
||||
allReward = reward;
|
||||
}
|
||||
|
||||
result = await addReward(roleId, roleName, sid, serverId, allReward);
|
||||
result = await addReward(roleId, roleName, sid, serverId, allReward, ITEM_CHANGE_REASON.USE_GIFT_PACKAGE);
|
||||
break;
|
||||
}
|
||||
case GIFT_PACKAGE_TYPE.SELECTED_X://手选
|
||||
@@ -57,7 +57,7 @@ export async function useGiftPackage(roleId: string, roleName: string, sid: stri
|
||||
} else {
|
||||
allReward = selectedReward;
|
||||
}
|
||||
result = await addReward(roleId, roleName, sid, serverId, allReward);
|
||||
result = await addReward(roleId, roleName, sid, serverId, allReward, ITEM_CHANGE_REASON.USE_GIFT_PACKAGE);
|
||||
break;
|
||||
}
|
||||
case GIFT_PACKAGE_TYPE.RANDOM_X://随机
|
||||
@@ -69,7 +69,7 @@ export async function useGiftPackage(roleId: string, roleName: string, sid: stri
|
||||
let selectedReward = getSelectedReward(giftPackageData, selectedArray)
|
||||
allReward = allReward.concat(selectedReward);
|
||||
}
|
||||
result = await addReward(roleId, roleName, sid, serverId, allReward);
|
||||
result = await addReward(roleId, roleName, sid, serverId, allReward, ITEM_CHANGE_REASON.USE_GIFT_PACKAGE);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -80,13 +80,13 @@ export async function useGiftPackage(roleId: string, roleName: string, sid: stri
|
||||
}
|
||||
|
||||
//结算奖励的内容
|
||||
export async function addReward(roleId: string, roleName: string, sid: string, serverId: number, reward: Array<RewardParam>) {
|
||||
export async function addReward(roleId: string, roleName: string, sid: string, serverId: number, reward: Array<RewardParam>, reason: number) {
|
||||
let giftReward = rewardItemData(reward);
|
||||
let goodArray = giftReward.goods;
|
||||
let heroArray = giftReward.heroes;
|
||||
|
||||
//兑换物品
|
||||
let goods = await addItems(roleId, roleName, sid, goodArray)
|
||||
let goods = await addItems(roleId, roleName, sid, goodArray, reason)
|
||||
let addHeros = [];
|
||||
if (heroArray.length > 0) {
|
||||
let heroResult = await createHeroes(roleId, roleName, sid, serverId, heroArray);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import moment = require('moment');
|
||||
import { ACTIVITY_TYPE, STATUS } from '../../consts';
|
||||
import { ACTIVITY_TYPE, ITEM_CHANGE_REASON, STATUS } from '../../consts';
|
||||
import { ActivityModel, ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityShopModel, ActivityShopModelType } from '../../db/ActivityShop';
|
||||
import { RoleModel } from '../../db/Role';
|
||||
@@ -128,7 +128,7 @@ export async function makeLimitPackageReward(roleId: string, roleName: string, s
|
||||
}
|
||||
|
||||
let rewardArray = stringToRewardParam(item.reward)
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardArray);
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardArray, ITEM_CHANGE_REASON.BUY_LIMIT_PACKAGE);
|
||||
|
||||
await ActivityShopModel.addRecord(activityId, roleId, playerData.roundIndex, item.id);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ACTIVITY_TYPE, MAIL_TYPE, STATUS } from '../../consts';
|
||||
import { ACTIVITY_TYPE, ITEM_CHANGE_REASON, MAIL_TYPE, STATUS } from '../../consts';
|
||||
import { ActivityModel, ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityMonthlyTicketModel, ActivityMonthlyTicketModelType } from '../../db/ActivityMonthlyTicket';
|
||||
import { RewardParam } from '../../domain/activityField/rewardField';
|
||||
@@ -89,7 +89,7 @@ export async function getPlayerMonthlyTicketDayReward(roleId: string, roleName:
|
||||
if (playerData.todayIndex > playerData.dayIndex) {//今天还没领取
|
||||
await ActivityMonthlyTicketModel.setDayIndex(serverId, roleId, activityId, playerData.todayIndex);
|
||||
let rewardParamArr: Array<RewardParam> = stringToRewardParam(playerData.baseReward);
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr)
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.MONTHLY_TICKET_DAILY)
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ export async function makeMonthlyTicketReward(roleId: string, roleName: string,
|
||||
|
||||
let firstReward = playerData.firstReward;
|
||||
let rewardParamArr: Array<RewardParam> = stringToRewardParam(firstReward);
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr)
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.MONTHLY_TICKET_FIRST)
|
||||
return {
|
||||
code: 0,
|
||||
data: Object.assign(result, { item: { isOpen: true, todayIndex: 1 }, activityId: activityData.activityId })
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ACTIVITY_TYPE, STATUS } from '../../consts';
|
||||
import { ACTIVITY_TYPE, ITEM_CHANGE_REASON, STATUS } from '../../consts';
|
||||
import { ActivityModel, ActivityModelType } from '../../db/Activity';
|
||||
import { PopUpShopData, } from '../../domain/activityField/popUpShopField';
|
||||
import { RewardParam } from '../../domain/activityField/rewardField';
|
||||
@@ -106,7 +106,7 @@ export async function makePopUpShopReward(roleId: string, roleName: string, sid:
|
||||
playerData.setPlayerRecords(playerRecord);
|
||||
|
||||
let rewardParamArr: Array<RewardParam> = stringToRewardParam(playerData.reward);
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr)
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.POP_UP_BUY_GIFT)
|
||||
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import moment = require('moment');
|
||||
import { ACTIVITY_TYPE, STATUS } from '../../consts';
|
||||
import { ACTIVITY_TYPE, ITEM_CHANGE_REASON, STATUS } from '../../consts';
|
||||
import { ActivityModel, ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityRefreshShopModel, ActivityRefreshShopModelType } from '../../db/ActivityRefreshShop';
|
||||
import { RoleModel } from '../../db/Role';
|
||||
@@ -139,7 +139,7 @@ export async function makeRefreshShopReward(roleId: string, roleName: string, si
|
||||
}
|
||||
|
||||
let rewardArray = stringToRewardParam(item.reward)
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardArray);
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardArray, ITEM_CHANGE_REASON.BUY_REFRESH_SHOP);
|
||||
|
||||
await ActivityRefreshShopModel.addRecord(activityId, roleId, playerData.roundIndex, item.pageIndex, item.id);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ACTIVITY_TYPE, REFRESH_TIME, STATUS } from '../../consts';
|
||||
import { ACTIVITY_TYPE, ITEM_CHANGE_REASON, REFRESH_TIME, STATUS } from '../../consts';
|
||||
import { ActivityModel, ActivityModelType } from '../../db/Activity';
|
||||
import { ActivitySelfServiceGoodsModel, ActivitySelfServiceGoodsModelType } from '../../db/ActivitySelfServiceGoods';
|
||||
import { ActivitySelfServiceShopModel, ActivitySelfServiceShopModelType } from '../../db/ActivitySelfServiceShop';
|
||||
@@ -101,7 +101,7 @@ export async function addSelfServiceShopGiftReward(roleId: string, roleName: str
|
||||
for (let obj of rewardArray) {
|
||||
goodsStr += `${obj.type}&${obj.id}&${obj.count}|`;
|
||||
}
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardArray);
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardArray, ITEM_CHANGE_REASON.SELF_SERVICE_SHOP_BUY_GIFT);
|
||||
//购买记录
|
||||
console.log('dddddddd', rewardArray.length, serverId, activityId, roleId, roundIndex, index, goodsStr, JSON.stringify(item))
|
||||
await ActivitySelfServiceShopModel.addBuyRecord(serverId, activityId, roleId, roundIndex, index, goodsStr);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import moment = require('moment');
|
||||
import { ACTIVITY_TYPE, SERVER_OPEN_TIME, STATUS } from '../../consts';
|
||||
import { ACTIVITY_TYPE, ITEM_CHANGE_REASON, SERVER_OPEN_TIME, STATUS } from '../../consts';
|
||||
import { ActivityModel, ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityTreasureHuntShopModel, ActivityTreasureHuntShopModelType } from '../../db/ActivityTreasureHuntShop';
|
||||
import { ActivityTreasureHuntTaskModel, ActivityTreasureHuntTaskModelType } from '../../db/ActivityTreasureHuntTask';
|
||||
@@ -340,7 +340,7 @@ export async function makeShop(roleId: string, roleName: string, sid: string, se
|
||||
await ActivityTreasureHuntShopModel.buyShopRecord(activityId, roleId, huntRoundIndex, playerData.todayIndex, cellIndex);
|
||||
|
||||
let rewardParamArr: Array<RewardParam> = stringToRewardParam(item.reward);
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr)
|
||||
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.TREASURE_HUNT_SHOP_BUY)
|
||||
|
||||
item.buyCount += 1;
|
||||
return {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ACTIVITY_TYPE, STATUS } from '../../consts';
|
||||
import { ACTIVITY_TYPE, ITEM_CHANGE_REASON, STATUS } from '../../consts';
|
||||
import { ActivityModel, ActivityModelType } from '../../db/Activity';
|
||||
import { RoleModel } from '../../db/Role';
|
||||
import { ServerlistModel } from '../../db/Serverlist';
|
||||
@@ -88,7 +88,7 @@ export async function makeYuanbaoShopReward(roleId: string, roleName: string, si
|
||||
}
|
||||
}
|
||||
|
||||
let result = await addReward(roleId, roleName, sid, serverId, arr)
|
||||
let result = await addReward(roleId, roleName, sid, serverId, arr, ITEM_CHANGE_REASON.YUANBAO_SHOP_BUY)
|
||||
item.buyCount += 1;
|
||||
return {
|
||||
code: 0,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DividendModel } from './../db/Dividend';
|
||||
import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_TIME, DIVIDEND_CODE_LEN, DIVIDEND_STATUS, LOT_STATUS, MAIL_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, DIVIDENDMAXRATIO, DIVIDENDPOSITIONMAXRATIO, ROLE_RECEIVE_STATUS, AUCTION_BID_STATUS, DEBUG_MAGIC_WORD, AUCTION_SOURCE } from './../consts';
|
||||
import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_TIME, DIVIDEND_CODE_LEN, DIVIDEND_STATUS, LOT_STATUS, MAIL_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, DIVIDENDMAXRATIO, DIVIDENDPOSITIONMAXRATIO, ROLE_RECEIVE_STATUS, AUCTION_BID_STATUS, DEBUG_MAGIC_WORD, AUCTION_SOURCE, TA_EVENT, getAuctionSourceTypeName } from './../consts';
|
||||
import { DividendRec, ItemReward } from "../domain/dbGeneral";
|
||||
import { genCode, getRandSingleEelm } from '../pubUtils/util';
|
||||
import { LotModel, LotParam, LotType } from '../db/Lot';
|
||||
@@ -13,6 +13,7 @@ import { Member } from '../domain/battleField/guildActivity';
|
||||
import * as dicParam from '../pubUtils/dicParam';
|
||||
import { RewardInter } from '../pubUtils/interface';
|
||||
import { getGuildAuctionChannelSid, getGuildChannelSid, getWorldAuctionChannelSid, pushCurrentTime } from './chatService';
|
||||
import { reportTAEvent } from './sdkService';
|
||||
|
||||
// ! 获取底价,假数据
|
||||
export function getBasePrice(gid: number, count: number) {
|
||||
@@ -298,15 +299,19 @@ export async function startGuildAuction() {
|
||||
}
|
||||
|
||||
export async function sendLotsRewardToMlail(lots: LotType[]) {
|
||||
let lotByRole = new Map<string, RewardInter[]>();
|
||||
let lotByRole = new Map<string, (RewardInter&{price: number})[]>();
|
||||
for(let lot of lots) {
|
||||
if(!lotByRole.has(lot.curBuyer)) {
|
||||
lotByRole.set(lot.curBuyer, []);
|
||||
}
|
||||
lotByRole.get(lot.curBuyer).push({ id: lot.gid, count: lot.count });
|
||||
lotByRole.get(lot.curBuyer).push({ id: lot.gid, count: lot.count, price: lot.curPrice });
|
||||
}
|
||||
for(let [roleId, goods ] of lotByRole) {
|
||||
await sendMailByContent(MAIL_TYPE.AUTION_REWARD, roleId, { goods });
|
||||
for(let { id, count, price } of goods) {
|
||||
let dicGoods = gameData.goods.get(id);
|
||||
reportTAEvent(roleId, TA_EVENT.AUCTION_ITEM_GET, { item_name: dicGoods?.name, item_count: count, deel_price: price });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,6 +416,7 @@ export async function sendUngotDividend(debug = false) {
|
||||
if (dividendRec.status === ROLE_RECEIVE_STATUS.YES) continue;
|
||||
const sum = rewards.get(dividendRec.roleId) || 0;
|
||||
rewards.set(dividendRec.roleId, sum + dividendRec.total);
|
||||
reportTAEvent(dividendRec.roleId, TA_EVENT.AUCTION_DIVIDEND, { type: getAuctionSourceTypeName(dividend.sourceType), count: dividendRec.total })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { MemComBtlTeam } from './../domain/battleField/ComBattleTeamField';
|
||||
import { ItemModel } from './../db/Item';
|
||||
import { IT_TYPE } from './../consts';
|
||||
import { ITEM_CHANGE_REASON, IT_TYPE } from './../consts';
|
||||
import { COM_BTL_QUALITY } from './../consts/constModules/itemConst';
|
||||
import { FriendRelationModel } from './../db/FriendRelation';
|
||||
import { RoleModel, RoleType } from './../db/Role';
|
||||
@@ -14,7 +14,6 @@ import { getRandRobot, transBossHpArr } from "./battleService";
|
||||
import { difference, omit } from 'underscore';
|
||||
import { Channel, ChannelService, pinus } from 'pinus';
|
||||
import { TREASURE, EXTERIOR } from '../pubUtils/dicParam';
|
||||
import { addItems, decreaseItems, handleCost } from './rewardService';
|
||||
import { getFriendLvAdd } from './friendService';
|
||||
import { getRoleIds } from '../pubUtils/friendUtil';
|
||||
import { getTeamSearchByQuality, rmRoleFromQueue } from './redisService';
|
||||
@@ -26,6 +25,7 @@ import { getFriendPointObject } from '../pubUtils/itemUtils';
|
||||
import { DicWar } from '../pubUtils/dictionary/DicWar';
|
||||
import { getZeroPointD } from '../pubUtils/timeUtil';
|
||||
import { dispatch } from '../pubUtils/dispatcher';
|
||||
import { handleCost } from './rewardService';
|
||||
|
||||
/**
|
||||
* 在给定的品质列表中随机返回一定数量的藏宝图Id
|
||||
@@ -261,7 +261,7 @@ export async function handleComBtlProgress(teamStatus: MemComBtlTeam, robotHurtT
|
||||
// 战斗胜利队长扣减藏宝图
|
||||
if (result && teamStatus.capId != 'robot') {
|
||||
const { sid } = channel.getMember(teamStatus.capId);
|
||||
let res = await decreaseItems(teamStatus.capId, sid, [{ id: teamStatus.blueprtId, count: 1 }]);
|
||||
let res = await handleCost(teamStatus.capId, sid, [{ id: teamStatus.blueprtId, count: 1 }], ITEM_CHANGE_REASON.COM_BATTLE_USE_BLUEPRT);
|
||||
if (res === true) return resResult(STATUS.COM_BATTLE_BLUEPRT_NOT_ENOUGH);
|
||||
}
|
||||
// // 为了背包显示,队长藏宝图在创建队伍的时候就扣掉了,如果输了,返还藏宝图
|
||||
|
||||
@@ -17,7 +17,7 @@ import { DicQuenchQuality } from '../pubUtils/dictionary/DicQuenchQuality';
|
||||
*/
|
||||
export function checkMaterialEnough(consumes: Array<{ id: number, count: number }>, jewel: number, jewelCount: number) {
|
||||
let comJewelMap = new Map<number, number>(); // good_id => count
|
||||
let needConsumes:{ id: number, count: number, ratio?: number }[] = []
|
||||
let needConsumes:{ id: number, count: number }[] = []
|
||||
for(let {id, count} of consumes) {
|
||||
if(!comJewelMap.has(id)) {
|
||||
comJewelMap.set(id, count);
|
||||
|
||||
@@ -4,7 +4,7 @@ import Role, { RoleModel, RoleType } from '../db/Role'
|
||||
import { getLvByExp, getExpByLv, gameData, getDicApByLv } from '../pubUtils/data';
|
||||
import { updateUserInfo } from './redisService';
|
||||
// import { switchOnFunc } from './funcSwitchService';
|
||||
import { FUNC_OPT_TYPE, TASK_TYPE, WAR_TYPE, STATUS, KING_EXP_RATIO_TYPE } from '../consts';
|
||||
import { FUNC_OPT_TYPE, TASK_TYPE, WAR_TYPE, STATUS, KING_EXP_RATIO_TYPE, ITEM_CHANGE_REASON } from '../consts';
|
||||
import { BackendSession, pinus } from 'pinus';
|
||||
import { REDIS_KEY } from '../consts';
|
||||
import { Rank } from './rankService';
|
||||
@@ -20,6 +20,7 @@ import { uniq } from 'underscore';
|
||||
export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kingExp: number = 0, session: BackendSession) {
|
||||
const serverId = session.get('serverId');
|
||||
const sid = session.get('sid');
|
||||
const ip = session.get('ip');
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let { lv = 1, exp = 0 } = role;
|
||||
@@ -67,7 +68,7 @@ export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kin
|
||||
});
|
||||
if(i != lv) { // 升级加体力
|
||||
let dicAp = getDicApByLv(i);
|
||||
await setAp(roleId, i, dicAp.restoreAp, sid);
|
||||
await setAp(roleId, ip, i, dicAp.restoreAp, sid, ITEM_CHANGE_REASON.LV_UP);
|
||||
}
|
||||
}
|
||||
// 推送
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { UserOrderModel, UserOrderModelType } from '../db/UserOrder';
|
||||
import { ACTIVITY_TYPE, ORDER_STATE, STATUS, TASK_TYPE } from '../consts';
|
||||
import { ACTIVITY_TYPE, ORDER_STATE, STATUS, TASK_TYPE, TA_EVENT, TA_USERSET_TYPE } from '../consts';
|
||||
import { dicRMB } from '../pubUtils/dictionary/DicRMB';
|
||||
import { makeYuanbaoShopReward } from './activity/yuanbaoService';
|
||||
import { RoleModel } from '../db/Role';
|
||||
@@ -26,6 +26,7 @@ import { checkActivityTask } from './taskService';
|
||||
import { checkOrderALI } from './pay/aliPay';
|
||||
import { getRoleOnlineInfo } from './redisService';
|
||||
import { PayCallback37Data } from '../domain/sdk';
|
||||
import { reportTAEvent, reportTAUserSet } from './sdkService';
|
||||
|
||||
|
||||
/**
|
||||
@@ -158,6 +159,7 @@ export async function settleOrder(order: UserOrderModelType, serverId: number, s
|
||||
let result = await makeOrder(order, sid);
|
||||
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 })
|
||||
return resResult(result);
|
||||
}
|
||||
//推送
|
||||
@@ -175,6 +177,10 @@ export async function settleOrder(order: UserOrderModelType, serverId: number, s
|
||||
await addVipRechargeMoney(order.roleId, serverId, order.price);
|
||||
//成长任务
|
||||
await checkActivityTask(serverId, sid, order.roleId, TASK_TYPE.ACTIVITY_RMB, order.price, { activityId: order.activityId })
|
||||
reportTAEvent(order.roleId, TA_EVENT.RECHARGE_SUCCESS, { pay_id: order.localOrderID, charge_id: order.productID, pay_name: order.message, pay_amount: order.price, pay_channel: order.payType })
|
||||
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 });
|
||||
|
||||
return result.data;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { PvpDefenseModel, PvpDefenseType, pvpUpdateInter } from '../db/PvpDefense';
|
||||
import { Defense, Attack, LineupCe, OppPlayer, HeroScore, HeroReward, OppPlayerReturn, AttackHero, DefenseHero } from '../domain/battleField/pvp';
|
||||
import { RoleType, CeAttrDataRole } from '../db/Role';
|
||||
import { PVP_HERO_POS, REDIS_KEY, PVP_CONST, COUNTER, TASK_TYPE, MAIL_TYPE } from '../consts';
|
||||
import { PVP_HERO_POS, REDIS_KEY, PVP_CONST, COUNTER, TASK_TYPE, MAIL_TYPE, TA_EVENT } from '../consts';
|
||||
import { dicPvpOpponent, DicPvpOpponent } from "../pubUtils/dictionary/DicPvpOpponent";
|
||||
import { getRandSingleIndex, genCode, shouldRefresh, getChineseName, makeRobotId, robotIdComBack, getRandSingleEelm } from '../pubUtils/util';
|
||||
import { pvpEndParamInter, RewardInter } from '../pubUtils/interface';
|
||||
@@ -25,6 +25,7 @@ import { PvpSeasonResultModel, PvpSeasonResultType } from '../db/PvpSeasonResult
|
||||
import { checkTask } from '../services/taskService';
|
||||
import { sendMailByContent } from './mailService';
|
||||
import { RoleRankInfo } from '../domain/rank';
|
||||
import { reportTAEvent } from './sdkService';
|
||||
|
||||
/**
|
||||
* 返回对手三人信息
|
||||
@@ -330,7 +331,8 @@ export async function sendLastSeasonRewardIfNotSent(pvpDefense: PvpDefenseType)
|
||||
let seasonNum: number = pinus.app.get('pvpSeasonNum');
|
||||
if(pvpDefense.seasonNum < seasonNum) {
|
||||
let oldPvpCongig = await PVPConfigModel.findPVPConfig(pvpDefense.seasonNum);
|
||||
pvpDefense = await sendPVPRewardToUser(pvpDefense, pvpDefense.seasonNum, oldPvpCongig.seasonEndTime);
|
||||
let result = await sendPVPRewardToUser(pvpDefense, pvpDefense.seasonNum, oldPvpCongig.seasonEndTime);
|
||||
pvpDefense = result.pvpDefense;
|
||||
}
|
||||
return pvpDefense;
|
||||
}
|
||||
@@ -530,7 +532,8 @@ export async function generPVPOppRecInfo(isSuccess: boolean, curOpp: OppPlayer,
|
||||
for(let { rank, roleId } of allRank) {
|
||||
console.log('******** pvpSeasonEnd: ', rank, roleId);
|
||||
let pvpDefense = await PvpDefenseModel.findByRoleId(roleId);
|
||||
await sendPVPRewardToUser(pvpDefense, pvpConfig.seasonNum, pvpConfig.seasonEndTime);
|
||||
let { pvpSeasonResult } = await sendPVPRewardToUser(pvpDefense, pvpConfig.seasonNum, pvpConfig.seasonEndTime);
|
||||
reportTAEvent(roleId, TA_EVENT.PVP_SEASON_END, { top_rank: rank, hero_score: pvpSeasonResult.heroScores })
|
||||
}
|
||||
await PVPConfigModel.setReward(pvpConfig.seasonNum);
|
||||
}
|
||||
@@ -557,7 +560,10 @@ export async function sendPVPRewardToUser(pvpDefense: PvpDefenseType, seasonNum:
|
||||
goods: heroGoods, notPush
|
||||
});
|
||||
|
||||
return await resetPvpScores(pvpDefense, seasonNum + 1, pvpSeasonResult);
|
||||
return {
|
||||
pvpSeasonResult,
|
||||
pvpDefense: await resetPvpScores(pvpDefense, seasonNum + 1, pvpSeasonResult)
|
||||
}
|
||||
}
|
||||
|
||||
async function resetPvpScores(pvpDefense: PvpDefenseType, seasonNum: number, pvpSeasonResult: PvpSeasonResultType) {
|
||||
|
||||
@@ -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 } 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;
|
||||
@@ -93,7 +94,7 @@ export class CheckMeterial {
|
||||
}
|
||||
|
||||
|
||||
export async function handleCost(roleId: string, sid: string, goods: Array<ItemInter>) {
|
||||
export async function handleCost(roleId: string, sid: string, goods: Array<ItemInter>, reason: ITEM_CHANGE_REASON) {
|
||||
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
let { items, equips, gold, coin } = sortItems(goods, HANDLE_REWARD_TYPE.COST);
|
||||
@@ -118,7 +119,7 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
|
||||
if (items.length > 0) {
|
||||
let { hasError, result } = await ItemModel.decreaseItems(roleId, items);
|
||||
if (hasError) return false;
|
||||
pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, { goods: result }), uids);
|
||||
pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, { goods: result.map(cur => ({...cur, reason })) }), uids);
|
||||
}
|
||||
|
||||
//删除装备
|
||||
@@ -144,24 +145,35 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
|
||||
}
|
||||
|
||||
|
||||
await EquipModel.deleteEquips(roleId, equipSeqIds);
|
||||
pinus.app.get('channelService').pushMessageByUids('onEquipDel', resResult(STATUS.SUCCESS, { equips: equipSeqIds }), uids);
|
||||
let equips = await EquipModel.deleteEquips(roleId, equipSeqIds);
|
||||
pinus.app.get('channelService').pushMessageByUids('onEquipDel', resResult(STATUS.SUCCESS, { equips: equips.map(equip => ({ seqId: equip.seqId, id: equip.id, inc: -1, reason })) }), uids);
|
||||
}
|
||||
|
||||
//消耗玩家货币
|
||||
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;
|
||||
}
|
||||
|
||||
// TODO: sid 在方法内部获取,且不一定存在
|
||||
export async function addItems(roleId: string, roleName: string, sid: string, goods: Array<ItemInter>) {
|
||||
export async function addItems(roleId: string, roleName: string, sid: string, goods: Array<ItemInter>, reason: ITEM_CHANGE_REASON) {
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
let { items, equips, gold, coin, ap, skins, figures } = sortItems(goods, HANDLE_REWARD_TYPE.RECEIVE);
|
||||
let showItems: { id: number, seqId?: number, count: number, isBag?: boolean }[] = [];
|
||||
@@ -178,7 +190,7 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
}
|
||||
|
||||
// 直接加的
|
||||
let { equips: equipInfos, pushMessages } = await addEquips(roleId, roleName, <{id: number, hid?: number}[]>incEquips);
|
||||
let { equips: equipInfos, pushMessages } = await addEquips(roleId, roleName, <{id: number, hid?: number}[]>incEquips, reason);
|
||||
for (let equip of equipInfos) {
|
||||
showItems.push({ seqId: equip.seqId, id: equip.id, count: 1, isBag: true });
|
||||
}
|
||||
@@ -202,7 +214,7 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
|
||||
// 2. 道具处理
|
||||
if(items.length > 0) {
|
||||
let { items: itemInfos } = await addBags(roleId, roleName, items);
|
||||
let { items: itemInfos } = await addBags(roleId, roleName, items, reason);
|
||||
for (let item of items) {
|
||||
showItems.push({ id: item.id, count: item.count });
|
||||
}
|
||||
@@ -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));
|
||||
@@ -239,7 +256,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 }[] = [];
|
||||
let skinInfos: {id: number, hid: number, inc: number, reason: number }[] = [];
|
||||
let calAllHeroResult = undefined; // 全局战力变化推送
|
||||
|
||||
for (let skinId of skins) {//皮肤推送
|
||||
@@ -251,7 +268,7 @@ 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 })
|
||||
skinInfos.push({ id: skinId, hid: result.hero?.hid||0, inc: 1, reason })
|
||||
}
|
||||
}
|
||||
if (!!skinInfos.length) {
|
||||
@@ -263,7 +280,7 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
||||
|
||||
// 5. 获得头像和相框等
|
||||
if(figures.length > 0) {
|
||||
let figureInfo = await addFigure(roleId, figures);
|
||||
let figureInfo = await addFigure(roleId, figures, reason);
|
||||
if(figureInfo) figureInfos.push(figureInfo);
|
||||
for (let id of figures) {//皮肤推送
|
||||
showItems.push({ id, count: 1 });
|
||||
@@ -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) {
|
||||
@@ -390,17 +419,6 @@ function sortItems(goods: ItemInter[], handleType: HANDLE_REWARD_TYPE) {
|
||||
return { items, equips, gold, coin, ap, skins, figures }
|
||||
}
|
||||
|
||||
export async function decreaseItems(roleId: string, sid: string, bags: Array<{ id: number, count: number, ratio?: number }>) {
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
if (bags.length > 0) {
|
||||
let { hasError, result } = await ItemModel.decreaseItems(roleId, bags);
|
||||
if (hasError) return true;
|
||||
pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, { goods: result }), uids);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
export async function checkGoods(roleId: string, goodIds: Array<number>) {
|
||||
let equipIds: Array<number> = [];
|
||||
let itemIds: Array<number> = [];
|
||||
@@ -507,7 +525,7 @@ export async function createHeroes(roleId: string, roleName: string, sid: string
|
||||
}
|
||||
|
||||
if (pieces.length > 0) {
|
||||
let goods = await addItems(roleId, roleName, sid, pieces);
|
||||
let goods = await addItems(roleId, roleName, sid, pieces, ITEM_CHANGE_REASON.HERO_TRANSFER_PIECE);
|
||||
resultItems = goods;
|
||||
}
|
||||
return { heroes, resultHeroes, goods: resultItems }
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Chat37Params, CheckGuild37Params, CheckName37Params, GetWordParam } fro
|
||||
import { sendMailByContent, sendMailToGuildByContent } from './mailService';
|
||||
import { getGoldObject } from '../pubUtils/itemUtils';
|
||||
import { NAMEPLATE } from '../pubUtils/dicParam';
|
||||
import { CHANNEL_PREFIX, FILENAME, getSdkChannelId, MAIL_TYPE, REDIS_KEY, SDK_37_ADDR, SDK_37_CONST, SDK_TA_CONST, STATUS, THINKING_DATA_MODE, THINKING_DATA_MODE_LIST } from "../consts";
|
||||
import { CHANNEL_PREFIX, FILENAME, getSdkChannelId, MAIL_TYPE, REDIS_KEY, SDK_37_ADDR, SDK_37_CONST, SDK_TA_CONST, STATUS, TA_USERSET_TYPE, THINKING_DATA_MODE, THINKING_DATA_MODE_LIST } from "../consts";
|
||||
import { UserModel } from "../db/User";
|
||||
import { request37CheckChat, request37GetWord, request37Post } from "../pubUtils/httpUtil";
|
||||
import { GuildModel } from "../db/Guild";
|
||||
@@ -167,22 +167,21 @@ export function connectThinkingData(app: Application) {
|
||||
pm2: true
|
||||
});
|
||||
}
|
||||
ta.setDynamicSuperProperties(() => {
|
||||
return {
|
||||
env: app.get('env'),
|
||||
server: app.getServerId(),
|
||||
mode: THINKING_DATA_MODE
|
||||
};
|
||||
});
|
||||
// ta.setDynamicSuperProperties(() => {
|
||||
// return {
|
||||
// env: app.get('env'),
|
||||
// server: app.getServerId(),
|
||||
// mode: THINKING_DATA_MODE
|
||||
// };
|
||||
// });
|
||||
app.set('ta', ta);
|
||||
}
|
||||
|
||||
export function reportTAEvent(userCode: string, serverId: number, eventName: string, ip: string) {
|
||||
console.log(userCode, serverId)
|
||||
export function reportTAEvent(roleId: string, eventName: string, properties: any, ip?: string) {
|
||||
let ta = pinus.app.get('ta');
|
||||
let event = {
|
||||
// 账号 ID (可选)
|
||||
accountId: `${userCode}`,
|
||||
accountId: `${roleId}`,
|
||||
// 访客 ID (可选),账号 ID 和访客 ID 不可以都为空
|
||||
distinctId: "",
|
||||
// 事件名称 (必填)
|
||||
@@ -192,9 +191,7 @@ export function reportTAEvent(userCode: string, serverId: number, eventName: st
|
||||
// 事件 IP (可选) 当传入 IP 地址时,后台可以解析所在地
|
||||
ip: ip,
|
||||
// 事件属性 (可选)
|
||||
properties: {
|
||||
serverId
|
||||
},
|
||||
properties,
|
||||
callback(err) {
|
||||
console.log('*****测试接入事件', err)
|
||||
}
|
||||
@@ -203,6 +200,37 @@ export function reportTAEvent(userCode: string, serverId: number, eventName: st
|
||||
ta.track(event);
|
||||
}
|
||||
|
||||
export function reportTAUserSet(type: TA_USERSET_TYPE, roleId: string, properties: any) {
|
||||
let ta = pinus.app.get('ta');
|
||||
let userData = {
|
||||
// 账号 ID (可选)
|
||||
accountId: `${roleId}`,
|
||||
// 访客 ID (可选),账号 ID 和访客 ID 不可以都为空
|
||||
distinctId: "",
|
||||
// 用户属性
|
||||
properties,
|
||||
// 出错时回调 (可选)
|
||||
callback(e) {
|
||||
if (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
if(type == TA_USERSET_TYPE.SET) {
|
||||
ta.userSet(userData);
|
||||
} else if (type == TA_USERSET_TYPE.SET_ONCE) {
|
||||
ta.userSetOnce(userData);
|
||||
} else if (type == TA_USERSET_TYPE.ADD) {
|
||||
ta.userAdd(userData);
|
||||
}
|
||||
}
|
||||
|
||||
export function taflush() {
|
||||
let ta = pinus.app.get('ta');
|
||||
ta.flush();
|
||||
ta.close();
|
||||
}
|
||||
|
||||
export async function fetch37Words() {
|
||||
let params = new GetWordParam();
|
||||
let result = await request37GetWord(SDK_37_ADDR.GET_WORD, params, SDK_37_CONST.CHAT_KEY);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BattleDropModel } from '../db/BattleDrop';
|
||||
import { getRandEelmWithWeight, getRandSingleEelm } from '../pubUtils/util';
|
||||
import { getRandEelmWithWeight, getRandSingleEelm, getReasonByWarType } from '../pubUtils/util';
|
||||
import { BATTLE_REWARD_TYPE, BLUEPRT_CONST } from '../consts';
|
||||
import { addItems, combineItemAndEquips } from './rewardService';
|
||||
import { BattleBlueprtDropModel } from '../db/BattleBlueprtDrop'
|
||||
@@ -186,8 +186,7 @@ export class WarReward {
|
||||
if(combine) {
|
||||
rewards = combineItemAndEquips(rewards);
|
||||
}
|
||||
await addItems(this.roleId, this.roleName, this.sid, rewards);
|
||||
await addItems(this.roleId, this.roleName, this.sid, rewards, getReasonByWarType(this.warInfo.warType));
|
||||
return rewards;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user