活动:创建英雄的统计添加推送逻辑
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
import { Application, BackendSession } from 'pinus';
|
import { Application, BackendSession } from 'pinus';
|
||||||
import { resResult } from '../../../pubUtils/util';
|
import { resResult } from '../../../pubUtils/util';
|
||||||
import { STATUS } from '../../../consts';
|
import { STATUS } from '../../../consts';
|
||||||
import { getPlayerGrowthFundData, growthFundActivity } from '../../../services/growthFundService';
|
import { getPlayerGrowthFundData } from '../../../services/growthFundService';
|
||||||
import { GrowthFundItem } from '../../../domain/activityField/growthFundField';
|
import { GrowthFundItem } from '../../../domain/activityField/growthFundField';
|
||||||
import { addItems, createHeroes } from '../../../services/rewardService';
|
|
||||||
import { ActivityGrowthFundModel } from '../../../db/ActivityGrowthFund';
|
import { ActivityGrowthFundModel } from '../../../db/ActivityGrowthFund';
|
||||||
import { addReward, stringToRewardParam } from '../../../services/giftPackageService';
|
import { addReward, stringToRewardParam } from '../../../services/giftPackageService';
|
||||||
import { RewardParam } from '../../../domain/activityField/rewardField';
|
import { RewardParam } from '../../../domain/activityField/rewardField';
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { uniq, indexOf, findIndex } from 'underscore';
|
|||||||
import { HeroModel, HeroType } from '../db/Hero';
|
import { HeroModel, HeroType } from '../db/Hero';
|
||||||
import { Figure } from '../domain/dbGeneral';
|
import { Figure } from '../domain/dbGeneral';
|
||||||
import { Rank } from './rankService';
|
import { Rank } from './rankService';
|
||||||
import { checkActivityTask, pushTaskUpdate } from './taskService';
|
import { checkActivityTask, pushActivityUpdate, pushTaskUpdate } from './taskService';
|
||||||
import { CreateHeroParam } from '../domain/roleField/hero';
|
import { CreateHeroParam } from '../domain/roleField/hero';
|
||||||
|
|
||||||
export async function handleCost(roleId: string, sid: string, goods: Array<ItemInter>) {
|
export async function handleCost(roleId: string, sid: string, goods: Array<ItemInter>) {
|
||||||
@@ -333,7 +333,7 @@ export async function createHeroes(roleId: string, roleName: string, sid: string
|
|||||||
let resultHeroes: HeroType[] = [], resultItems: ItemInter[] = [];
|
let resultHeroes: HeroType[] = [], resultItems: ItemInter[] = [];
|
||||||
if (newHeroInfo.length > 0) {
|
if (newHeroInfo.length > 0) {
|
||||||
|
|
||||||
let { heroes, role, figureInfo, calHeroResults, calAllHeroResults, taskPushMessage } = await pubCreateHeroes(roleId, roleName, serverId, newHeroInfo, funcs);
|
let { heroes, role, figureInfo, calHeroResults, calAllHeroResults, taskPushMessage, activityTaskPushMessage } = await pubCreateHeroes(roleId, roleName, serverId, newHeroInfo, funcs);
|
||||||
|
|
||||||
let r = new Rank(REDIS_KEY.HERO_NUM_RANK, { serverId });
|
let r = new Rank(REDIS_KEY.HERO_NUM_RANK, { serverId });
|
||||||
await r.setRankWithRoleInfo(roleId, role.heroNum, role.heroNumUpdatedAt, role);
|
await r.setRankWithRoleInfo(roleId, role.heroNum, role.heroNumUpdatedAt, role);
|
||||||
@@ -348,6 +348,7 @@ export async function createHeroes(roleId: string, roleName: string, sid: string
|
|||||||
}
|
}
|
||||||
|
|
||||||
pushTaskUpdate(roleId, sid, null, taskPushMessage);
|
pushTaskUpdate(roleId, sid, null, taskPushMessage);
|
||||||
|
pushActivityUpdate(roleId, sid, null, activityTaskPushMessage);
|
||||||
resultHeroes = heroes;
|
resultHeroes = heroes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+116
-116
@@ -43,20 +43,20 @@ export default class GMUsers extends Service {
|
|||||||
* 根据类型等搜索玩家
|
* 根据类型等搜索玩家
|
||||||
*/
|
*/
|
||||||
public async getuserlist(field: string = 'all', value: string = '') {
|
public async getuserlist(field: string = 'all', value: string = '') {
|
||||||
const {ctx} = this;
|
const { ctx } = this;
|
||||||
|
|
||||||
let arr = new Array(), flag = 0;
|
let arr = new Array(), flag = 0;
|
||||||
if(value == '') field = 'all';
|
if (value == '') field = 'all';
|
||||||
let valueArr = value.split(',');
|
let valueArr = value.split(',');
|
||||||
for(let i of valueArr) {
|
for (let i of valueArr) {
|
||||||
if(field == 'uid') {
|
if (field == 'uid') {
|
||||||
let d = parseInt(i);
|
let d = parseInt(i);
|
||||||
if(isNaN(d)) {
|
if (isNaN(d)) {
|
||||||
flag = 1; break;
|
flag = 1; break;
|
||||||
} else {
|
} else {
|
||||||
arr.push(d);
|
arr.push(d);
|
||||||
}
|
}
|
||||||
} else if(field == 'username'||field == 'tel') {
|
} else if (field == 'username' || field == 'tel') {
|
||||||
arr.push(i);
|
arr.push(i);
|
||||||
} else if (field == 'all') {
|
} else if (field == 'all') {
|
||||||
break;
|
break;
|
||||||
@@ -65,29 +65,29 @@ export default class GMUsers extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flag) {
|
if (flag) {
|
||||||
return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
let users = await UserModel.findUserByField(field, valueArr);
|
let users = await UserModel.findUserByField(field, valueArr);
|
||||||
|
|
||||||
if(users) {
|
if (users) {
|
||||||
let list = new Array();
|
let list = new Array();
|
||||||
for(let user of users) {
|
for (let user of users) {
|
||||||
let role = await RoleModel.findAllByUid(user.uid);
|
let role = await RoleModel.findAllByUid(user.uid);
|
||||||
let sms = await smsModel.findByTel(user.tel);
|
let sms = await smsModel.findByTel(user.tel);
|
||||||
|
|
||||||
list.push({...user, role, isFixed: sms?sms.isFixed: false, code: sms?sms.code:""});
|
list.push({ ...user, role, isFixed: sms ? sms.isFixed : false, code: sms ? sms.code : "" });
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, {list})
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { list })
|
||||||
} else {
|
} else {
|
||||||
console.error('userlist not found');
|
console.error('userlist not found');
|
||||||
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
|
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createRole(uid:number, serverId: number, roleName: string) {
|
public async createRole(uid: number, serverId: number, roleName: string) {
|
||||||
console.log('enter Auth createRole');
|
console.log('enter Auth createRole');
|
||||||
const ctx = this.ctx;
|
const ctx = this.ctx;
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ export default class GMUsers extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async addAuth(uid:number, auth: number) {
|
public async addAuth(uid: number, auth: number) {
|
||||||
console.log('enter Auth addAuth');
|
console.log('enter Auth addAuth');
|
||||||
const ctx = this.ctx;
|
const ctx = this.ctx;
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ export default class GMUsers extends Service {
|
|||||||
console.log('enter Auth fix sms');
|
console.log('enter Auth fix sms');
|
||||||
const ctx = this.ctx;
|
const ctx = this.ctx;
|
||||||
const checkTel = this.checkTelNo(tel);
|
const checkTel = this.checkTelNo(tel);
|
||||||
if(checkTel.status == 1) {
|
if (checkTel.status == 1) {
|
||||||
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, checkTel.data);
|
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, checkTel.data);
|
||||||
}
|
}
|
||||||
const sms = await smsModel.fixSms(tel);
|
const sms = await smsModel.fixSms(tel);
|
||||||
@@ -178,21 +178,21 @@ export default class GMUsers extends Service {
|
|||||||
* 根据类型等搜索玩家
|
* 根据类型等搜索玩家
|
||||||
*/
|
*/
|
||||||
public async getrolelist(field: string = 'all', value: string = '') {
|
public async getrolelist(field: string = 'all', value: string = '') {
|
||||||
const {ctx} = this;
|
const { ctx } = this;
|
||||||
|
|
||||||
let arr = new Array(), flag = 0;
|
let arr = new Array(), flag = 0;
|
||||||
let valueArr = value.split(',');
|
let valueArr = value.split(',');
|
||||||
if(value == '') field = 'all';
|
if (value == '') field = 'all';
|
||||||
for(let i of valueArr) {
|
for (let i of valueArr) {
|
||||||
if(field == 'uid') {
|
if (field == 'uid') {
|
||||||
let d = parseInt(i);
|
let d = parseInt(i);
|
||||||
if(isNaN(d)) {
|
if (isNaN(d)) {
|
||||||
flag = 1; break;
|
flag = 1; break;
|
||||||
} else {
|
} else {
|
||||||
arr.push(d);
|
arr.push(d);
|
||||||
}
|
}
|
||||||
field = 'userInfo.uid';
|
field = 'userInfo.uid';
|
||||||
} else if(field == 'roleName') {
|
} else if (field == 'roleName') {
|
||||||
arr.push(i);
|
arr.push(i);
|
||||||
} else if (field == 'tel') {
|
} else if (field == 'tel') {
|
||||||
arr.push(i);
|
arr.push(i);
|
||||||
@@ -204,26 +204,26 @@ export default class GMUsers extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flag) {
|
if (flag) {
|
||||||
return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
let roles = await RoleModel.findRoleByField(field, valueArr);
|
let roles = await RoleModel.findRoleByField(field, valueArr);
|
||||||
|
|
||||||
if(roles) {
|
if (roles) {
|
||||||
|
|
||||||
let result = new Array();
|
let result = new Array();
|
||||||
for(let role of roles) {
|
for (let role of roles) {
|
||||||
let heroCount = await HeroModel.count({roleId: role.roleId}).lean();
|
let heroCount = await HeroModel.count({ roleId: role.roleId }).lean();
|
||||||
let equipCount = await EquipModel.count({roleId: role.roleId}).lean();
|
let equipCount = await EquipModel.count({ roleId: role.roleId }).lean();
|
||||||
let itemCount = await ItemModel.count({roleId: role.roleId}).lean();
|
let itemCount = await ItemModel.count({ roleId: role.roleId }).lean();
|
||||||
let defense = await PvpDefenseModel.findByRoleId(role.roleId);
|
let defense = await PvpDefenseModel.findByRoleId(role.roleId);
|
||||||
|
|
||||||
let {roleId, roleName, serverId, lv, vLv, gold, coin} = role;
|
let { roleId, roleName, serverId, lv, vLv, gold, coin } = role;
|
||||||
let {uid, tel} = role.userInfo;
|
let { uid, tel } = role.userInfo;
|
||||||
result.push({
|
result.push({
|
||||||
key: roleId, roleId, roleName, serverId, lv, vLv, uid, tel, heroCount, equipCount, itemCount, gold, coin,
|
key: roleId, roleId, roleName, serverId, lv, vLv, uid, tel, heroCount, equipCount, itemCount, gold, coin,
|
||||||
hasDefense: defense?'是':'否', defCe: defense?defense.defCe:0
|
hasDefense: defense ? '是' : '否', defCe: defense ? defense.defCe : 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { list: result });
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { list: result });
|
||||||
@@ -234,27 +234,27 @@ export default class GMUsers extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async createHero(uids: Array<string>, _hid: string, _hlv: string) {
|
public async createHero(uids: Array<string>, _hid: string, _hlv: string) {
|
||||||
const {ctx} = this;
|
const { ctx } = this;
|
||||||
console.log('gm createHero', uids, _hid, _hlv);
|
console.log('gm createHero', uids, _hid, _hlv);
|
||||||
let hlv = parseInt(_hlv);
|
let hlv = parseInt(_hlv);
|
||||||
if( isNaN(hlv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
if (isNaN(hlv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
let hids = (_hid as string).split('&').map(cur => parseInt(cur));
|
let hids = (_hid as string).split('&').map(cur => parseInt(cur));
|
||||||
for(let hid of hids) {
|
for (let hid of hids) {
|
||||||
if(isNaN(hid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
if (isNaN(hid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
let heroInfos = new Array();
|
let heroInfos = new Array();
|
||||||
for(let roleId of uids) {
|
for (let roleId of uids) {
|
||||||
let role = await RoleModel.findByRoleId(roleId);
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
if(role) {
|
if (role) {
|
||||||
for(let hid of hids) {
|
for (let hid of hids) {
|
||||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||||
if(hero) continue;
|
if (hero) continue;
|
||||||
let dicHero = gameData.hero.get(hid);
|
let dicHero = gameData.hero.get(hid);
|
||||||
if(!dicHero) continue;
|
if (!dicHero) continue;
|
||||||
const heroInfo = {
|
const heroInfo = {
|
||||||
roleId, roleName: role.roleName, hid, serverId: role.serverId,
|
roleId, roleName: role.roleName, hid, serverId: role.serverId,
|
||||||
lv: hlv, exp: getHeroExpByLv(hlv - 1)||0
|
lv: hlv, exp: getHeroExpByLv(hlv - 1) || 0
|
||||||
}
|
}
|
||||||
heroInfos.push(heroInfo);
|
heroInfos.push(heroInfo);
|
||||||
}
|
}
|
||||||
@@ -264,39 +264,39 @@ export default class GMUsers extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for(let heroInfo of heroInfos) {
|
for (let heroInfo of heroInfos) {
|
||||||
await pubCreateHero(heroInfo.roleId, heroInfo.roleName, heroInfo.serverId, heroInfo);
|
await pubCreateHero(heroInfo.roleId, heroInfo.roleName, heroInfo.serverId, heroInfo);
|
||||||
}
|
}
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
console.error(e.stack)
|
console.error(e.stack)
|
||||||
return ctx.service.utils.resResult(STATUS.GM_CREATE_ERROR, null, e.stack);
|
return ctx.service.utils.resResult(STATUS.GM_CREATE_ERROR, null, e.stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createEquip(uids: Array<string>, _eid: string, _ecount: string, _ehid: string) {
|
public async createEquip(uids: Array<string>, _eid: string, _ecount: string, _ehid: string) {
|
||||||
const {ctx} = this;
|
const { ctx } = this;
|
||||||
console.log('gm createEquip', uids, _eid, _ecount, _ehid);
|
console.log('gm createEquip', uids, _eid, _ecount, _ehid);
|
||||||
let eids = (_eid as string).split('&').map(cur => parseInt(cur));
|
let eids = (_eid as string).split('&').map(cur => parseInt(cur));
|
||||||
let ecount = parseInt(_ecount);
|
let ecount = parseInt(_ecount);
|
||||||
let ehid = parseInt(_ehid);
|
let ehid = parseInt(_ehid);
|
||||||
if( isNaN(ecount) || isNaN(ehid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
if (isNaN(ecount) || isNaN(ehid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
for(let eid of eids) {
|
for (let eid of eids) {
|
||||||
if(isNaN(eid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
if (isNaN(eid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
}
|
}
|
||||||
let flag = 0, msg = '创建失败';
|
let flag = 0, msg = '创建失败';
|
||||||
for(let roleId of uids) {
|
for (let roleId of uids) {
|
||||||
let role = await RoleModel.findByRoleId(roleId);
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
if(role) {
|
if (role) {
|
||||||
for(let eid of eids) {
|
for (let eid of eids) {
|
||||||
for(let i = 0; i <ecount; i++) {
|
for (let i = 0; i < ecount; i++) {
|
||||||
|
|
||||||
let dicEquip = gameData.goods.get(eid);
|
let dicEquip = gameData.goods.get(eid);
|
||||||
if(!dicEquip) {
|
if (!dicEquip) {
|
||||||
flag = 1, msg = "未找到装备" + eid;
|
flag = 1, msg = "未找到装备" + eid;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
await ctx.service.utils.addEquips(roleId, role.roleName, {id: eid, ...dicEquip, hid: ehid});
|
await ctx.service.utils.addEquips(roleId, role.roleName, { id: eid, ...dicEquip, hid: ehid });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -312,29 +312,29 @@ export default class GMUsers extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async createItem(uids: Array<string>, _itemid: string, _itemcount: string) {
|
public async createItem(uids: Array<string>, _itemid: string, _itemcount: string) {
|
||||||
const {ctx} = this;
|
const { ctx } = this;
|
||||||
console.log('gm createItem', uids, _itemid, _itemcount);
|
console.log('gm createItem', uids, _itemid, _itemcount);
|
||||||
let itemids = (_itemid as string).split('&').map(cur => parseInt(cur));
|
let itemids = (_itemid as string).split('&').map(cur => parseInt(cur));
|
||||||
for(let itemid of itemids) {
|
for (let itemid of itemids) {
|
||||||
if(isNaN(itemid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
if (isNaN(itemid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
}
|
}
|
||||||
let itemcount = parseInt(_itemcount);
|
let itemcount = parseInt(_itemcount);
|
||||||
if( isNaN(itemcount)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
if (isNaN(itemcount)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
|
|
||||||
let flag = 0, msg = '创建失败';
|
let flag = 0, msg = '创建失败';
|
||||||
for(let itemid of itemids) {
|
for (let itemid of itemids) {
|
||||||
let dicGoods = gameData.goods.get(itemid);
|
let dicGoods = gameData.goods.get(itemid);
|
||||||
let itidObj = ITID.get(dicGoods.itid);
|
let itidObj = ITID.get(dicGoods.itid);
|
||||||
|
|
||||||
if(!dicGoods) {
|
if (!dicGoods) {
|
||||||
flag = 1, msg = "未找到道具" + itemid;
|
flag = 1, msg = "未找到道具" + itemid;
|
||||||
} else if(!itidObj){
|
} else if (!itidObj) {
|
||||||
flag = 1, msg = "未找到道具" + itemid;
|
flag = 1, msg = "未找到道具" + itemid;
|
||||||
} else {
|
} else {
|
||||||
for(let roleId of uids) {
|
for (let roleId of uids) {
|
||||||
let role = await RoleModel.findByRoleId(roleId);
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
if(role) {
|
if (role) {
|
||||||
await ctx.service.utils.addBags(roleId, role.roleName, {id: itemid, itemName: dicGoods.name, count: itemcount, type: itidObj.type, hid: 0});
|
await ctx.service.utils.addBags(roleId, role.roleName, { id: itemid, itemName: dicGoods.name, count: itemcount, type: itidObj.type, hid: 0 });
|
||||||
} else {
|
} else {
|
||||||
flag = 1, msg = '未找到角色' + roleId;
|
flag = 1, msg = '未找到角色' + roleId;
|
||||||
}
|
}
|
||||||
@@ -350,11 +350,11 @@ export default class GMUsers extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async addGold(uids: Array<string>, _count: string) {
|
public async addGold(uids: Array<string>, _count: string) {
|
||||||
const {ctx} = this;
|
const { ctx } = this;
|
||||||
console.log('gm addGold', uids, _count);
|
console.log('gm addGold', uids, _count);
|
||||||
let count = parseInt(_count);
|
let count = parseInt(_count);
|
||||||
if(isNaN(count)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
if (isNaN(count)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
for(let roleId of uids) {
|
for (let roleId of uids) {
|
||||||
await RoleModel.addGoldFree(roleId, count);
|
await RoleModel.addGoldFree(roleId, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,22 +362,22 @@ export default class GMUsers extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async addCoin(uids: Array<string>, _count: string) {
|
public async addCoin(uids: Array<string>, _count: string) {
|
||||||
const {ctx} = this;
|
const { ctx } = this;
|
||||||
console.log('gm addCoin', uids, _count);
|
console.log('gm addCoin', uids, _count);
|
||||||
let count = parseInt(_count);
|
let count = parseInt(_count);
|
||||||
if(isNaN(count)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
if (isNaN(count)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
for(let roleId of uids) {
|
for (let roleId of uids) {
|
||||||
await RoleModel.addCoin(roleId, count);
|
await RoleModel.addCoin(roleId, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
|
||||||
}
|
}
|
||||||
public async addSkins(uids: Array<string>, _id: string) {
|
public async addSkins(uids: Array<string>, _id: string) {
|
||||||
const {ctx} = this;
|
const { ctx } = this;
|
||||||
console.log('gm addSkin', uids, _id);
|
console.log('gm addSkin', uids, _id);
|
||||||
let id = parseInt(_id);
|
let id = parseInt(_id);
|
||||||
if(isNaN(id)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
if (isNaN(id)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
for(let roleId of uids) {
|
for (let roleId of uids) {
|
||||||
await ctx.service.utils.addSkins(roleId, id);
|
await ctx.service.utils.addSkins(roleId, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,54 +385,54 @@ export default class GMUsers extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async levelUp(uids: Array<string>, _lv: string) {
|
public async levelUp(uids: Array<string>, _lv: string) {
|
||||||
const {ctx} = this;
|
const { ctx } = this;
|
||||||
console.log('gm levelUp', uids, _lv);
|
console.log('gm levelUp', uids, _lv);
|
||||||
let lv = parseInt(_lv);
|
let lv = parseInt(_lv);
|
||||||
if(isNaN(lv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
if (isNaN(lv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
for(let roleId of uids) {
|
for (let roleId of uids) {
|
||||||
let exp = getExpByLv(lv - 1);
|
let exp = getExpByLv(lv - 1);
|
||||||
await RoleModel.levelup(roleId, lv, exp?exp.sum:0);
|
await RoleModel.levelup(roleId, lv, exp ? exp.sum : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getPvpDefense(roleId: string) {
|
public async getPvpDefense(roleId: string) {
|
||||||
const {ctx} = this;
|
const { ctx } = this;
|
||||||
let result = await PvpDefenseModel.findByRoleId(roleId);
|
let result = await PvpDefenseModel.findByRoleId(roleId);
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||||
hasDefense: !!result, defense: result
|
hasDefense: !!result, defense: result
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// public async getHeroList(roleId: string) {
|
// public async getHeroList(roleId: string) {
|
||||||
// const {ctx} = this;
|
// const {ctx} = this;
|
||||||
// let herolist = await HeroModel.findByRole(roleId);
|
// let herolist = await HeroModel.findByRole(roleId);
|
||||||
// let defense = await PvpDefenseModel.findByRoleId(roleId);
|
// let defense = await PvpDefenseModel.findByRoleId(roleId);
|
||||||
|
|
||||||
// let result = Array<Hero>();
|
// let result = Array<Hero>();
|
||||||
// for(let hero of herolist) {
|
// for(let hero of herolist) {
|
||||||
// if(defense) {
|
// if(defense) {
|
||||||
// let {heroes = []} = defense;
|
// let {heroes = []} = defense;
|
||||||
// let curHero = heroes.find(cur => cur.actorId == hero.hid);
|
// let curHero = heroes.find(cur => cur.actorId == hero.hid);
|
||||||
// if(!curHero) {
|
// if(!curHero) {
|
||||||
// result.push(hero);
|
// result.push(hero);
|
||||||
// }
|
// }
|
||||||
// } else{
|
// } else{
|
||||||
// result.push(hero);
|
// result.push(hero);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
// return ctx.service.utils.resResult(STATUS.SUCCESS, {
|
||||||
// heroes: result
|
// heroes: result
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public async saveHeroToDefense(roleId: string, _roleName: string, hid: number) {
|
public async saveHeroToDefense(roleId: string, _roleName: string, hid: number) {
|
||||||
const {ctx} = this;
|
const { ctx } = this;
|
||||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||||
let role = await RoleModel.findByRoleId(roleId);
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
if(!hero || !role) {
|
if (!hero || !role) {
|
||||||
return ctx.service.utils.resResult(STATUS.GM_HERO_NOT_FOUND);
|
return ctx.service.utils.resResult(STATUS.GM_HERO_NOT_FOUND);
|
||||||
}
|
}
|
||||||
let { lv, ce, attr: heroAttrs } = hero;
|
let { lv, ce, attr: heroAttrs } = hero;
|
||||||
@@ -452,7 +452,7 @@ export default class GMUsers extends Service {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let defense = await PvpDefenseModel.findByRoleId(roleId);
|
let defense = await PvpDefenseModel.findByRoleId(roleId);
|
||||||
if(!defense) {
|
if (!defense) {
|
||||||
// defense = await PvpDefenseModel.createPvpDefense({roleId, roleName, heroes: [], defCe:ce});
|
// defense = await PvpDefenseModel.createPvpDefense({roleId, roleName, heroes: [], defCe:ce});
|
||||||
} else {
|
} else {
|
||||||
defense = await PvpDefenseModel.addHeroToDefense(roleId, heroInfo, ce);
|
defense = await PvpDefenseModel.addHeroToDefense(roleId, heroInfo, ce);
|
||||||
@@ -464,15 +464,15 @@ export default class GMUsers extends Service {
|
|||||||
|
|
||||||
|
|
||||||
public async removeHeroFromDefense(roleId: string, hid: number) {
|
public async removeHeroFromDefense(roleId: string, hid: number) {
|
||||||
const {ctx} = this;
|
const { ctx } = this;
|
||||||
|
|
||||||
let defense = await PvpDefenseModel.findByRoleId(roleId);
|
let defense = await PvpDefenseModel.findByRoleId(roleId);
|
||||||
if(!defense) {
|
if (!defense) {
|
||||||
return ctx.service.utils.resResult(STATUS.GM_PVP_DEFENSE_NOT_FOUND);
|
return ctx.service.utils.resResult(STATUS.GM_PVP_DEFENSE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
let {heroes} = defense;
|
let { heroes } = defense;
|
||||||
let curHero = heroes.find(cur => cur.actorId == hid);
|
let curHero = heroes.find(cur => cur.actorId == hid);
|
||||||
if(!curHero) {
|
if (!curHero) {
|
||||||
return ctx.service.utils.resResult(STATUS.GM_PVP_DEFENSE_HERO_NOT_FOUND);
|
return ctx.service.utils.resResult(STATUS.GM_PVP_DEFENSE_HERO_NOT_FOUND);
|
||||||
}
|
}
|
||||||
defense = await PvpDefenseModel.removeHeroFromDefense(roleId, hid, curHero.ce);
|
defense = await PvpDefenseModel.removeHeroFromDefense(roleId, hid, curHero.ce);
|
||||||
@@ -485,12 +485,12 @@ export default class GMUsers extends Service {
|
|||||||
/**
|
/**
|
||||||
* 根据类型等搜索玩家
|
* 根据类型等搜索玩家
|
||||||
*/
|
*/
|
||||||
public async getHeroList(field: string, value: (string|number)) {
|
public async getHeroList(field: string, value: (string | number)) {
|
||||||
const {ctx} = this;
|
const { ctx } = this;
|
||||||
|
|
||||||
let heroes = await HeroModel.findByField(field, value);
|
let heroes = await HeroModel.findByField(field, value);
|
||||||
|
|
||||||
if(heroes) {
|
if (heroes) {
|
||||||
|
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { list: heroes });
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { list: heroes });
|
||||||
} else {
|
} else {
|
||||||
@@ -532,7 +532,7 @@ export default class GMUsers extends Service {
|
|||||||
let seqId = parseInt(seqIdStr);
|
let seqId = parseInt(seqIdStr);
|
||||||
console.log(seqId);
|
console.log(seqId);
|
||||||
let equip = await EquipModel.findbySeqId(seqId);
|
let equip = await EquipModel.findbySeqId(seqId);
|
||||||
if(equip.hid > 0) {
|
if (equip.hid > 0) {
|
||||||
let hero = await HeroModel.findByHidAndRole(equip.hid, roleId);
|
let hero = await HeroModel.findByHidAndRole(equip.hid, roleId);
|
||||||
let index = hero.ePlace.findIndex(cur => cur.id == equip.ePlaceId);
|
let index = hero.ePlace.findIndex(cur => cur.id == equip.ePlaceId);
|
||||||
if (index < 0) continue;
|
if (index < 0) continue;
|
||||||
@@ -557,14 +557,14 @@ export default class GMUsers extends Service {
|
|||||||
|
|
||||||
let id = parseInt(idStr);
|
let id = parseInt(idStr);
|
||||||
let cur = map.get(roleId);
|
let cur = map.get(roleId);
|
||||||
if(!cur) {
|
if (!cur) {
|
||||||
cur = new Array<number>();
|
cur = new Array<number>();
|
||||||
map.set(roleId, cur);
|
map.set(roleId, cur);
|
||||||
}
|
}
|
||||||
cur.push(id);
|
cur.push(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(let [roleId, ids] of map) {
|
for (let [roleId, ids] of map) {
|
||||||
await ItemModel.deletebyRoleAndIds(roleId, ids);
|
await ItemModel.deletebyRoleAndIds(roleId, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,14 +582,14 @@ export default class GMUsers extends Service {
|
|||||||
|
|
||||||
let id = parseInt(idStr);
|
let id = parseInt(idStr);
|
||||||
let cur = map.get(roleId);
|
let cur = map.get(roleId);
|
||||||
if(!cur) {
|
if (!cur) {
|
||||||
cur = new Array<number>();
|
cur = new Array<number>();
|
||||||
map.set(roleId, cur);
|
map.set(roleId, cur);
|
||||||
}
|
}
|
||||||
cur.push(id);
|
cur.push(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(let [roleId, ids] of map) {
|
for (let [roleId, ids] of map) {
|
||||||
await ItemModel.updateCountByRoleAndIds(roleId, ids, count);
|
await ItemModel.updateCountByRoleAndIds(roleId, ids, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,22 +602,22 @@ export default class GMUsers extends Service {
|
|||||||
console.log('gm setHeroLv', roleIdAndHids, _hlv);
|
console.log('gm setHeroLv', roleIdAndHids, _hlv);
|
||||||
const ctx = this.ctx;
|
const ctx = this.ctx;
|
||||||
let hlv = parseInt(_hlv);
|
let hlv = parseInt(_hlv);
|
||||||
if( isNaN(hlv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
if (isNaN(hlv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
|
|
||||||
for(let roleIdAndHid of roleIdAndHids) {
|
for (let roleIdAndHid of roleIdAndHids) {
|
||||||
let [roleId, hidStr] = roleIdAndHid.split('|');
|
let [roleId, hidStr] = roleIdAndHid.split('|');
|
||||||
if(isNaN(parseInt(hidStr))) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
if (isNaN(parseInt(hidStr))) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||||
|
|
||||||
let hid = parseInt(hidStr);
|
let hid = parseInt(hidStr);
|
||||||
|
|
||||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||||
console.log(hid, roleId, !!hero);
|
console.log(hid, roleId, !!hero);
|
||||||
if(!hero) continue;
|
if (!hero) continue;
|
||||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.LVUP, roleId, hero, {lv: hlv});
|
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.LVUP, roleId, hero, { lv: hlv });
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
console.error(e.stack)
|
console.error(e.stack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,8 +231,8 @@ function unlockSingleFigure(dbFigures: Figure[], id: number, unlockDirect = fals
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function createHero(roleId: string, roleName: string, serverId: number, heroInfo: CreateHeroParam, funcs?: number[]) {
|
export async function createHero(roleId: string, roleName: string, serverId: number, heroInfo: CreateHeroParam, funcs?: number[]) {
|
||||||
let { role, figureInfo, heroes, calHeroResults, calAllHeroResults, taskPushMessage } = await createHeroes(roleId, roleName, serverId, [heroInfo], funcs)
|
let { role, figureInfo, heroes, calHeroResults, calAllHeroResults, taskPushMessage, activityTaskPushMessage } = await createHeroes(roleId, roleName, serverId, [heroInfo], funcs)
|
||||||
return { hero: heroes[0], role, figureInfo, calHeroResult: calHeroResults[0], calAllHeroResult: calAllHeroResults[0], taskPushMessage }
|
return { hero: heroes[0], role, figureInfo, calHeroResult: calHeroResults[0], calAllHeroResult: calAllHeroResults[0], taskPushMessage, activityTaskPushMessage }
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createHeroes(roleId: string, roleName: string, serverId: number, heroInfos: CreateHeroParam[], funcs?: number[]) {
|
export async function createHeroes(roleId: string, roleName: string, serverId: number, heroInfos: CreateHeroParam[], funcs?: number[]) {
|
||||||
@@ -268,9 +268,10 @@ export async function createHeroes(roleId: string, roleName: string, serverId: n
|
|||||||
let m4 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_LV, heroes, funcs);
|
let m4 = await checkTaskWithHeroes(roleId, TASK_TYPE.HERO_LV, heroes, funcs);
|
||||||
let taskPushMessage = m1.concat(m2, m3, m4);
|
let taskPushMessage = m1.concat(m2, m3, m4);
|
||||||
//成长任务
|
//成长任务
|
||||||
await accomplishTask(serverId, roleId, TASK_TYPE.HERO_NUM, heroNum)
|
let mm1 = await accomplishTask(serverId, roleId, TASK_TYPE.HERO_NUM, heroNum)
|
||||||
await accomplishTask(serverId, roleId, TASK_TYPE.HERO_QUALITY, heroNum, { heroes })
|
let mm2 = await accomplishTask(serverId, roleId, TASK_TYPE.HERO_QUALITY, heroNum, { heroes })
|
||||||
return { role, figureInfo, heroes, calHeroResults, calAllHeroResults, taskPushMessage }
|
let activityTaskPushMessage = mm1.concat(mm2);
|
||||||
|
return { role, figureInfo, heroes, calHeroResults, calAllHeroResults, taskPushMessage, activityTaskPushMessage }
|
||||||
}
|
}
|
||||||
|
|
||||||
export function transPiece(hid: number) {
|
export function transPiece(hid: number) {
|
||||||
|
|||||||
Reference in New Issue
Block a user