diff --git a/wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/model/TransferCategory.kt b/wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/model/TransferCategory.kt index 275b36fc..92facb06 100644 --- a/wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/model/TransferCategory.kt +++ b/wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/model/TransferCategory.kt @@ -18,6 +18,7 @@ enum class TransferCategory { FEE, REFERRAL_COMMISSION, REFERRAL_KYC_REWARD, + REFERENT_COMMISSION, KYC_ACCEPTED_REWARD, NORMAL //TODO TEST? } \ No newline at end of file diff --git a/wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/model/UserTransactionCategory.kt b/wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/model/UserTransactionCategory.kt index 47fde533..018b899d 100644 --- a/wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/model/UserTransactionCategory.kt +++ b/wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/model/UserTransactionCategory.kt @@ -9,6 +9,7 @@ enum class UserTransactionCategory { FEE, REFERRAL_COMMISSION, REFERRAL_KYC_REWARD, + REFERENT_COMMISSION, KYC_ACCEPTED_REWARD, SYSTEM } \ No newline at end of file diff --git a/wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/service/TransferManagerImpl.kt b/wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/service/TransferManagerImpl.kt index d7a38dba..139bbcae 100644 --- a/wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/service/TransferManagerImpl.kt +++ b/wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/service/TransferManagerImpl.kt @@ -246,6 +246,36 @@ class TransferManagerImpl( userTransactionManager.save(gainerTx) } + TransferCategory.REFERENT_COMMISSION -> { + val loserOwner = command.sourceWallet.owner.id!! + val loserMainWallet = command.sourceWallet + val loserBalance = loserMainWallet.balance.amount + + val gainerOwner = command.destWallet.owner.id!! + val gainerMainWallet = command.destWallet + val gainerBalance = gainerMainWallet.balance.amount + + val loserTx = UserTransaction( + loserOwner, + txId, + currency, + loserBalance - amount, + -amount, + UserTransactionCategory.REFERENT_COMMISSION + ) + userTransactionManager.save(loserTx) + + val gainerTx = UserTransaction( + gainerOwner, + txId, + currency, + gainerBalance + amount, + amount, + UserTransactionCategory.REFERENT_COMMISSION, + ) + userTransactionManager.save(gainerTx) + } + TransferCategory.REFERRAL_KYC_REWARD -> { val loserOwner = command.sourceWallet.owner.id!! val loserMainWallet = command.sourceWallet