后台:自动开服

This commit is contained in:
luying
2021-12-08 16:23:00 +08:00
parent 02c2096704
commit fc38485f94
8 changed files with 102 additions and 97 deletions

View File

@@ -8,13 +8,14 @@ import { Service } from 'egg';
import Counter from '@db/Counter';
import { getExpByLv } from '../pubUtils/data';
import { isString } from 'underscore';
import { getAge } from '../pubUtils/timeUtil';
import { getAge, nowSeconds } from '../pubUtils/timeUtil';
import { resResult } from '../pubUtils/util';
import { checkTeeanAgerTime } from '../pubUtils/authenticateUtil';
// import { authenticate } from '../pubUtils/httpUtil';
import { checkTask } from 'app/pubUtils/taskUtil';
import { getChannelId, loginValidata } from '../pubUtils/sdkUtil';
import { LoginValidateData37 } from 'app/domain/sdk';
import { ServerlistModel } from '@db/Serverlist';
/**
* Test Service
@@ -308,12 +309,17 @@ export default class Auth extends Service {
if (exist === true) {
return ctx.service.utils.resResult(STATUS.ROLE_EXIST);
}
const server = await ServerlistModel.findByServerId(serverId);
if(!server) return ctx.service.utils.resResult(STATUS.SERVER_NOT_FOUND);
if(nowSeconds() > server.stopRegisterTime) return ctx.service.utils.resResult(STATUS.SERVER_STOP_REGISTER);
const roleId = ctx.service.utils.genCode(10);
const code = ctx.service.utils.genCode(6);
const seqId = await Counter.getNewCounter(COUNTER.ROLE) || -1;
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName: "", seqId, lv: DEFAULT_LV, exp: (getExpByLv(DEFAULT_LV - 1) || { sum: 0 }).sum || 0 });
if (role) {
await ServerlistModel.incRoleCnt(serverId);
// 任务
await checkTask(roleId, TASK_TYPE.ROLE_LV, role.lv, false, {});