fix: deposit award

This commit is contained in:
chaosBreaking
2019-09-29 21:53:39 +08:00
parent a31f095699
commit 624f34e1ed
2 changed files with 31 additions and 2 deletions

View File

@@ -143,14 +143,28 @@ FundModel.prototype.addFund = async function (txlist = [], option) {
const myId = this.userId;
User.findById(myId).then(async user => {
if (!user && !user.inviter) return 0;
const award = +newSum * 0.1;
const inviteFund = createNewFund({
amount: +newSum * 0.1,
amount: award,
blockNumber: 'followerReward',
hash: myId
});
User.findByIdAndUpdate(user.inviter, {
$push: inviteFund
$push: {
fundList: inviteFund
}
});
createAction(4, {
userId: myId,
amount: award, // 充值记录的数值仍然是区块链的数值
tokenType: 'vic', // 目前设定只能挖出矿晶vic
remain: this.asset,
detail: {
desc: `${user.id}挖矿充值奖励其推荐人${user.inviter}`
}
}).save();
}).catch(err => {
mylog.error(`${myId}充值奖励其推荐人时出错 `, JSON.stringify(err));
});
return res;
};