feat:黄旗酒馆

This commit is contained in:
xichaoyin 2024-01-10 14:29:17 +08:00
parent c2ce055c73
commit 14796bb06b
4 changed files with 75 additions and 44 deletions

View File

@ -19,7 +19,7 @@ export default async function (call: ApiCall<ReqZhaoMu, ResZhaoMu>) {
let prize = [];
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
for (let n = 0; n < call.req.num; n++) {
for (let n = 1; n <= call.req.num; n++) {
let num = mydata.zhaomu.num + n;
let baodi = hd.data.baodi.filter(x => x.num == num);
if (baodi.length > 0) {

View File

@ -214,10 +214,13 @@ export default class HQJGFun {
/**
*
*/
static async dayDpsLvPrize() {
static async dayDpsLvPrize(time: number) {
console.log(
"黄旗酒馆 每日伤害等级奖励结算 开始执行。。。"
)
// 取stime小于当前时间的最后一条数据
let hdinfo = await G.mongodb.collection("hdinfo").find({
htype: this.htype, stime: { $lte: G.time }
htype: this.htype, stime: { $lte: time }
}, { sort: { stime: -1 } }).limit(1).toArray();
// 没有活动数
@ -227,6 +230,7 @@ export default class HQJGFun {
let hd = hdinfo[0];
let hdid = hdinfo[0].hdid;
// 活动结束
if (hd.etime < G.time - 300) {
return
}
@ -260,17 +264,26 @@ export default class HQJGFun {
contentInsertArr: [lvprize.lv],
})
}
console.log(
"黄旗酒馆 每日伤害等级奖励结算 执行完成!!!"
)
})
}
/**
*
*/
static async endDpsRankPrize() {
// 取stime小于当前时间的最后一条数据
static async endDpsRankPrize(time: number) {
console.log(
"黄旗酒馆 最大伤害排行奖励结算 开始执行。。。"
)
let today = PublicShared.getToDayZeroTime(time + 300);
let yesterday = PublicShared.getToDayZeroTime(time - 300);
// 查询昨天23:59:00或者今天00:00:00结束的活动
let hdinfo = await G.mongodb.collection("hdinfo").find({
htype: this.htype, stime: { $lte: G.time }
}, { sort: { stime: -1 } }).limit(1).toArray();
htype: this.htype, rtime: { $gt: yesterday, $lte: today }
}).toArray();
// 没有活动数
if (hdinfo.length <= 0) {
@ -279,7 +292,7 @@ export default class HQJGFun {
let hd = hdinfo[0];
let hdid = hdinfo[0].hdid;
if (hd.etime < G.time - 300) {
if (hd.data.sendrank) {
return
}
@ -306,5 +319,16 @@ export default class HQJGFun {
contentInsertArr: [rank],
})
}
// 标记已发送
await G.mongodb.collection("hdinfo").updateOne(
{ hdid: hdid }, { $set: { "data.sendrank": true } }
);
console.log(
"黄旗酒馆 最大伤害排行奖励结算 执行结束!!!"
)
}
}
G.on("NEW_DAY", HQJGFun.dayDpsLvPrize.bind(HQJGFun));
G.on("NEW_DAY", HQJGFun.endDpsRankPrize.bind(HQJGFun));

View File

@ -15,13 +15,14 @@ import { ZhanLingTasks } from './public/zhanling';
import { player } from './shared/protocols/user/type';
import { PublicShared } from './shared/public/public';
import { setGud } from './public/gud';
import {checkResetBuyLog} from "./api_s2c/event/zhoumolibao/ApiOpen";
import {Christmasfun} from "./api_s2c/event/christmas/fun";
import {PushGiftFun} from "./public/pushgift";
import {LeiChongLiBaoBuyGift} from "./api_s2c/event/leichonglibao/ApiReceive";
import { checkResetBuyLog } from "./api_s2c/event/zhoumolibao/ApiOpen";
import { PushGiftFun } from "./public/pushgift";
import { LeiChongLiBaoBuyGift } from "./api_s2c/event/leichonglibao/ApiReceive";
import { HongDianChange } from './api_s2c/hongdian/fun';
export type gEventType = {
/**新的一天 */
NEW_DAY: (time: number) => void;
/**玩家断开连接 */
PLAYER_DISCONNECT: (uid: string) => void;
/**玩家修改名字 */
@ -165,7 +166,7 @@ export function addListener() {
XstaskFun.uidTask[uid] = null;
delete XstaskFun.uidTask[uid];
}
setGud(uid,{ logoutTime: G.time });
setGud(uid, { logoutTime: G.time });
G.mongodb.collection('user').updateOne({ uid: uid }, { $set: { logoutTime: G.time } });
});
@ -177,7 +178,7 @@ export function addListener() {
}
});
G.on('PLAYER_PAY', async (player, payId, payArgs,call) => {
G.on('PLAYER_PAY', async (player, payId, payArgs, call) => {
let conf: any = await PayFun.getConf(payId, payArgs);
ActionLog.addDayLog(player.uid, { key: 'pay', val: conf.payExp[0].n });
ActionLog.addRetainLog(player.uid, { key: 'pay', val: conf.payExp[0].n });

View File

@ -4,6 +4,7 @@ import { Wjjl } from "../../module/collection_wjjl";
import { ZhanLingTasks } from "../zhanling";
import { setGud } from '../gud';
import { EmailFun } from '../email';
import { clusterRunOnce } from '../../clusterUtils';
export class SchedulerNewDayLocalCtor extends Scheduler {
@ -23,6 +24,41 @@ export class SchedulerNewDayLocalCtor extends Scheduler {
}
async start() {
clusterRunOnce(async () => {
//这个定时器会被每个进程都启动这是这部分逻辑应该只执行1次
// 每周一,发放终身卡
(async () => {
if (PublicShared.getWeek(G.time) == 1) {
let logs = await G.mongodb.collection("payLogNew").find(
{ key: "zhongshenka", del_time: { $exists: false } }, { projection: { _id: 0, } }
).toArray();
if (logs.length == 0) {
console.log("没有终身卡数据,不发放终身卡");
}
let con = G.gc.payEmail.zhongshenka.filter(e => e.day == 7)[0];
for (let i = 0; i < logs.length; i++) {
console.log("发放终身卡", logs[i].uid);
// 发送邮件
EmailFun.addEmail({
uid: logs[i].uid,
type: "system",
title: con.title,
content: con.content,
contentInsertArr: [],
createTime: G.time,
prize: con.prize,
})
}
}
})()
// 转点刷新事件
G.emit('NEW_DAY', G.time);
})
let users = Object.values(G.server.uid_connections)
if (users.length) {
for (let item of users) {
@ -55,35 +91,5 @@ export class SchedulerNewDayLocalCtor extends Scheduler {
}
G.server.broadcastClusterMsg('msg_s2c/NewDay', { time: this.zeroTime });
}
(async () => {
// 每周一,发放终身卡
if (PublicShared.getWeek(G.time) != 1) {
console.log("不是周一,不发放终身卡", PublicShared.getWeek(G.time));
return
};
let logs = await G.mongodb.collection("payLogNew").find(
{ key: "zhongshenka", del_time: { $exists: false } }, { projection: { _id: 0, } }
).toArray();
if (logs.length == 0) {
console.log("没有终身卡数据,不发放终身卡");
}
let con = G.gc.payEmail.zhongshenka.filter(e => e.day == 7)[0];
for (let i = 0; i < logs.length; i++) {
console.log("发放终身卡", logs[i].uid);
// 发送邮件
EmailFun.addEmail({
uid: logs[i].uid,
type: "system",
title: con.title,
content: con.content,
contentInsertArr: [],
createTime: G.time,
prize:con.prize,
})
}
})()
}
}