From 87d5b0902feba59aa07dfd9f5b4c2deb2360f1ae Mon Sep 17 00:00:00 2001 From: dy Date: Tue, 19 Dec 2023 14:29:14 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E9=93=81=E7=AC=BC=E6=AD=BB=E6=96=97?= =?UTF-8?q?=EF=BC=8C=E7=9B=B8=E5=90=8C=E7=A7=AF=E5=88=86=E7=94=A8=E6=88=98?= =?UTF-8?q?=E5=8A=9B=E6=8E=92=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_cross/wzry/ApiRank.ts | 41 +++++++++++++++-------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/src/api_cross/wzry/ApiRank.ts b/src/api_cross/wzry/ApiRank.ts index 79c9d3c..767fdc8 100644 --- a/src/api_cross/wzry/ApiRank.ts +++ b/src/api_cross/wzry/ApiRank.ts @@ -1,39 +1,32 @@ -import { ApiCall } from "tsrpc"; -import { ReqRank, ResRank } from "../../cross/protocols/wzry/PtlRank"; -import { ChatFun } from "../../public/chat"; -import { EmailFun } from "../../public/email"; -import { FightFun } from "../../public/fight"; -import { Rank } from '../../public/rank/rank'; -import { SchedulerWzryDlDstart, wzrygroup } from "../../public/scheduler/scheduler_wzry"; -import { WangZheRongYaofun } from "../../public/wzry"; -import { PublicShared } from "../../shared/public/public"; -import { player } from "../../shared/protocols/user/type"; -import { rankInfo } from "../../shared/protocols/type"; -import { FindOptions } from "mongodb"; +import {ApiCall} from "tsrpc"; +import {ReqRank, ResRank} from "../../cross/protocols/wzry/PtlRank"; +import {player} from "../../shared/protocols/user/type"; +import {FindOptions} from "mongodb"; -export async function getRankList(limit?: number, projection?:any){ - let option : FindOptions = { - sort : { - 'data.valArr': -1 +export async function getRankList(limit?: number, projection?: any) { + let option: FindOptions = { + sort: { + 'data.valArr': -1, + 'data.player.power': -1 } } - if(limit!=null){ + if (limit != null) { option.limit = limit; } - if(projection!=null){ + if (projection != null) { option.projection = projection; } - let listArr = await G.mongodb.collection('rankList').find({ type: 'wzryCross' },option).toArray(); + let listArr = await G.mongodb.collection('rankList').find({type: 'wzryCross'}, option).toArray(); let list = listArr.map(l => l.data); return list; } export async function getPlayerRank(uid: string) { - let _r = await getRankList(50,{ - "data.player.uid":1, - "data.valArr":1, + let _r = await getRankList(50, { + "data.player.uid": 1, + "data.valArr": 1, }); if (!Object.keys(_r).length) { return -1 @@ -42,14 +35,14 @@ export async function getPlayerRank(uid: string) { return myrank; } -export async function getWzryRankList(uid: string, gud: player){ +export async function getWzryRankList(uid: string, gud: player) { let list = await getRankList(50); return { rankList: list, myRank: { rank: list.findIndex(li => li.player.uid == uid) + 1 || -1, player: gud, - valArr: [(await G.mongodb.collection('wzry_fight').findOne({ uid: uid }))?.jifen || 0] + valArr: [(await G.mongodb.collection('wzry_fight').findOne({uid: uid}))?.jifen || 0] } }; } From dbda10a17ed3190c275100fa97a2b34b3784e5cd Mon Sep 17 00:00:00 2001 From: dy Date: Tue, 19 Dec 2023 16:24:14 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=8E=BB=E6=8E=89trace=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/setMongodb.ts | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/setMongodb.ts b/src/setMongodb.ts index 2e1c47a..d636171 100644 --- a/src/setMongodb.ts +++ b/src/setMongodb.ts @@ -630,25 +630,25 @@ export class _mongodb { } } -//@ts-ignore -FindCursor.prototype._toArray = FindCursor.prototype.toArray; -//@ts-ignore -FindCursor.prototype.toArray = async function(){ - let rss = await this._toArray(); - - //如果返回的数据超过50条 - if(rss.length>50){ - addGameLog("system","findCount",null,{ - collection: this.namespace.collection, - db:this.namespace.db, - count:rss.length - }) - console.log("system,findCount",{ - collection: this.namespace.collection, - db:this.namespace.db, - count:rss.length - }) - console.trace(); - } - return rss; -} \ No newline at end of file +// //@ts-ignore +// FindCursor.prototype._toArray = FindCursor.prototype.toArray; +// //@ts-ignore +// FindCursor.prototype.toArray = async function(){ +// let rss = await this._toArray(); +// +// //如果返回的数据超过50条 +// if(rss.length>50){ +// addGameLog("system","findCount",null,{ +// collection: this.namespace.collection, +// db:this.namespace.db, +// count:rss.length +// }) +// console.log("system,findCount",{ +// collection: this.namespace.collection, +// db:this.namespace.db, +// count:rss.length +// }) +// console.trace(); +// } +// return rss; +// } \ No newline at end of file From 7ae7349550dc0acdafd78c8b495c557a0883de77 Mon Sep 17 00:00:00 2001 From: xcy <871622040@qq.com> Date: Tue, 19 Dec 2023 14:42:51 +0800 Subject: [PATCH 3/6] =?UTF-8?q?fix:=E8=B7=A8=E6=9C=8D=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/scheduler/scheduler_cross_email_pull.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/public/scheduler/scheduler_cross_email_pull.ts b/src/public/scheduler/scheduler_cross_email_pull.ts index 652f36e..66a19cc 100644 --- a/src/public/scheduler/scheduler_cross_email_pull.ts +++ b/src/public/scheduler/scheduler_cross_email_pull.ts @@ -22,12 +22,15 @@ export class CrossEmailPull extends Scheduler { G.clientCross.callApi("email/GetCrossEmail", {server_id: G.config.serverId + ""}).then((res) => { if(!res.isSucc)return; res.res.emails.forEach(async (email) => { + let _prize = email?.prizeData?.prize || []; + if (email?.prizeData) delete email.prizeData; + + email["prize"] = _prize; if (email.uid != "system") { await EmailFun.addEmail(email) } else { await EmailFun.addQuanFuEmail(email) } - await EmailFun.addEmail(email) }) }) await this.ctorStartTime() From 11e5f17b20819903253238b481438d6ef15d3917 Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Tue, 19 Dec 2023 17:00:25 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0gc=20Test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js_pm2.config.js | 4 + package-lock.json | 31 ++++++++ package.json | 1 + src/api_o2s/games/Apiheapdump.ts | 23 ++++++ src/monopoly/protocols/games/Ptlheapdump.ts | 18 +++++ src/monopoly/protocols/serviceProto.ts | 84 ++++++++++++++++----- src/setHttp.ts | 3 +- 7 files changed, 145 insertions(+), 19 deletions(-) create mode 100644 src/api_o2s/games/Apiheapdump.ts create mode 100644 src/monopoly/protocols/games/Ptlheapdump.ts diff --git a/js_pm2.config.js b/js_pm2.config.js index 0efa009..bb6f27d 100644 --- a/js_pm2.config.js +++ b/js_pm2.config.js @@ -60,6 +60,8 @@ const localApps = [ instances: instancesNum, // 传递给脚本的参数 args: '-serverType msg', + //允许强制gc + node_args: '--expose-gc', // 是否启用监控模式,默认是false。如果设置成true,当应用程序变动时,pm2会自动重载。这里也可以设置你要监控的文件。 watch: false, // 不用监听的文件 @@ -86,6 +88,8 @@ const crossApps = [ cwd: './', // 传递给脚本的参数 args: '-serverType cross', + //允许强制gc + node_args: '--expose-gc', // 是否启用监控模式,默认是false。如果设置成true,当应用程序变动时,pm2会自动重载。这里也可以设置你要监控的文件。 watch: false, // 不用监听的文件 diff --git a/package-lock.json b/package-lock.json index 824ac2d..c0fc9f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "axios": "^1.4.0", "crypto-js": "^4.1.1", "express": "^4.18.2", + "heapdump": "^0.3.15", "ioredis": "^5.3.2", "json5": "^2.2.3", "mathjs": "^11.4.0", @@ -2545,6 +2546,18 @@ "he": "bin/he" } }, + "node_modules/heapdump": { + "version": "0.3.15", + "resolved": "https://registry.npmjs.org/heapdump/-/heapdump-0.3.15.tgz", + "integrity": "sha512-n8aSFscI9r3gfhOcAECAtXFaQ1uy4QSke6bnaL+iymYZ/dWs9cqDqHM+rALfsHUwukUbxsdlECZ0pKmJdQ/4OA==", + "hasInstallScript": true, + "dependencies": { + "nan": "^2.13.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/http-basic": { "version": "8.1.3", "resolved": "https://registry.npmmirror.com/http-basic/-/http-basic-8.1.3.tgz", @@ -3199,6 +3212,11 @@ "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", "dev": true }, + "node_modules/nan": { + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.18.0.tgz", + "integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==" + }, "node_modules/nanoid": { "version": "3.3.1", "resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.1.tgz", @@ -6645,6 +6663,14 @@ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, + "heapdump": { + "version": "0.3.15", + "resolved": "https://registry.npmjs.org/heapdump/-/heapdump-0.3.15.tgz", + "integrity": "sha512-n8aSFscI9r3gfhOcAECAtXFaQ1uy4QSke6bnaL+iymYZ/dWs9cqDqHM+rALfsHUwukUbxsdlECZ0pKmJdQ/4OA==", + "requires": { + "nan": "^2.13.2" + } + }, "http-basic": { "version": "8.1.3", "resolved": "https://registry.npmmirror.com/http-basic/-/http-basic-8.1.3.tgz", @@ -7163,6 +7189,11 @@ "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", "dev": true }, + "nan": { + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.18.0.tgz", + "integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==" + }, "nanoid": { "version": "3.3.1", "resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.1.tgz", diff --git a/package.json b/package.json index 99faaea..2f06bdb 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "axios": "^1.4.0", "crypto-js": "^4.1.1", "express": "^4.18.2", + "heapdump": "^0.3.15", "ioredis": "^5.3.2", "json5": "^2.2.3", "mathjs": "^11.4.0", diff --git a/src/api_o2s/games/Apiheapdump.ts b/src/api_o2s/games/Apiheapdump.ts new file mode 100644 index 0000000..e4b923d --- /dev/null +++ b/src/api_o2s/games/Apiheapdump.ts @@ -0,0 +1,23 @@ +import { ApiCall } from "tsrpc"; +import { Reqheapdump, Resheapdump } from "../../monopoly/protocols/games/Ptlheapdump"; +var heapdump = require('heapdump'); + +export default async function (call: ApiCall) { + + if(call.req.act == "heapdump"){ + let name = Date.now() + '.heapsnapshot' + heapdump.writeSnapshot(name); + call.succ({ + code:200, + data:name + }) + } + + if(call.req.act == "gc"){ + global.gc(); + call.succ({ + code:200, + data:"gc..." + }) + } +} \ No newline at end of file diff --git a/src/monopoly/protocols/games/Ptlheapdump.ts b/src/monopoly/protocols/games/Ptlheapdump.ts new file mode 100644 index 0000000..bd93a7f --- /dev/null +++ b/src/monopoly/protocols/games/Ptlheapdump.ts @@ -0,0 +1,18 @@ +import { StringTypeSchema } from "tsbuffer-schema"; + +/** + * 区服初始化 + */ +export type Reqheapdump = { + act:string, + data:any +}; + + +export type Resheapdump = { + /** + * 如果发送成功 将返回 + */ + code: number + data: any; +}; \ No newline at end of file diff --git a/src/monopoly/protocols/serviceProto.ts b/src/monopoly/protocols/serviceProto.ts index 782cc14..6ca08f2 100644 --- a/src/monopoly/protocols/serviceProto.ts +++ b/src/monopoly/protocols/serviceProto.ts @@ -1,6 +1,7 @@ import { ServiceProto } from 'tsrpc-proto'; import { Reqsendemail, Ressendemail } from './email/Ptlsendemail'; import { Reqdeploy, Resdeploy } from './games/Ptldeploy'; +import { Reqheapdump, Resheapdump } from './games/Ptlheapdump'; import { Reqmetrics, Resmetrics } from './games/Ptlmetrics'; import { Reqnotification, Resnotification } from './games/Ptlnotification'; import { Reqopen, Resopen } from './games/Ptlopen'; @@ -31,6 +32,10 @@ export interface ServiceType { req: Reqdeploy, res: Resdeploy }, + "games/heapdump": { + req: Reqheapdump, + res: Resheapdump + }, "games/metrics": { req: Reqmetrics, res: Resmetrics @@ -127,96 +132,101 @@ export const serviceProto: ServiceProto = { }, { "id": 2, - "name": "games/metrics", + "name": "games/heapdump", "type": "api" }, { "id": 3, - "name": "games/notification", + "name": "games/metrics", "type": "api" }, { "id": 4, - "name": "games/open", + "name": "games/notification", "type": "api" }, { "id": 5, - "name": "games/ranking", + "name": "games/open", "type": "api" }, { "id": 6, - "name": "gift/popup", + "name": "games/ranking", "type": "api" }, { "id": 7, - "name": "gm/Pay", + "name": "gift/popup", "type": "api" }, { "id": 8, - "name": "gm/SendPrize", + "name": "gm/Pay", "type": "api" }, { "id": 9, - "name": "hdinfo/details", + "name": "gm/SendPrize", "type": "api" }, { "id": 10, - "name": "AddHuoDong", + "name": "hdinfo/details", "type": "api" }, { "id": 11, - "name": "CatAllhd", + "name": "AddHuoDong", "type": "api" }, { "id": 12, - "name": "DelHuoDong", + "name": "CatAllhd", "type": "api" }, { "id": 13, - "name": "Email", + "name": "DelHuoDong", "type": "api" }, { "id": 14, - "name": "GetLog", + "name": "Email", "type": "api" }, { "id": 15, - "name": "healthz", + "name": "GetLog", "type": "api" }, { "id": 16, - "name": "union/rename", + "name": "healthz", "type": "api" }, { "id": 17, - "name": "user/data", + "name": "union/rename", "type": "api" }, { "id": 18, - "name": "user/disable", + "name": "user/data", "type": "api" }, { "id": 19, - "name": "user/getdata", + "name": "user/disable", "type": "api" }, { "id": 20, + "name": "user/getdata", + "type": "api" + }, + { + "id": 21, "name": "user/rename", "type": "api" } @@ -367,6 +377,44 @@ export const serviceProto: ServiceProto = { } ] }, + "games/Ptlheapdump/Reqheapdump": { + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "act", + "type": { + "type": "String" + } + }, + { + "id": 1, + "name": "data", + "type": { + "type": "Any" + } + } + ] + }, + "games/Ptlheapdump/Resheapdump": { + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "code", + "type": { + "type": "Number" + } + }, + { + "id": 1, + "name": "data", + "type": { + "type": "Any" + } + } + ] + }, "games/Ptlmetrics/Reqmetrics": { "type": "Interface" }, diff --git a/src/setHttp.ts b/src/setHttp.ts index 6c10173..62af391 100644 --- a/src/setHttp.ts +++ b/src/setHttp.ts @@ -10,7 +10,8 @@ export async function createHttp() { json: true, cors: '*', port: G.config.httpPort, - logLevel: G.argv.logModel as LogLevel + logLevel: G.argv.logModel as LogLevel, + apiTimeout:300000, }); setHttp(G.http); await G.http.autoImplementApi(resolve(__dirname, 'api_o2s'), true); From db2286509c6af4a5bfa75b71e59a1f0de1d01ec8 Mon Sep 17 00:00:00 2001 From: xcy <871622040@qq.com> Date: Fri, 15 Dec 2023 20:06:20 +0800 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=83=85=E6=8A=A5?= =?UTF-8?q?=E7=89=B9=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/xstask/ApiAllGet.ts | 32 +++++++++++++++++++++----------- src/api_s2c/xstask/ApiGet.ts | 31 ++++++++++++++++++++----------- src/api_s2c/xstask/ApiOpen.ts | 2 +- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/src/api_s2c/xstask/ApiAllGet.ts b/src/api_s2c/xstask/ApiAllGet.ts index f41ac3c..d89d696 100644 --- a/src/api_s2c/xstask/ApiAllGet.ts +++ b/src/api_s2c/xstask/ApiAllGet.ts @@ -1,15 +1,17 @@ -import { ApiCall } from "tsrpc"; -import { PlayerFun } from '../../public/player'; -import { XstaskFun } from '../../public/xstask'; -import { ReqAllGet, ResAllGet } from "../../shared/protocols/xstask/PtlAllGet"; -import { HongDianChange } from "../hongdian/fun"; -import { PublicShared } from "../../shared/public/public"; +import {ApiCall} from "tsrpc"; +import {PlayerFun} from '../../public/player'; +import {XstaskFun} from '../../public/xstask'; +import {ReqAllGet, ResAllGet} from "../../shared/protocols/xstask/PtlAllGet"; +import {HongDianChange} from "../hongdian/fun"; +import {PublicShared} from "../../shared/public/public"; +import {TeQuanFun} from "../../public/tequan"; export default async function (call: ApiCall) { const taskList = JSON.parse(JSON.stringify(await XstaskFun.getAllTask(call.uid))); let taskInfo = await XstaskFun.getInfo(call.uid); - let prizeArr:atn[] = [] - for(let task of taskList) { + let tequan = await TeQuanFun.getXsTaskNum(call); + let prizeArr: atn[] = [] + for (let task of taskList) { const taskConf = G.gc.xstask[task?.taskId]; if (!task) continue; if (task.receiveData == undefined) continue; @@ -23,12 +25,12 @@ export default async function (call: ApiCall) { // } continue } - let change: Parameters[1] = { $inc: {} }; + let change: Parameters[1] = {$inc: {}}; change.$inc[`finishNum.${taskConf.colour}`] = 1; // 比对派遣时间,如果小于当日0点,则更新新任务,否则该变领取状态为true - if(task.receiveData.time < PublicShared.getToDayZeroTime()) { + if (task.receiveData.time < PublicShared.getToDayZeroTime()) { // 更新任务 - let newTask = XstaskFun.randomTasks(taskInfo?.lv, 1) + let newTask = XstaskFun.randomTasks(taskInfo?.lv, 1) XstaskFun.updateTask(call.uid, task._id, newTask[0].taskId) } else { // 更新领取状态 @@ -38,6 +40,14 @@ export default async function (call: ApiCall) { XstaskFun.changeInfo(call.uid, change); await PlayerFun.sendPrize(call, taskConf.prize); HongDianChange.sendChangeKey(call.uid, ['xstaskhd', 'huodonghd']); + + if (!tequan) { + prizeArr.push(...taskConf.prize) + } else { + for (let i = 0; i < 3; i++) { + prizeArr.push(...taskConf.prize) + } + } prizeArr.push(...taskConf.prize) } call.succ({ diff --git a/src/api_s2c/xstask/ApiGet.ts b/src/api_s2c/xstask/ApiGet.ts index 62a5b1b..878052d 100644 --- a/src/api_s2c/xstask/ApiGet.ts +++ b/src/api_s2c/xstask/ApiGet.ts @@ -1,9 +1,10 @@ -import { ApiCall } from "tsrpc"; -import { PlayerFun } from '../../public/player'; -import { XstaskFun } from '../../public/xstask'; -import { ReqGet, ResGet } from "../../shared/protocols/xstask/PtlGet"; -import { HongDianChange } from "../hongdian/fun"; -import { PublicShared } from '../../shared/public/public'; +import {ApiCall} from "tsrpc"; +import {PlayerFun} from '../../public/player'; +import {XstaskFun} from '../../public/xstask'; +import {ReqGet, ResGet} from "../../shared/protocols/xstask/PtlGet"; +import {HongDianChange} from "../hongdian/fun"; +import {PublicShared} from '../../shared/public/public'; +import {TeQuanFun} from "../../public/tequan"; export default async function (call: ApiCall) { @@ -23,24 +24,32 @@ export default async function (call: ApiCall) { } } - let change: Parameters[1] = { $inc: {} }; + let change: Parameters[1] = {$inc: {}}; change.$inc[`finishNum.${taskConf.colour}`] = 1; // 比对派遣时间,如果小于当日0点,则更新新任务,否则该变领取状态为true - if(task.receiveData.time < PublicShared.getToDayZeroTime()) { + if (task.receiveData.time < PublicShared.getToDayZeroTime()) { // 更新任务 - let newTask = XstaskFun.randomTasks(taskInfo?.lv, 1) + let newTask = XstaskFun.randomTasks(taskInfo?.lv, 1) XstaskFun.updateTask(call.uid, call.req._id, newTask[0].taskId) } else { // 更新领取状态 XstaskFun.finishTask(call.uid, call.req._id) } // XstaskFun.delTask(call.uid, call.req._id); + let send_prize = []; XstaskFun.changeInfo(call.uid, change); - await PlayerFun.sendPrize(call, taskConf.prize); + if (!await TeQuanFun.getXsTaskNum(call)) { + send_prize = taskConf.prize; + } else { + for (let i = 0; i < 3; i++) { + send_prize = send_prize.concat(taskConf.prize) + } + } + await PlayerFun.sendPrize(call, send_prize); HongDianChange.sendChangeKey(call.uid, ['xstaskhd', 'huodonghd']); call.succ({ taskList: await XstaskFun.getAllTask(call.uid), - prize: taskConf.prize + prize: send_prize }); } \ No newline at end of file diff --git a/src/api_s2c/xstask/ApiOpen.ts b/src/api_s2c/xstask/ApiOpen.ts index 4261a4c..3a65a5d 100644 --- a/src/api_s2c/xstask/ApiOpen.ts +++ b/src/api_s2c/xstask/ApiOpen.ts @@ -36,7 +36,7 @@ export default async function (call: ApiCall) { XstaskFun.delTasks(call.uid, delTask.map(task => task._id)); } - needAddTask += await TeQuanFun.getXsTaskNum(call); + // needAddTask += await TeQuanFun.getXsTaskNum(call); needAddTask && await XstaskFun.addTasks(call.uid, XstaskFun.randomTasks(taskInfo?.lv || changeInfo.lv, needAddTask)); let { _id, uid, type, ...info } = taskInfo || changeInfo as typeof taskInfo; From 070edf1cb54cd9afb0bf5cad928bbd910c50375e Mon Sep 17 00:00:00 2001 From: xcy <871622040@qq.com> Date: Fri, 15 Dec 2023 21:11:31 +0800 Subject: [PATCH 6/6] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E4=BC=99=E4=BC=B4?= =?UTF-8?q?=E6=8B=9B=E5=8B=9F=E7=9A=84=E5=A5=96=E5=8A=B1=E9=A2=86=E5=8F=96?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/event/huobanzhaomu/ApiRec.ts | 37 +++++++++++++++--------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/api_s2c/event/huobanzhaomu/ApiRec.ts b/src/api_s2c/event/huobanzhaomu/ApiRec.ts index 3b8cd45..0c1dfba 100644 --- a/src/api_s2c/event/huobanzhaomu/ApiRec.ts +++ b/src/api_s2c/event/huobanzhaomu/ApiRec.ts @@ -1,27 +1,38 @@ -import { ApiCall } from "tsrpc"; -import { PlayerFun } from '../../../public/player'; -import { ReqRec, ResRec } from "../../../shared/protocols/event/huobanzhaomu/PtlRec"; -import { HongDianChange } from "../../hongdian/fun"; +import {ApiCall} from "tsrpc"; +import {PlayerFun} from '../../../public/player'; +import {ReqRec, ResRec} from "../../../shared/protocols/event/huobanzhaomu/PtlRec"; +import {HongDianChange} from "../../hongdian/fun"; +import {PayFun} from "../../../public/pay"; export default async function (call: ApiCall) { let conf = G.gc.huobanzhaomu[call.req.index]; - if (!conf) return call.error('', { code: -1 }); - if (conf.gudKey && call.conn.gud[conf.gudKey] < conf.total) return call.error('', { code: -2 }); + if (!conf) return call.error('', {code: -1}); + if (conf.gudKey && call.conn.gud[conf.gudKey] < conf.total) return call.error('', {code: -2}); - let db = await G.mongodb.cEvent('huobanzhaomu').findOne({ uid: call.uid, type: 'huobanzhaomu' }); - if (db?.rec.includes(call.req.index)) return call.error('', { code: -3 }); - if (!conf.gudKey && (db?.rec?.length || 0) < G.gc.huobanzhaomu.length - 1) return call.error('', { code: -4 }); + let db = await G.mongodb.cEvent('huobanzhaomu').findOne({uid: call.uid, type: 'huobanzhaomu'}); + if (db?.rec.includes(call.req.index)) return call.error('', {code: -3}); + + if (conf.gudKey == "chaozhiyueka") { + let logs = await PayFun.getPayLog(call.uid, "chaozhiyueka"); + if (!logs || logs.slice(-1)[0].eTime < G.time) { + return call.error('', {code: -4}); + } + } else { + if (!conf.gudKey && (db?.rec?.length || 0) < G.gc.huobanzhaomu.length - 1) { + return call.error('', {code: -4}); + } + } await PlayerFun.sendPrize(call, conf.prize); if (db?.rec?.length + 1 >= G.gc.huobanzhaomu.length) { - G.mongodb.collection('syncBtns').updateOne({ uid: call.uid }, { $set: { 'huobanzhaomu.active': false } }, { upsert: true }); + G.mongodb.collection('syncBtns').updateOne({uid: call.uid}, {$set: {'huobanzhaomu.active': false}}, {upsert: true}); } G.mongodb.cEvent('huobanzhaomu').updateOne( - { uid: call.uid, type: 'huobanzhaomu' }, - { $push: { rec: call.req.index } }, - { upsert: true } + {uid: call.uid, type: 'huobanzhaomu'}, + {$push: {rec: call.req.index}}, + {upsert: true} ); HongDianChange.sendChangeKey(call.uid, ['huobanzhaomuhd'])