Merge branch 'statusCode' of gitlab.trgame.cn:zyztech/zyz_server

Conflicts:
	game-server/app/servers/battle/handler/eventBattleHandler.ts
This commit is contained in:
luying
2020-10-17 10:18:52 +08:00
17 changed files with 232 additions and 298 deletions

View File

@@ -3,6 +3,9 @@ import BaseModel from './BaseModel';
import { index, getModelForClass, prop } from '@typegoose/typegoose';
class ServerInfo {
@prop({ required: true })
id: number;
@prop({ required: true })
name: string;
@@ -55,7 +58,7 @@ export default class Game extends BaseModel {
public static async getServerListByType(serverType: string) {
let game = await GameModel.findOne().lean();
if (!game) {
const serverInfo: ServerInfo = { name: '常山少年', host: 'pinus_test.trgame.cn', port: 3014, status: 1, createTime: new Date(), serverType: 'official' };
const serverInfo: ServerInfo = { id: 1, name: '常山少年', host: 'pinus_test.trgame.cn', port: 3014, status: 1, createTime: new Date(), serverType: 'official' };
const iconUrl = `https://download.tgamebox.cn/avatar/${APP_ID}/1.png`;
game = await GameModel.findOneAndUpdate(
{},

View File

@@ -48,14 +48,15 @@ export default class Sms extends BaseModel {
}
public async cntLimit(cnt: number) {
console.log('hasSendToday:', this.hasSendToday());
if (await this.hasSendToday() && this.countToday >= cnt) {
console.log('hasSendToday:', this.hasSendToday(), this.countToday, cnt);
if (this.hasSendToday() && this.countToday >= cnt) {
return true;
}
this.countToday = 0;
return false;
}
public async hasSendToday() {
public hasSendToday() {
console.log(moment(this.updateTime).format('YYYY-MM-DD'), moment(Date.now()).format('YYYY-MM-DD'));
return moment(this.updateTime).format('YYYY-MM-DD') === moment(Date.now()).format('YYYY-MM-DD');
}

View File

@@ -2,6 +2,7 @@ import { COUNTER } from './../consts/consts';
import { CounterModel } from './Counter';
import BaseModel from './BaseModel';
import { index, getModelForClass, prop } from '@typegoose/typegoose';
import { genCode } from '../pubUtils/util';
/**
* 用户字段接口
@@ -16,6 +17,9 @@ export default class User extends BaseModel {
@prop({ required: true })
username: string;
@prop({ required: true })
userCode: string; // 用户唯一字符串标识
@prop({ required: true })
token: string;
@@ -65,8 +69,9 @@ export default class User extends BaseModel {
let update = {};
if (!user) {
const uid = await CounterModel.getNewCounter(COUNTER.UID);
const userCode = genCode(8);
const doc = new UserModel();
update = Object.assign(update, { platform, pkgName, serverType, createTime: curTime, uid, username: `用户${uid}` }, doc.toJSON());
update = Object.assign(update, { platform, pkgName, serverType, createTime: curTime, uid, userCode, username: `用户${uid}` }, doc.toJSON());
}
update = Object.assign(update, { token, lastLoginTime: curTime });
user = await UserModel.findOneAndUpdate({ tel }, update, { upsert: true, new: true }).lean(lean);