✨ feat(后台): 后台玩家查询、排行榜统计
This commit is contained in:
@@ -38,6 +38,12 @@ export default class UserController extends Controller {
|
|||||||
ctx.body = await ctx.service.users.getrolelist(page, pageSize, sortField, sortOrder, form);
|
ctx.body = await ctx.service.users.getrolelist(page, pageSize, sortField, sortOrder, form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getpaystatic() {
|
||||||
|
const { ctx } = this;
|
||||||
|
const { page = 1, pageSize = 10, form } = ctx.request.body;
|
||||||
|
ctx.body = await ctx.service.users.getpaystatic(page, pageSize, form);
|
||||||
|
}
|
||||||
|
|
||||||
public async setWar() {
|
public async setWar() {
|
||||||
const { ctx } = this;
|
const { ctx } = this;
|
||||||
const { roleId, warId } = ctx.request.body;
|
const { roleId, warId } = ctx.request.body;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export default (app: Application) => {
|
|||||||
router.post('/api/users/getuserlist', tokenParser,controller.users.getuserlist);
|
router.post('/api/users/getuserlist', tokenParser,controller.users.getuserlist);
|
||||||
router.post('/api/users/fixsms', tokenParser, controller.users.fixSms);
|
router.post('/api/users/fixsms', tokenParser, controller.users.fixSms);
|
||||||
router.post('/api/users/getrolelist', tokenParser,controller.users.getrolelist);
|
router.post('/api/users/getrolelist', tokenParser,controller.users.getrolelist);
|
||||||
|
router.post('/api/users/getpaystatic', controller.users.getpaystatic);
|
||||||
router.post('/api/users/deleterole', tokenParser,controller.users.deleteRole);
|
router.post('/api/users/deleterole', tokenParser,controller.users.deleteRole);
|
||||||
router.post('/api/users/setwar', tokenParser, controller.users.setWar);
|
router.post('/api/users/setwar', tokenParser, controller.users.setWar);
|
||||||
router.post('/api/users/setcreatetime', tokenParser, controller.users.setCreateTime);
|
router.post('/api/users/setcreatetime', tokenParser, controller.users.setCreateTime);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import GiftCodeDetail, { GiftCodeDetailModel } from '@db/GiftCodeDetail';
|
|||||||
import { deletRole } from '@pubUtils/roleUtil';
|
import { deletRole } from '@pubUtils/roleUtil';
|
||||||
import { RScriptRecordModel } from '@db/RScriptRecord';
|
import { RScriptRecordModel } from '@db/RScriptRecord';
|
||||||
import { DicWar } from '@pubUtils/dictionary/DicWar';
|
import { DicWar } from '@pubUtils/dictionary/DicWar';
|
||||||
import { SearchHeroParam, SearchUserParam, SearchGiftCodeParam, SearchGiftCodeDetailParam, SearchItemParam, SearchGuildParam } from '@domain/backEndField/search';
|
import { SearchHeroParam, SearchUserParam, SearchGiftCodeParam, SearchGiftCodeDetailParam, SearchItemParam, SearchGuildParam, SearchRoleParam } from '@domain/backEndField/search';
|
||||||
import { CreateGiftCode, UpdateGiftCode } from '@domain/backEndField/params';
|
import { CreateGiftCode, UpdateGiftCode } from '@domain/backEndField/params';
|
||||||
import { isNumber } from 'util';
|
import { isNumber } from 'util';
|
||||||
import { GuildModel } from '@db/Guild';
|
import { GuildModel } from '@db/Guild';
|
||||||
@@ -23,6 +23,7 @@ import { TowerRecordModel } from '@db/TowerRecord';
|
|||||||
import { nowSeconds } from '@pubUtils/timeUtil';
|
import { nowSeconds } from '@pubUtils/timeUtil';
|
||||||
import { RoleCeModel, RoleCeType } from '@db/RoleCe';
|
import { RoleCeModel, RoleCeType } from '@db/RoleCe';
|
||||||
import { HangUpRecordModel } from '@db/HangUpRecord';
|
import { HangUpRecordModel } from '@db/HangUpRecord';
|
||||||
|
import { UserOrderModel } from '@db/UserOrder';
|
||||||
const Excel = require('exceljs');
|
const Excel = require('exceljs');
|
||||||
|
|
||||||
// import { resResult } from '@pubUtils/util';
|
// import { resResult } from '@pubUtils/util';
|
||||||
@@ -121,9 +122,17 @@ export default class GMUsers extends Service {
|
|||||||
/**
|
/**
|
||||||
* 根据类型等搜索玩家
|
* 根据类型等搜索玩家
|
||||||
*/
|
*/
|
||||||
public async getrolelist(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchUserParam) {
|
public async getrolelist(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchRoleParam) {
|
||||||
const { ctx } = this;
|
const { ctx } = this;
|
||||||
|
|
||||||
|
if(!!form.channelId) {
|
||||||
|
let user = await UserModel.findUserByChannelRegex(form.channelId);
|
||||||
|
if(!user) {
|
||||||
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { list: [], total: 0 });
|
||||||
|
}
|
||||||
|
form.uid = user.uid;
|
||||||
|
}
|
||||||
|
|
||||||
const roles = await RoleModel.findByCondition(page, pageSize, sortField, sortOrder, form);
|
const roles = await RoleModel.findByCondition(page, pageSize, sortField, sortOrder, form);
|
||||||
const total = await RoleModel.countByCondition( form )
|
const total = await RoleModel.countByCondition( form )
|
||||||
|
|
||||||
@@ -132,10 +141,12 @@ export default class GMUsers extends Service {
|
|||||||
let heroCount = await HeroModel.count({ roleId: role.roleId }).lean();
|
let heroCount = await HeroModel.count({ roleId: role.roleId }).lean();
|
||||||
let itemCount = await ItemModel.count({ roleId: role.roleId }).lean();
|
let itemCount = await ItemModel.count({ roleId: role.roleId }).lean();
|
||||||
|
|
||||||
let { roleId, roleName, serverId, lv, gold, coin, ce, blockType = 0, blockReason = '', fixedIpLocation, ipLocation } = role;
|
let { roleId, roleName, serverId, lv, gold, coin, ce, blockType = 0, blockReason = '', fixedIpLocation, ip, ipLocation, totalPay } = role;
|
||||||
let { uid, tel } = role.userInfo;
|
let { uid, tel } = role.userInfo;
|
||||||
|
let user = await UserModel.findUserByUid(role.userInfo.uid);
|
||||||
|
|
||||||
list.push({
|
list.push({
|
||||||
key: roleId, roleId, roleName, serverId, lv, uid, tel, heroCount, itemCount, gold, coin, ce, blockType, blockReason, fixedIpLocation, ipLocation,
|
key: roleId, roleId, roleName, serverId, lv, uid, tel, heroCount, itemCount, gold, coin, ce, blockType, blockReason, fixedIpLocation, ip, ipLocation, channelId: user?.channelId, totalPay, channelType: user?.channelType,
|
||||||
env: ctx.app.config.realEnv
|
env: ctx.app.config.realEnv
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -143,6 +154,30 @@ export default class GMUsers extends Service {
|
|||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { list, total })
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { list, total })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getpaystatic(page: number, pageSize: number, form: { beginTime: number, endTime: number, serverId: number }) {
|
||||||
|
const { ctx } = this;
|
||||||
|
let match = {};
|
||||||
|
if(form.beginTime && form.endTime) {
|
||||||
|
match['beginTime'] = { $gt: new Date(form.beginTime) };
|
||||||
|
match['endTime'] = { $lt: new Date(form.endTime) };
|
||||||
|
}
|
||||||
|
if(form.serverId) {
|
||||||
|
match['serverId'] = form.serverId;
|
||||||
|
}
|
||||||
|
console.log(match)
|
||||||
|
let list = await UserOrderModel.aggregate([
|
||||||
|
{ $match: match },
|
||||||
|
{ $group: { '_id': '$roleId', sum: { '$sum': '$price' }, count: { '$sum': 1 }, max: { $max:'$price'}, lastTime: { $max: '$updatedAt' } } },
|
||||||
|
{ $lookup: { from: 'roles', localField: '_id', foreignField: 'roleId', as: 'role' } },
|
||||||
|
{ $unwind: '$role' },
|
||||||
|
{ $project: { _id: 0, roleId: '$_id', roleName: '$role.roleName', guildName: '$role.guildName', serverId: '$role.serverId', lv: '$role.lv', sum: 1, count: 1, max: 1, lastTime: {$dateToString: {format: '%Y-%m-%d %H:%M:%S', date:{$add:['$lastTime',28800000]}}}, env: ctx.app.config.realEnv } },
|
||||||
|
{ $sort: { 'sum': -1 } },
|
||||||
|
{ $limit: pageSize },
|
||||||
|
{ $skip: (page - 1) * pageSize },
|
||||||
|
])
|
||||||
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { list })
|
||||||
|
}
|
||||||
|
|
||||||
// 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);
|
||||||
|
|||||||
1
gm-server/typings/config/plugin.d.ts
vendored
1
gm-server/typings/config/plugin.d.ts
vendored
@@ -31,5 +31,6 @@ declare module 'egg' {
|
|||||||
jsonp?: EggPluginItem;
|
jsonp?: EggPluginItem;
|
||||||
view?: EggPluginItem;
|
view?: EggPluginItem;
|
||||||
cors?: EggPluginItem;
|
cors?: EggPluginItem;
|
||||||
|
xtransit?: EggPluginItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,6 +249,11 @@ export default class User extends BaseModel {
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async findUserByChannelRegex(channelId: string) {
|
||||||
|
const user: UserType = await UserModel.findOne({ channelId: { $regex: new RegExp(channelId.toString(), 'i') } }).select('uid token serverType auth tel userCode pkgName ip deviceId').lean({ getters: true });
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
public static async findTokenByTel(tel: string) {
|
public static async findTokenByTel(tel: string) {
|
||||||
const user: UserType = await UserModel.findOne({ tel }).lean();
|
const user: UserType = await UserModel.findOne({ tel }).lean();
|
||||||
return user ? user.token : null;
|
return user ? user.token : null;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export interface SearchRoleParam {
|
|||||||
roleId?: string; // 角色id
|
roleId?: string; // 角色id
|
||||||
roleName?: string; // 昵称
|
roleName?: string; // 昵称
|
||||||
tel?: string;
|
tel?: string;
|
||||||
|
channelId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SearchHeroParam {
|
export interface SearchHeroParam {
|
||||||
|
|||||||
Reference in New Issue
Block a user