|
|
@ -23,6 +23,7 @@ import com.qniao.dam.domain.aggregate.walletaccount.entity.WalletAccount; |
|
|
import com.qniao.dam.domain.aggregate.walletaccount.valueobj.WalletAccountRecord; |
|
|
import com.qniao.dam.domain.aggregate.walletaccount.valueobj.WalletAccountRecord; |
|
|
import com.qniao.dam.domain.service.virtualaccount.ConsumeVirtualAccountDomainService; |
|
|
import com.qniao.dam.domain.service.virtualaccount.ConsumeVirtualAccountDomainService; |
|
|
import com.qniao.dam.domain.service.virtualaccount.CostGiftRewardDomainService; |
|
|
import com.qniao.dam.domain.service.virtualaccount.CostGiftRewardDomainService; |
|
|
|
|
|
import com.qniao.dam.domain.service.virtualaccount.CostIMGiftRewardDomainService; |
|
|
import com.qniao.dam.domain.service.virtualaccount.SettleOneOnOneRtcDomainService; |
|
|
import com.qniao.dam.domain.service.virtualaccount.SettleOneOnOneRtcDomainService; |
|
|
import com.qniao.dam.domian.aggregate.order.constant.OrderBelongingEnum; |
|
|
import com.qniao.dam.domian.aggregate.order.constant.OrderBelongingEnum; |
|
|
import com.qniao.dam.domian.aggregate.order.constant.OrderStatusEnum; |
|
|
import com.qniao.dam.domian.aggregate.order.constant.OrderStatusEnum; |
|
|
@ -82,6 +83,8 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
@Resource |
|
|
@Resource |
|
|
private CostGiftRewardDomainService costGiftRewardDomainService; |
|
|
private CostGiftRewardDomainService costGiftRewardDomainService; |
|
|
@Resource |
|
|
@Resource |
|
|
|
|
|
private CostIMGiftRewardDomainService costIMGiftRewardDomainService; |
|
|
|
|
|
@Resource |
|
|
private ProductQueryService productQueryService; |
|
|
private ProductQueryService productQueryService; |
|
|
@Resource |
|
|
@Resource |
|
|
private RewardConfigQueryService rewardConfigQueryService; |
|
|
private RewardConfigQueryService rewardConfigQueryService; |
|
|
@ -123,7 +126,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
if (VirtualAccountTradeTypeEnum.CONNECT_CHANNEL.equals(dto.getTradeType())) { |
|
|
if (VirtualAccountTradeTypeEnum.CONNECT_CHANNEL.equals(dto.getTradeType())) { |
|
|
RewardConfig worthRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.VIRTUAL_ACCOUNT_WORTH); |
|
|
RewardConfig worthRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.VIRTUAL_ACCOUNT_WORTH); |
|
|
BigDecimal worthReward = BigDecimal.valueOf(productSpec.getUnitSellingPrice().intValue()).multiply(new BigDecimal(worthRewardConfig.getValue())); |
|
|
BigDecimal worthReward = BigDecimal.valueOf(productSpec.getUnitSellingPrice().intValue()).multiply(new BigDecimal(worthRewardConfig.getValue())); |
|
|
walletAccountApplicationService.handleChannelConnectReward(dto.getAppId(),dto.getAnchorUserId(), dto.getChannelCreatorTodayCrossMicCount(),worthReward); |
|
|
|
|
|
|
|
|
walletAccountApplicationService.handleChannelConnectReward(dto.getAppId(), dto.getAnchorUserId(), dto.getChannelCreatorTodayCrossMicCount(), worthReward); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -176,7 +179,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
ProductSpec productSpec = productSpecDao.selectById(dto.getProductSpecId()); |
|
|
ProductSpec productSpec = productSpecDao.selectById(dto.getProductSpecId()); |
|
|
Integer costBalance = productSpec.getUnitSellingPrice().intValue() * dto.getQuantity(); |
|
|
Integer costBalance = productSpec.getUnitSellingPrice().intValue() * dto.getQuantity(); |
|
|
if (virtualAccount != null && virtualAccount.getBalance() >= costBalance) { |
|
|
if (virtualAccount != null && virtualAccount.getBalance() >= costBalance) { |
|
|
vo = handleIMGiftReward(virtualAccount, dto.getAppId(),dto.getFromUserId(), dto.getToUserId(), productSpec, costBalance, dto.getQuantity()); |
|
|
|
|
|
|
|
|
vo = handleIMGiftReward(virtualAccount, dto.getAppId(), dto.getFromUserId(), dto.getToUserId(), productSpec, costBalance, dto.getQuantity()); |
|
|
} |
|
|
} |
|
|
vo.setCostBalance(costBalance); |
|
|
vo.setCostBalance(costBalance); |
|
|
} |
|
|
} |
|
|
@ -200,7 +203,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
//收益信息 |
|
|
//收益信息 |
|
|
RevenueReward revenueReward = revenueRewardQueryService.queryByUserId(appId, toUserId); |
|
|
RevenueReward revenueReward = revenueRewardQueryService.queryByUserId(appId, toUserId); |
|
|
if (Objects.isNull(revenueReward)) { |
|
|
if (Objects.isNull(revenueReward)) { |
|
|
revenueReward = RevenueReward.initUser(appId,toUserId); |
|
|
|
|
|
|
|
|
revenueReward = RevenueReward.initUser(appId, toUserId); |
|
|
} |
|
|
} |
|
|
RewardConfig worthRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.VIRTUAL_ACCOUNT_WORTH); |
|
|
RewardConfig worthRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.VIRTUAL_ACCOUNT_WORTH); |
|
|
RewardConfig giftRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.CHAT_PROFIT_BY_GIFT); |
|
|
RewardConfig giftRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.CHAT_PROFIT_BY_GIFT); |
|
|
@ -222,7 +225,8 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
WalletAccountRecord walletAccountRecord = WalletAccountRecord.build(TradeTypeEnum.IM_GIFT_REWARD, revenue, true, originalBalance, walletAccount.getTotalBalance()); |
|
|
WalletAccountRecord walletAccountRecord = WalletAccountRecord.build(TradeTypeEnum.IM_GIFT_REWARD, revenue, true, originalBalance, walletAccount.getTotalBalance()); |
|
|
walletAccount.setRecordList(Collections.singletonList(walletAccountRecord)); |
|
|
walletAccount.setRecordList(Collections.singletonList(walletAccountRecord)); |
|
|
|
|
|
|
|
|
costGiftRewardDomainService.handle(order, virtualAccount, costBalance, revenueReward, walletAccount); |
|
|
|
|
|
|
|
|
List<BaseDomainEvent> eventList = costIMGiftRewardDomainService.handle(order, virtualAccount, costBalance, revenueReward, walletAccount); |
|
|
|
|
|
this.sendEvent(eventList); |
|
|
vo.setSuccess(true); |
|
|
vo.setSuccess(true); |
|
|
return vo; |
|
|
return vo; |
|
|
} |
|
|
} |
|
|
@ -237,10 +241,10 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
if (virtualAccount != null && virtualAccount.getBalance() >= costBalance) { |
|
|
if (virtualAccount != null && virtualAccount.getBalance() >= costBalance) { |
|
|
if (dto.getDirection() == 1) { |
|
|
if (dto.getDirection() == 1) { |
|
|
//直接送主播 |
|
|
//直接送主播 |
|
|
vo = handleChannelAnchorGiftReward(virtualAccount,dto.getAppId(), 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 { |
|
|
} else { |
|
|
//直接送嘉宾 |
|
|
//直接送嘉宾 |
|
|
vo = handleChannelUserGiftReward(virtualAccount, dto.getAppId(),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); |
|
|
vo.setCostBalance(costBalance); |
|
|
@ -268,7 +272,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
//收益信息 |
|
|
//收益信息 |
|
|
RevenueReward toRevenueReward = revenueRewardQueryService.queryByUserId(appId, toUserId); |
|
|
RevenueReward toRevenueReward = revenueRewardQueryService.queryByUserId(appId, toUserId); |
|
|
if (Objects.isNull(toRevenueReward)) { |
|
|
if (Objects.isNull(toRevenueReward)) { |
|
|
toRevenueReward = RevenueReward.initUser(appId,toUserId); |
|
|
|
|
|
|
|
|
toRevenueReward = RevenueReward.initUser(appId, toUserId); |
|
|
} |
|
|
} |
|
|
RewardConfig worthRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.VIRTUAL_ACCOUNT_WORTH); |
|
|
RewardConfig worthRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.VIRTUAL_ACCOUNT_WORTH); |
|
|
//营收额 todo |
|
|
//营收额 todo |
|
|
@ -289,7 +293,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
//收益信息 |
|
|
//收益信息 |
|
|
RevenueReward anchorRevenueReward = revenueRewardQueryService.queryByUserId(appId, anchorId); |
|
|
RevenueReward anchorRevenueReward = revenueRewardQueryService.queryByUserId(appId, anchorId); |
|
|
if (Objects.isNull(anchorRevenueReward)) { |
|
|
if (Objects.isNull(anchorRevenueReward)) { |
|
|
anchorRevenueReward = RevenueReward.initUser(appId,anchorId); |
|
|
|
|
|
|
|
|
anchorRevenueReward = RevenueReward.initUser(appId, anchorId); |
|
|
} |
|
|
} |
|
|
//营收额 |
|
|
//营收额 |
|
|
BigDecimal giftRewardPct = rewardConfigQueryService.queryMatchmakerChannelGiftPct(anchorId, channelCreatorTodayCrossMicCount); |
|
|
BigDecimal giftRewardPct = rewardConfigQueryService.queryMatchmakerChannelGiftPct(anchorId, channelCreatorTodayCrossMicCount); |
|
|
@ -337,7 +341,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
//收益信息 |
|
|
//收益信息 |
|
|
RevenueReward revenueReward = revenueRewardQueryService.queryByUserId(appId, toUserId); |
|
|
RevenueReward revenueReward = revenueRewardQueryService.queryByUserId(appId, toUserId); |
|
|
if (Objects.isNull(revenueReward)) { |
|
|
if (Objects.isNull(revenueReward)) { |
|
|
revenueReward = RevenueReward.initUser(appId,toUserId); |
|
|
|
|
|
|
|
|
revenueReward = RevenueReward.initUser(appId, toUserId); |
|
|
} |
|
|
} |
|
|
RewardConfig worthRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.VIRTUAL_ACCOUNT_WORTH); |
|
|
RewardConfig worthRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.VIRTUAL_ACCOUNT_WORTH); |
|
|
//营收额 todo |
|
|
//营收额 todo |
|
|
@ -475,7 +479,7 @@ public class VirtualAccountApplicationService extends BaseApplicationService { |
|
|
RewardConfig worthRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.VIRTUAL_ACCOUNT_WORTH); |
|
|
RewardConfig worthRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.VIRTUAL_ACCOUNT_WORTH); |
|
|
RewardConfig rtcRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.RTC_PROFIT_BY_ONE_ON_ONE); |
|
|
RewardConfig rtcRewardConfig = rewardConfigQueryService.queryByRewardType(RewardTypeEnum.RTC_PROFIT_BY_ONE_ON_ONE); |
|
|
|
|
|
|
|
|
BigDecimal income = BigDecimal.valueOf(dto.getConsumeBalance()).multiply(new BigDecimal(worthRewardConfig.getValue())); |
|
|
|
|
|
|
|
|
BigDecimal income = BigDecimal.valueOf(dto.getConsumeBalance()).multiply(new BigDecimal(worthRewardConfig.getValue())); |
|
|
income = rtcRewardConfig.calculateReward(income); |
|
|
income = rtcRewardConfig.calculateReward(income); |
|
|
|
|
|
|
|
|
if (RtcChannelTypeEnum.ONE_ON_ONE_VOICE.equals(dto.getRtcChannelType())) { |
|
|
if (RtcChannelTypeEnum.ONE_ON_ONE_VOICE.equals(dto.getRtcChannelType())) { |
|
|
|