消耗竞赛
This commit is contained in:
parent
6953349058
commit
fd3c13d2b5
@ -13,13 +13,14 @@ import {PublicShared} from "../../../shared/public/public";
|
||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||
let ioList = await G.ioredis.get(`rank:xiaofeijingsai`);
|
||||
if (ioList) {
|
||||
return call.succ({list: JSON.parse(ioList)})
|
||||
let myData = await getMyData(call, JSON.parse(ioList))
|
||||
return call.succ({list: JSON.parse(ioList), myData})
|
||||
}
|
||||
|
||||
let _hd = (await HuoDongFun.gethdList(call, 11))[0]
|
||||
if (!_hd) return call.errorCode(-1)
|
||||
|
||||
let limit = _hd.data?.rank?.slice(-1)?.[0]?.rank?.slice(-1)?.[0] || 50
|
||||
let limit = call.req.limit || 50
|
||||
|
||||
let rmbuse = await G.mongodb.collection('rmbuse').aggregate([
|
||||
{$match: {isAdd: false, cTime: {$gte: _hd.stime, $lte: _hd.etime}}},
|
||||
@ -35,9 +36,27 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||
list = list.map(i => ({...i, player: users.find(v => v.uid == i._id)}))
|
||||
|
||||
// 活动结束前半小时,缓存过期时间改为10秒
|
||||
let exTime = (G.time + 1800) < _hd.etime ? 10 : 180
|
||||
let exTime = (G.time + 1800) > _hd.etime ? 10 : 180
|
||||
|
||||
G.ioredis.setex(`rank:xiaofeijingsai`, exTime, JSON.stringify(list));
|
||||
|
||||
call.succ({list})
|
||||
let myData = await getMyData(call, list, _hd)
|
||||
|
||||
call.succ({list, myData})
|
||||
}
|
||||
|
||||
// 获取自己的信息
|
||||
async function getMyData(call, rankList, _hd?) {
|
||||
let myData = rankList.find(i => i._id == call.uid)
|
||||
if (myData) return myData
|
||||
|
||||
if (!_hd) {
|
||||
_hd = (await HuoDongFun.gethdList(call, 11))[0]
|
||||
}
|
||||
let a = await G.mongodb.collection('rmbuse').aggregate([
|
||||
{$match: {uid: call.uid, isAdd: false, cTime: {$gte: _hd.stime, $lte: _hd.etime}}},
|
||||
{$group: {_id: "$uid", total: {$sum: "$change"}}}
|
||||
]).toArray()
|
||||
let myUser = await G.mongodb.collection('user').findOne({uid: call.uid})
|
||||
return {player: myUser, ...a}
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
/**
|
||||
* 消费竞赛
|
||||
*/
|
||||
export type ReqOpen = {};
|
||||
export type ReqOpen = {
|
||||
limit: number
|
||||
};
|
||||
|
||||
export type ResOpen = {
|
||||
list: any[]
|
||||
list: { _id: string, total: number, player: any }[]
|
||||
myData: { _id: string, total: number, player: any }
|
||||
};
|
@ -10534,7 +10534,16 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
||||
]
|
||||
},
|
||||
"event/xiaofeijingsai/PtlOpen/ReqOpen": {
|
||||
"type": "Interface"
|
||||
"type": "Interface",
|
||||
"properties": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "limit",
|
||||
"type": {
|
||||
"type": "Number"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"event/xiaofeijingsai/PtlOpen/ResOpen": {
|
||||
"type": "Interface",
|
||||
@ -10545,9 +10554,62 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
||||
"type": {
|
||||
"type": "Array",
|
||||
"elementType": {
|
||||
"type": "Any"
|
||||
"type": "Interface",
|
||||
"properties": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "_id",
|
||||
"type": {
|
||||
"type": "String"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "total",
|
||||
"type": {
|
||||
"type": "Number"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "player",
|
||||
"type": {
|
||||
"type": "Any"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "myData",
|
||||
"type": {
|
||||
"type": "Interface",
|
||||
"properties": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "_id",
|
||||
"type": {
|
||||
"type": "String"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "total",
|
||||
"type": {
|
||||
"type": "Number"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "player",
|
||||
"type": {
|
||||
"type": "Any"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user