From 5b4e0cce65b76ee1a5103b9ca79a3a0fe02b7f6f Mon Sep 17 00:00:00 2001 From: dy Date: Wed, 20 Dec 2023 17:48:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E8=B4=B9=E7=AB=9E=E8=B5=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/event/xiaofeijingsai/ApiOpen.ts | 29 ++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/api_s2c/event/xiaofeijingsai/ApiOpen.ts b/src/api_s2c/event/xiaofeijingsai/ApiOpen.ts index 79c06bb..209b72e 100644 --- a/src/api_s2c/event/xiaofeijingsai/ApiOpen.ts +++ b/src/api_s2c/event/xiaofeijingsai/ApiOpen.ts @@ -4,19 +4,28 @@ import {PayFun} from "../../../public/pay"; import {HuoDongFun} from "../../../public/huodongfun"; import {PublicShared} from "../../../shared/public/public"; - +/** + * 消费竞赛 + * redis缓存3分钟 + * 返回活动日期内的 + * @param call + */ export default async function (call: ApiCall) { - // let data = await G.mongodb.cEvent('zhoumolibao').findOne({uid: call.uid, type: 'zhoumolibao'}) - // + let ioList = await G.ioredis.get(`rank:xiaofeijingsai`); + if (ioList) { + return call.succ({list: JSON.parse(ioList)}) + } + let _hd = (await HuoDongFun.gethdList(call, 11))[0] - console.log(_hd) - // - // let payIds = _hd?.data?.gift?.filter(i => i.payId)?.map(i => i.payId) - // let a = [] + if (!_hd) return call.errorCode(-1) + + let limit = _hd.data?.rank?.slice(-1)?.[0]?.rank?.slice(-1)?.[0] || 50 + let rmbuse = await G.mongodb.collection('rmbuse').aggregate([ - {$match: {isAdd: false}}, + {$match: {isAdd: false, cTime: {$gte: _hd.stime, $lte: _hd.etime}}}, {$group: {_id: "$uid", total: {$sum: "$change"}}}, - {$sort: {total: 1}} + {$sort: {total: 1}}, + {$limit: limit} ]).toArray() let list: any = rmbuse.map(i => ({...i, total: R.negate(i.total)})) @@ -25,5 +34,7 @@ export default async function (call: ApiCall) { list = list.map(i => ({...i, player: users.find(v => v.uid == i._id)})) + G.ioredis.setex(`rank:xiaofeijingsai`, 180, JSON.stringify(list)); + call.succ({list}) } \ No newline at end of file