Merge branch 'feature/xiaofeijingsai' into dev
This commit is contained in:
commit
d3ebfdcc02
@ -13,13 +13,14 @@ import {PublicShared} from "../../../shared/public/public";
|
|||||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
let ioList = await G.ioredis.get(`rank:xiaofeijingsai`);
|
let ioList = await G.ioredis.get(`rank:xiaofeijingsai`);
|
||||||
if (ioList) {
|
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]
|
let _hd = (await HuoDongFun.gethdList(call, 11))[0]
|
||||||
if (!_hd) return call.errorCode(-1)
|
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([
|
let rmbuse = await G.mongodb.collection('rmbuse').aggregate([
|
||||||
{$match: {isAdd: false, cTime: {$gte: _hd.stime, $lte: _hd.etime}}},
|
{$match: {isAdd: false, cTime: {$gte: _hd.stime, $lte: _hd.etime}}},
|
||||||
@ -34,7 +35,28 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
|
|
||||||
list = list.map(i => ({...i, player: users.find(v => v.uid == i._id)}))
|
list = list.map(i => ({...i, player: users.find(v => v.uid == i._id)}))
|
||||||
|
|
||||||
G.ioredis.setex(`rank:xiaofeijingsai`, 180, JSON.stringify(list));
|
// 活动结束前半小时,缓存过期时间改为10秒
|
||||||
|
let exTime = (G.time + 1800) > _hd.etime ? 10 : 180
|
||||||
|
|
||||||
call.succ({list})
|
G.ioredis.setex(`rank:xiaofeijingsai`, exTime, JSON.stringify(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 = {
|
export type ResOpen = {
|
||||||
list: any[]
|
list: { _id: string, total: number, player: any }[]
|
||||||
|
myData: { _id: string, total: number, player: any }
|
||||||
};
|
};
|
@ -10627,7 +10627,16 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"event/xiaofeijingsai/PtlOpen/ReqOpen": {
|
"event/xiaofeijingsai/PtlOpen/ReqOpen": {
|
||||||
"type": "Interface"
|
"type": "Interface",
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": 0,
|
||||||
|
"name": "limit",
|
||||||
|
"type": {
|
||||||
|
"type": "Number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"event/xiaofeijingsai/PtlOpen/ResOpen": {
|
"event/xiaofeijingsai/PtlOpen/ResOpen": {
|
||||||
"type": "Interface",
|
"type": "Interface",
|
||||||
@ -10638,9 +10647,62 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "Array",
|
"type": "Array",
|
||||||
"elementType": {
|
"elementType": {
|
||||||
|
"type": "Interface",
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": 0,
|
||||||
|
"name": "_id",
|
||||||
|
"type": {
|
||||||
|
"type": "String"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "total",
|
||||||
|
"type": {
|
||||||
|
"type": "Number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"name": "player",
|
||||||
|
"type": {
|
||||||
"type": "Any"
|
"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