|
|
|
@ -1,10 +1,13 @@ |
|
|
|
package com.qniao.dam.application.handler.walletaccount; |
|
|
|
|
|
|
|
import com.qniao.dam.api.command.walletaccount.user.request.UserAcquireRewardAmountDto; |
|
|
|
import com.qniao.dam.domain.aggregate.walletaccount.WalletAccountAggregate; |
|
|
|
import com.qniao.dam.domain.aggregate.walletaccount.entity.WalletAccount; |
|
|
|
import com.qniao.dam.domain.aggregate.walletaccount.valueobj.WalletAccountRecord; |
|
|
|
import com.qniao.dam.domian.aggregate.walletaccount.constant.IdentityTypeEnum; |
|
|
|
import com.qniao.dam.domian.aggregate.walletaccount.constant.TradeTypeEnum; |
|
|
|
import com.qniao.dam.infrastructure.persistent.dao.domain.WalletAccountDao; |
|
|
|
import com.qniao.dam.query.walletaccount.WalletAccountQueryService; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
@ -18,6 +21,8 @@ public class WalletAccountApplicationService { |
|
|
|
private WalletAccountDao walletAccountDao; |
|
|
|
@Resource |
|
|
|
private WalletAccountAggregate walletAccountAggregate; |
|
|
|
@Resource |
|
|
|
private WalletAccountQueryService walletAccountQueryService; |
|
|
|
|
|
|
|
public void confirmWithdraw(Long walletAccountId, BigDecimal withdrawAmount, Long associateId) { |
|
|
|
WalletAccount walletAccount = walletAccountDao.selectById(walletAccountId); |
|
|
|
@ -37,4 +42,15 @@ public class WalletAccountApplicationService { |
|
|
|
walletAccount.setTotalBalance(walletAccount.getAvailableBalance().add(walletAccount.getFrozenBalance())); |
|
|
|
walletAccountAggregate.save(walletAccount); |
|
|
|
} |
|
|
|
|
|
|
|
public void acquireRewardAmount(UserAcquireRewardAmountDto dto) { |
|
|
|
WalletAccount walletAccount = walletAccountQueryService.queryByType(dto.getUserId(), IdentityTypeEnum.INDIVIDUAL); |
|
|
|
BigDecimal originalBalance = walletAccount.getTotalBalance(); |
|
|
|
walletAccount.setAvailableBalance(walletAccount.getAvailableBalance().add(dto.getAmount())); |
|
|
|
walletAccount.setTotalBalance(walletAccount.getAvailableBalance().add(walletAccount.getFrozenBalance())); |
|
|
|
WalletAccountRecord record = WalletAccountRecord.build(TradeTypeEnum.CHAT_REWARD, dto.getAmount(), true, originalBalance, walletAccount.getTotalBalance()); |
|
|
|
record.setRemark(dto.getRemark()); |
|
|
|
walletAccount.setRecordList(Collections.singletonList(record)); |
|
|
|
walletAccountAggregate.save(walletAccount); |
|
|
|
} |
|
|
|
} |