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: {