fix: 累计收益

This commit is contained in:
chaosBreaking
2019-09-30 11:20:42 +08:00
parent 0638a4cc5b
commit 3fd1776581

View File

@@ -295,12 +295,14 @@ module.exports = {
return Fund.findOne({userId}).then(async fund => {
const [ start, end ] = getDate(1);
let now = new Date();
const actions = await Action.find({ userId, type: 1, createdAt: { $gt: start, $lt: now } }).exec();
// 计算昨日收益
let revenueLastday = calRevenueLastday(actions);
// 筛选有效矿晶
let activeFund = getActiveFund(fund.fundList);
const revenueAll = fund.asset && +fund.asset['vic'] || 0;
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);
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: {