right reduce
This commit is contained in:
@@ -233,6 +233,7 @@ module.exports = {
|
|||||||
const { hasNew, list } = await fund.hasNewDeposit();
|
const { hasNew, list } = await fund.hasNewDeposit();
|
||||||
const [ start, end ] = getDate(1);
|
const [ start, end ] = getDate(1);
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
|
const allAction = await Action.find({ userId, type: 1 }).exec();
|
||||||
if (!hasNew) {
|
if (!hasNew) {
|
||||||
// const [ start, end ] = getDate(1);
|
// const [ start, end ] = getDate(1);
|
||||||
const actions = await Action.find({ userId, type: 1, createdAt: { $gt: start, $lt: now } });
|
const actions = await Action.find({ userId, type: 1, createdAt: { $gt: start, $lt: now } });
|
||||||
@@ -240,7 +241,8 @@ module.exports = {
|
|||||||
let revenueLastday = calRevenueLastday(actions);
|
let revenueLastday = calRevenueLastday(actions);
|
||||||
// 筛选有效矿晶
|
// 筛选有效矿晶
|
||||||
let activeFund = getActiveFund(fund.fundList);
|
let activeFund = getActiveFund(fund.fundList);
|
||||||
const revenueAll = fund.asset && +fund.asset['vic'] || 0;
|
let revenueAll = Array.isArray(allAction) && allAction.reduce((pre, cur) => pre + (+cur.amount || 0), 0) || 0;
|
||||||
|
revenueAll = revenueAll.toFixed(4);
|
||||||
return res.json({
|
return res.json({
|
||||||
code: 0,
|
code: 0,
|
||||||
msg: '刷新成功',
|
msg: '刷新成功',
|
||||||
@@ -263,7 +265,8 @@ module.exports = {
|
|||||||
// 筛选有效矿晶
|
// 筛选有效矿晶
|
||||||
let activeFund = getActiveFund(fund.fundList);
|
let activeFund = getActiveFund(fund.fundList);
|
||||||
if (!newFund || !newFund.fundList) newFund = fund;
|
if (!newFund || !newFund.fundList) newFund = fund;
|
||||||
const revenueAll = fund.asset && +fund.asset['vic'] || 0;
|
let revenueAll = Array.isArray(allAction) && allAction.reduce((pre, cur) => pre + (+cur.amount || 0), 0) || 0;
|
||||||
|
revenueAll = revenueAll.toFixed(4);
|
||||||
return res.json({
|
return res.json({
|
||||||
code: 0,
|
code: 0,
|
||||||
msg: '刷新成功',
|
msg: '刷新成功',
|
||||||
@@ -303,8 +306,8 @@ module.exports = {
|
|||||||
const allAction = await Action.find({ userId, type: 1 }).exec();
|
const allAction = await Action.find({ userId, type: 1 }).exec();
|
||||||
// 计算昨日收益
|
// 计算昨日收益
|
||||||
let revenueLastday = calRevenueLastday(actions);
|
let revenueLastday = calRevenueLastday(actions);
|
||||||
const revenueAll = Array.isArray(allAction) && allAction.reduce((pre, cur) => (pre.amount && +pre.amount || 0) + (pre.amount && +cur.amount || 0), 0) || 0;
|
let revenueAll = Array.isArray(allAction) && allAction.reduce((pre, cur) => pre + (+cur.amount || 0), 0) || 0;
|
||||||
// const revenueAll = fund.asset && +fund.asset['vic'] || 0;
|
revenueAll = revenueAll.toFixed(4);
|
||||||
return res.json({
|
return res.json({
|
||||||
code: 0,
|
code: 0,
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
Reference in New Issue
Block a user