fix: deposit award
This commit is contained in:
@@ -13,6 +13,7 @@ function createAction (actCode, data) {
|
||||
case 1: return createMineRewardAction(data);
|
||||
case 2: return createGroupRewardAction(data);
|
||||
case 3: return createWithdrawAction(data);
|
||||
case 4: return createFollerDepositAward(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +71,20 @@ function createWithdrawAction(data = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
function createFollerDepositAward(data = {}) {
|
||||
// 充值奖励推荐人
|
||||
const { userId, amount, remain, tokenType, detail = {} } = data;
|
||||
return new Action({
|
||||
userId,
|
||||
type: 4,
|
||||
op: 1,
|
||||
amount,
|
||||
remain,
|
||||
tokenType,
|
||||
detail
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createAction,
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user