Mleipper / AirDropProjectboard

0 stars 0 forks source link

payment run #6

Open Mleipper opened 5 years ago

Mleipper commented 5 years ago

1 - For each referrer - SUM up all 'paid' and 'status accepted' rewards (using RewardActions) without the referral paid and set that amount of tokens (In TokenRewards for the referrer) to pendingReferralTokens

3 - Recalculate all TokenReward values for - PendingTokens - i.e. status of pending only, EarnedTokens - All accepted rewards

4 - For each TokenReward with the same type of token payment, Sum up EarnedTokens and [ReferalTokens] and output the users UserId, PaymentToken, CryptoAddress, TotalToBePaid

5 - Set all rows of 1 to referralPaid

6 - Set all values of accepted rewards to paid if they were changed in step 3

7 - Set all rows that were used in step 4 to change from [EarnedTokens] to [PaidTokens] and [ReferalTokens] to [PaidReferalTokens]

Mleipper commented 5 years ago

select UserId, sum(TokensAwarded) as Tokens_earned from [rewardpo_earn].[dbo].[RewardActions] where Status = 2 or Status =3 group by UserId

saved here will pick up in morning