From 3fd17765816c8768186a42450686582592c36b67 Mon Sep 17 00:00:00 2001 From: chaosBreaking Date: Mon, 30 Sep 2019 11:20:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=B4=AF=E8=AE=A1=E6=94=B6=E7=9B=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/fund/fund.controller.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/fund/fund.controller.js b/src/modules/fund/fund.controller.js index 0ab3c24..c32d7db 100644 --- a/src/modules/fund/fund.controller.js +++ b/src/modules/fund/fund.controller.js @@ -295,12 +295,14 @@ module.exports = { return Fund.findOne({userId}).then(async fund => { const [ start, end ] = getDate(1); let now = new Date(); + // 筛选有效矿晶 + let activeFund = getActiveFund(fund.fundList); const actions = await Action.find({ userId, type: 1, createdAt: { $gt: start, $lt: now } }).exec(); + const allAction = await Action.find({ userId, type: 1 }).exec(); // 计算昨日收益 let revenueLastday = calRevenueLastday(actions); - // 筛选有效矿晶 - let activeFund = getActiveFund(fund.fundList); - const revenueAll = fund.asset && +fund.asset['vic'] || 0; + const revenueAll = Array.isArray(allAction) && allAction.reduce((pre, cur) => (pre.amount && +pre.amount || 0) + (pre.amount && +cur.amount || 0)) || 0; + // const revenueAll = fund.asset && +fund.asset['vic'] || 0; return res.json({ code: 0, data: {