军团:添加补发捐献宝箱
This commit is contained in:
@@ -6,7 +6,7 @@ import { RoleModel, RoleType } from "../db/Role";
|
||||
import { UserGuildModel, UserGuildType, WishGood } from "../db/UserGuild";
|
||||
import { UserGuildApplyModel } from "../db/UserGuildApply";
|
||||
import { PVPConfigModel } from "../db/SystemConfig";
|
||||
import { getZeroPointD, getZeroPointOfTimeD, nowSeconds } from "../pubUtils/timeUtil";
|
||||
import { getZeroPointD, getZeroPointOfTime, getZeroPointOfTimeD, nowSeconds } from "../pubUtils/timeUtil";
|
||||
import { pinus, BackendSession, FrontendOrBackendSession } from "pinus";
|
||||
import { ARMY } from "../pubUtils/dicParam";
|
||||
import { sendMailByContent } from "./mailService";
|
||||
@@ -25,6 +25,7 @@ import { sendMessageToGuildWithSuc, sendMessageToUserWithSuc } from "./pushServi
|
||||
import { delGuildChannel, leaveGuildChannel } from "./chatChannelService";
|
||||
import { GuildActiveModel, } from "../db/GuildActive";
|
||||
import { RewardInter } from "../pubUtils/interface";
|
||||
import { getGuildFundByRefTime } from "./donateService";
|
||||
|
||||
export async function getMyGuildInfo(roleId: string, sid: string, userGuild: UserGuildType, guild: GuildType, serverId: number, session: FrontendOrBackendSession) {
|
||||
|
||||
@@ -216,15 +217,16 @@ export async function getUserGuildWithRefActive(roleId: string, select?: string)
|
||||
|
||||
export async function refreshUserGuild(userGuild: UserGuildType, roleId: string) {
|
||||
if(!userGuild) return false;
|
||||
let { receivedActive, refTimeDaily, activeDaily, activeRecord, wishGoods, receivedWishPool } = userGuild;
|
||||
let { receivedActive, refTimeDaily, activeDaily, activeRecord, wishGoods, receivedWishPool, receiveBoxs } = userGuild;
|
||||
|
||||
const now = new Date();
|
||||
let isRefDaily = shouldRefresh(refTimeDaily, now);
|
||||
if (isRefDaily) {
|
||||
await sendUnreceivedWishPool(wishGoods, roleId);
|
||||
await sendUnreceivedActiveBox(roleId, userGuild.guildCode, refTimeDaily, receivedActive);
|
||||
receivedActive = []; refTimeDaily = now; activeDaily = 0; activeRecord = []; wishGoods = []; receivedWishPool = [];
|
||||
let receiveBoxs = [], wishDntCnt = 0, donateCnt = 0;
|
||||
await sendUnreceivedDonateBox(roleId, userGuild.guildCode, refTimeDaily, receiveBoxs);
|
||||
receivedActive = []; refTimeDaily = now; activeDaily = 0; activeRecord = []; wishGoods = []; receivedWishPool = [], receiveBoxs = [];
|
||||
let wishDntCnt = 0, donateCnt = 0;
|
||||
userGuild = await UserGuildModel.updateInfo(roleId, { receivedActive, refTimeDaily, activeDaily, activeRecord, wishGoods, receiveBoxs, wishDntCnt, donateCnt, receivedWishPool }, {});
|
||||
if (!userGuild) return false;
|
||||
}
|
||||
@@ -252,7 +254,6 @@ async function sendUnreceivedActiveBox(roleId: string, guildCode: string, refTim
|
||||
let guildActive = await getGuildActiveByRefTime(guildCode, refTime);
|
||||
let goods: RewardInter[] = [];
|
||||
for(let [id, { activeDayPoint, reward }] of gameData.guildActiveDayReward) {
|
||||
console.log('####', guildActive, activeDayPoint, receiveActiveBox)
|
||||
if(guildActive >= activeDayPoint && receiveActiveBox.indexOf(id) == -1) goods.push(...reward);
|
||||
}
|
||||
if(goods.length > 0) {
|
||||
@@ -260,6 +261,20 @@ async function sendUnreceivedActiveBox(roleId: string, guildCode: string, refTim
|
||||
}
|
||||
}
|
||||
|
||||
async function sendUnreceivedDonateBox(roleId: string, guildCode: string, refTimeDaily: Date, receiveBoxs: number[]) {
|
||||
let refTime = getZeroPointOfTime(refTimeDaily);
|
||||
let { fund: guildFund, donationLv } = await getGuildFundByRefTime(guildCode, refTime);
|
||||
let goods: RewardInter[] = [];
|
||||
for(let [id, { boxRewards, fund, level }] of gameData.armyDonateBox) {
|
||||
if(level == donationLv && guildFund >= fund && receiveBoxs.indexOf(id) == -1) {
|
||||
if(boxRewards) goods.push(...boxRewards);
|
||||
}
|
||||
}
|
||||
if(goods.length > 0) {
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_FUND_BOX, roleId, { goods });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 每周结算上周公会周功勋和 活跃并发奖励(未完)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user