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