|
|
|
@ -21,7 +21,6 @@ import com.qniao.dam.domain.aggregate.virtualaccount.entity.VirtualAccount; |
|
|
|
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.domain.service.revenuereward.AcquireRevenueRewardDomainService; |
|
|
|
import com.qniao.dam.domain.service.virtualaccount.ConsumeVirtualAccountDomainService; |
|
|
|
import com.qniao.dam.domain.service.virtualaccount.CostGiftRewardDomainService; |
|
|
|
import com.qniao.dam.domain.service.virtualaccount.SettleOneOnOneRtcDomainService; |
|
|
|
@ -33,7 +32,6 @@ import com.qniao.dam.domian.aggregate.productspec.constant.ProductSpecTermNameEn |
|
|
|
import com.qniao.dam.domian.aggregate.rewardconfig.constant.RewardTypeEnum; |
|
|
|
import com.qniao.dam.domian.aggregate.virtualaccount.constant.VirtualAccountTradeTypeEnum; |
|
|
|
import com.qniao.dam.domian.aggregate.virtualaccount.event.ChannelCostGiftEvent; |
|
|
|
import com.qniao.dam.domian.aggregate.virtualaccount.event.VirtualAccountCostGiftEvent; |
|
|
|
import com.qniao.dam.domian.aggregate.walletaccount.constant.IdentityTypeEnum; |
|
|
|
import com.qniao.dam.domian.aggregate.walletaccount.constant.TradeSceneEnum; |
|
|
|
import com.qniao.dam.domian.aggregate.walletaccount.constant.TradeTypeEnum; |
|
|
|
@ -49,7 +47,6 @@ import com.qniao.dam.query.walletaccount.WalletAccountQueryService; |
|
|
|
import com.qniao.das.domian.aggregate.marriageinformation.MarriageInformation; |
|
|
|
import com.qniao.domain.BaseApplicationService; |
|
|
|
import com.qniao.domain.BaseDomainEvent; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
@ -126,7 +123,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
|
if (VirtualAccountTradeTypeEnum.CONNECT_CHANNEL.equals(dto.getTradeType())) { |
|
|
|
RewardConfig worthRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.VIRTUAL_ACCOUNT_WORTH); |
|
|
|
BigDecimal worthReward = BigDecimal.valueOf(productSpec.getUnitSellingPrice().intValue()).multiply(new BigDecimal(worthRewardConfig.getValue())); |
|
|
|
walletAccountApplicationService.handleChannelConnectReward(dto.getAnchorUserId(), dto.getChannelCreatorTodayCrossMicCount(),worthReward); |
|
|
|
walletAccountApplicationService.handleChannelConnectReward(dto.getAppId(),dto.getAnchorUserId(), dto.getChannelCreatorTodayCrossMicCount(),worthReward); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -179,7 +176,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
|
ProductSpec productSpec = productSpecDao.selectById(dto.getProductSpecId()); |
|
|
|
Integer costBalance = productSpec.getUnitSellingPrice().intValue() * dto.getQuantity(); |
|
|
|
if (virtualAccount != null && virtualAccount.getBalance() >= costBalance) { |
|
|
|
vo = handleIMGiftReward(virtualAccount, dto.getFromUserId(), dto.getToUserId(), productSpec, costBalance, dto.getQuantity()); |
|
|
|
vo = handleIMGiftReward(virtualAccount, dto.getAppId(),dto.getFromUserId(), dto.getToUserId(), productSpec, costBalance, dto.getQuantity()); |
|
|
|
} |
|
|
|
vo.setCostBalance(costBalance); |
|
|
|
} |
|
|
|
@ -188,6 +185,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public CostGiftVo handleIMGiftReward(VirtualAccount virtualAccount, |
|
|
|
Long appId, |
|
|
|
Long fromUserId, |
|
|
|
Long toUserId, |
|
|
|
ProductSpec productSpec, |
|
|
|
@ -217,7 +215,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
|
|
|
|
|
revenueReward.setRecordList(Collections.singletonList(revenueRewardRecord)); |
|
|
|
//钱包 |
|
|
|
WalletAccount walletAccount = walletAccountQueryService.queryByType(toUserId, IdentityTypeEnum.INDIVIDUAL); |
|
|
|
WalletAccount walletAccount = walletAccountQueryService.queryByType(appId, toUserId, IdentityTypeEnum.INDIVIDUAL); |
|
|
|
BigDecimal originalBalance = walletAccount.getTotalBalance(); |
|
|
|
walletAccount.setAvailableBalance(walletAccount.getAvailableBalance().add(revenue)); |
|
|
|
walletAccount.setTotalBalance(walletAccount.getAvailableBalance().add(walletAccount.getFrozenBalance())); |
|
|
|
@ -239,10 +237,10 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
|
if (virtualAccount != null && virtualAccount.getBalance() >= costBalance) { |
|
|
|
if (dto.getDirection() == 1) { |
|
|
|
//直接送主播 |
|
|
|
vo = handleChannelAnchorGiftReward(virtualAccount, dto.getFromUserId(), dto.getChannelCreatorId(), productSpec, costBalance, dto.getQuantity(), dto.getChannelCreatorTodayCrossMicCount()); |
|
|
|
vo = handleChannelAnchorGiftReward(virtualAccount,dto.getAppId(), dto.getFromUserId(), dto.getChannelCreatorId(), productSpec, costBalance, dto.getQuantity(), dto.getChannelCreatorTodayCrossMicCount()); |
|
|
|
} else { |
|
|
|
//直接送嘉宾 |
|
|
|
vo = handleChannelUserGiftReward(virtualAccount, dto.getFromUserId(), dto.getToUserId(), dto.getChannelCreatorId(), productSpec, costBalance, dto.getQuantity(), dto.getChannelCreatorTodayCrossMicCount()); |
|
|
|
vo = handleChannelUserGiftReward(virtualAccount, dto.getAppId(),dto.getFromUserId(), dto.getToUserId(), dto.getChannelCreatorId(), productSpec, costBalance, dto.getQuantity(), dto.getChannelCreatorTodayCrossMicCount()); |
|
|
|
} |
|
|
|
} |
|
|
|
vo.setCostBalance(costBalance); |
|
|
|
@ -254,7 +252,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public CostGiftVo handleChannelUserGiftReward(VirtualAccount virtualAccount, |
|
|
|
Long fromUserId, |
|
|
|
Long appId, Long fromUserId, |
|
|
|
Long toUserId, |
|
|
|
Long anchorId, |
|
|
|
ProductSpec productSpec, |
|
|
|
@ -281,7 +279,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
|
toRevenueRewardRecord.setContent("直播间礼物"); |
|
|
|
toRevenueReward.setRecordList(Collections.singletonList(toRevenueRewardRecord)); |
|
|
|
//钱包 |
|
|
|
WalletAccount toWalletAccount = walletAccountQueryService.queryByType(toUserId, IdentityTypeEnum.INDIVIDUAL); |
|
|
|
WalletAccount toWalletAccount = walletAccountQueryService.queryByType(appId, toUserId, IdentityTypeEnum.INDIVIDUAL); |
|
|
|
BigDecimal toOriginalBalance = toWalletAccount.getTotalBalance(); |
|
|
|
toWalletAccount.setAvailableBalance(toWalletAccount.getAvailableBalance().add(toRevenue)); |
|
|
|
toWalletAccount.setTotalBalance(toWalletAccount.getAvailableBalance().add(toWalletAccount.getFrozenBalance())); |
|
|
|
@ -304,7 +302,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
|
anchorRevenueRewardRecord.setContent("直播间礼物"); |
|
|
|
anchorRevenueReward.setRecordList(Collections.singletonList(anchorRevenueRewardRecord)); |
|
|
|
//钱包 |
|
|
|
WalletAccount anchorWalletAccount = walletAccountQueryService.queryByType(anchorId, IdentityTypeEnum.INDIVIDUAL); |
|
|
|
WalletAccount anchorWalletAccount = walletAccountQueryService.queryByType(appId, anchorId, IdentityTypeEnum.INDIVIDUAL); |
|
|
|
BigDecimal anchorOriginalBalance = anchorWalletAccount.getTotalBalance(); |
|
|
|
anchorWalletAccount.setAvailableBalance(anchorWalletAccount.getAvailableBalance().add(anchorRevenue)); |
|
|
|
anchorWalletAccount.setTotalBalance(anchorWalletAccount.getAvailableBalance().add(anchorWalletAccount.getFrozenBalance())); |
|
|
|
@ -323,6 +321,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public CostGiftVo handleChannelAnchorGiftReward(VirtualAccount virtualAccount, |
|
|
|
Long appId, |
|
|
|
Long fromUserId, |
|
|
|
Long toUserId, |
|
|
|
ProductSpec productSpec, |
|
|
|
@ -353,7 +352,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
|
|
|
|
|
revenueReward.setRecordList(Collections.singletonList(revenueRewardRecord)); |
|
|
|
//钱包 |
|
|
|
WalletAccount walletAccount = walletAccountQueryService.queryByType(toUserId, IdentityTypeEnum.INDIVIDUAL); |
|
|
|
WalletAccount walletAccount = walletAccountQueryService.queryByType(appId, toUserId, IdentityTypeEnum.INDIVIDUAL); |
|
|
|
BigDecimal originalBalance = walletAccount.getTotalBalance(); |
|
|
|
walletAccount.setAvailableBalance(walletAccount.getAvailableBalance().add(revenue)); |
|
|
|
walletAccount.setTotalBalance(walletAccount.getAvailableBalance().add(walletAccount.getFrozenBalance())); |
|
|
|
@ -472,7 +471,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
|
|
|
|
|
WalletAccount walletAccount = null; |
|
|
|
if (dto.getHasProfit()) { |
|
|
|
walletAccount = walletAccountQueryService.queryByType(dto.getProfitUserId(), IdentityTypeEnum.INDIVIDUAL); |
|
|
|
walletAccount = walletAccountQueryService.queryByType(dto.getAppId(), dto.getProfitUserId(), IdentityTypeEnum.INDIVIDUAL); |
|
|
|
RewardConfig worthRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.VIRTUAL_ACCOUNT_WORTH); |
|
|
|
RewardConfig rtcRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.RTC_PROFIT_BY_ONE_ON_ONE); |
|
|
|
|
|
|
|
|