军团:添加管理debug接口
This commit is contained in:
@@ -9,9 +9,6 @@ import { SystemConfigModel } from "../db/SystemConfig";
|
||||
import { nowSeconds } from "../pubUtils/timeUtil";
|
||||
import { pinus } from "pinus";
|
||||
import { GuildRecType } from "../db/GuildRec";
|
||||
import { MailModel } from "../db/Mail";
|
||||
import { RewardInter } from "../pubUtils/interface";
|
||||
import { getRedis } from "./redisService";
|
||||
import { ARMY } from "../pubUtils/dicParam";
|
||||
import { sendMail } from "./mailService";
|
||||
|
||||
@@ -95,24 +92,28 @@ export async function getGuildWithRefActive(guildCode: string, serverId: number)
|
||||
* @param serverId 区
|
||||
* @param active 增加的活跃
|
||||
*/
|
||||
export async function addGuildActive(guildCode: string, serverId: number, active: number) {
|
||||
|
||||
// TODO 加写锁
|
||||
let guild = await GuildModel.findByCode(guildCode, serverId, '+refTimeDaily');
|
||||
export async function addActive(roleId: string, serverId: number, id: number, active: number) {
|
||||
|
||||
let userGuild = await getUserGuildWithRefActive(roleId, 'activeRecord receivedActive activeDaily activeWeekly guildCode');
|
||||
if(!userGuild) return false;
|
||||
|
||||
let guildCode = userGuild.guildCode;
|
||||
let guild = await getGuildWithRefActive(guildCode, serverId);
|
||||
if(!guild) return false;
|
||||
|
||||
const now = new Date();
|
||||
let { activeDaily, activeWeekly, refTimeDaily} = guild;
|
||||
|
||||
let isRefDaily = shouldRefresh(refTimeDaily, now, 0);
|
||||
if(isRefDaily) {
|
||||
activeDaily = 0; refTimeDaily = now;
|
||||
let {activeRecord} = userGuild;
|
||||
if(id != 0) { // 用于debug,传0时直接增加活跃
|
||||
let curActiveRecord = activeRecord.find(cur => cur.id == id);
|
||||
if( curActiveRecord ) {
|
||||
curActiveRecord.count ++;
|
||||
} else {
|
||||
activeRecord.push({id, count: 1});
|
||||
}
|
||||
}
|
||||
userGuild = await UserGuildModel.updateInfo(roleId, { activeRecord }, { activeDaily: active, activeWeekly: active });
|
||||
|
||||
activeWeekly += active; activeDaily += active;
|
||||
|
||||
guild = await GuildModel.updateInfo(guildCode, { activeDaily, activeWeekly, refTimeDaily }, {});
|
||||
return guild;
|
||||
guild = await GuildModel.updateInfo(guildCode, { }, { activeDaily: active, activeWeekly: active });
|
||||
return { guild, userGuild };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +131,7 @@ export async function getUserGuildWithRefActive(roleId: string, select: string)
|
||||
if(isRefDaily) {
|
||||
receivedActive = 0; refTimeDaily = now; activeDaily = 0; activeRecord = [];
|
||||
|
||||
userGuild = await UserGuildModel.updateInfo(roleId, { receivedActive, refTimeDaily, activeDaily, activeRecord }, select);
|
||||
userGuild = await UserGuildModel.updateInfo(roleId, { receivedActive, refTimeDaily, activeDaily, activeRecord }, {}, select);
|
||||
if(!userGuild) return false;
|
||||
}
|
||||
|
||||
@@ -157,14 +158,14 @@ export async function settleGuildWeekly() {
|
||||
let active = false;
|
||||
let job = 0;
|
||||
|
||||
if(activeWeekly > 100) {
|
||||
if(activeWeekly > ARMY.ARMY_WEEKHONOUR_LIMIT) {
|
||||
activeMemberCnt ++;
|
||||
active = true;
|
||||
}
|
||||
|
||||
if(auth == GUILD_AUTH.LEADER) {
|
||||
job = GUILD_JOB.DAJIANGJUN;
|
||||
} else if (activeWeekly <= 100) {
|
||||
} else if (activeWeekly <= ARMY.ARMY_WEEKHONOUR_LIMIT) {
|
||||
job = GUILD_JOB.SHIBING;
|
||||
} else {
|
||||
otherMemberNum++;
|
||||
|
||||
Reference in New Issue
Block a user