Dnlyao
2022-04-08 10:25:44 +08:00
let ids = []
let total = await TradeRecord.find(conditions).select('id').sort({'tradeAt': -1})
for (let item of total) {
ids.push(item._id)
}
for (let index = 1; index <= Math.floor(ids.length / 10) + 1; index++) {
let tradids = []
let i = index - 1 > 0 ? (index - 1) * 10 : 0
if ((index * 10) < ids.length) {
tradids = ids.slice(i, index * 10)
} else {
tradids = ids.slice(i)
}
if (tradids.length > 0) {
let ret = await TradeRecord.find({_id: {$in: tradids}})
.select('device organization restaurant user deploySite consumeInterval amount mainAccountAmount subsidyAmount giveFreeAmount balance subsidyBalance giveFreeBalance tradeAt sn deviceSerial subAccount supermarketConsume payMethod consumeType consumePayMethod deviceMode ')
.populate('organization', 'name')
.populate('restaurant', 'name')
.populate('deploySite', 'name')
.populate({
path: 'user',
select: 'department name type jobNumber cardUid fingerprint',
populate: {path: 'department', select: 'name'}
})
rowsbase.push(...ret)
}
}
}
代码如上