fix: 只找vicFundSum大于0的&分配比例
This commit is contained in:
4
clean.js
4
clean.js
@@ -48,8 +48,8 @@ async function clean () {
|
|||||||
const releasedAmout = (await Action.find({ type: '1', userId: userFund.userId })).reduce((sum, action) => sum + +action.amount, 0);
|
const releasedAmout = (await Action.find({ type: '1', userId: userFund.userId })).reduce((sum, action) => sum + +action.amount, 0);
|
||||||
const rest = boughtAmountSum - releasedAmout;
|
const rest = boughtAmountSum - releasedAmout;
|
||||||
mylog.info('No. ', currentIndex, '用户' + userFund.userId, '剩余 ', rest);
|
mylog.info('No. ', currentIndex, '用户' + userFund.userId, '剩余 ', rest);
|
||||||
await Fund.findByIdAndUpdate(userFund.id, { fundList: [], 'option.restNeetToRelease': rest });
|
const vic = userFund.asset.vic || 0;
|
||||||
// await Fund.findByIdAndUpdate(userFund.id, { fundList: [], $inc: {'asset.vic': userFund.option.restNeetToRelease } });
|
await Fund.findByIdAndUpdate(userFund.id, { vicFundSum: vic, 'asset.vic': 0, fundList: [], 'option.restNeetToRelease': rest, snapshot: { asset: userFund.asset } });
|
||||||
probe.currentIndex = currentIndex;
|
probe.currentIndex = currentIndex;
|
||||||
}
|
}
|
||||||
process.exit();
|
process.exit();
|
||||||
|
|||||||
@@ -40,21 +40,24 @@ const { createAction } = require('../modules/action/action.handler');
|
|||||||
|
|
||||||
const getProfitRate = base => {
|
const getProfitRate = base => {
|
||||||
if (base > 0 && base <= 10000) {
|
if (base > 0 && base <= 10000) {
|
||||||
return 0.0002;
|
return 0.001;
|
||||||
} else if (base > 10000 && base <= 50000) {
|
} else if (base > 10000 && base <= 50000) {
|
||||||
return 0.0005;
|
return 0.003;
|
||||||
} else if (base > 50000 && base <= 100000) {
|
} else if (base > 50000 && base <= 100000) {
|
||||||
return 0.0008;
|
return 0.006;
|
||||||
} else if (base > 100000 && base <= 200000) {
|
} else if (base > 100000 && base <= 200000) {
|
||||||
return 0.0010;
|
return 0.01;
|
||||||
} else if (base > 200000 && base <= 500000) {
|
} else if (base > 200000 && base <= 500000) {
|
||||||
return 0.0015;
|
return 0.015;
|
||||||
} else if (base > 500000 && base <= 1000000) {
|
} else if (base > 500000 && base <= 1000000) {
|
||||||
return 0.0020;
|
return 0.018;
|
||||||
} else if (base > 1000000 && base <= 10000000) {
|
} else if (base > 1000000 && base <= 10000000) {
|
||||||
return 0.0030;
|
return 0.02;
|
||||||
} else return 0;
|
} else return 0;
|
||||||
};
|
};
|
||||||
|
const probe = {
|
||||||
|
currentIndex: 0
|
||||||
|
};
|
||||||
|
|
||||||
function awardMine(user, fund) {
|
function awardMine(user, fund) {
|
||||||
if (!user || !fund || fund.vicFundSum === 0) return 0;
|
if (!user || !fund || fund.vicFundSum === 0) return 0;
|
||||||
@@ -127,7 +130,7 @@ async function mine (job = mock, done = mock) {
|
|||||||
});
|
});
|
||||||
// 批量更新,每次十个
|
// 批量更新,每次十个
|
||||||
for (; currentIndex < allFundNum;) {
|
for (; currentIndex < allFundNum;) {
|
||||||
const userFundList = await Fund.find().sort('_id').limit(10).skip(currentIndex);
|
const userFundList = await Fund.find({ vicFundSum: { $gt: 0 } }).sort('_id').limit(10).skip(currentIndex);
|
||||||
typeof job.touch === 'function' && job.touch();
|
typeof job.touch === 'function' && job.touch();
|
||||||
if (!userFundList || !Array.isArray(userFundList)) return 0;
|
if (!userFundList || !Array.isArray(userFundList)) return 0;
|
||||||
for (let i = 0, len = userFundList.length; i < len; ++i) {
|
for (let i = 0, len = userFundList.length; i < len; ++i) {
|
||||||
@@ -175,9 +178,7 @@ async function mine (job = mock, done = mock) {
|
|||||||
typeof done === 'function' && done('收益计算分配完成');
|
typeof done === 'function' && done('收益计算分配完成');
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
const probe = {
|
|
||||||
currentIndex: 0
|
|
||||||
};
|
|
||||||
const start = async (job, done) => {
|
const start = async (job, done) => {
|
||||||
const SysConfig = require('../../configSec');
|
const SysConfig = require('../../configSec');
|
||||||
mongoose.set('useCreateIndex', true);
|
mongoose.set('useCreateIndex', true);
|
||||||
|
|||||||
Reference in New Issue
Block a user