|
|
@ -1,13 +1,20 @@ |
|
|
package com.qniao.dam.domain.service.virtualaccount; |
|
|
package com.qniao.dam.domain.service.virtualaccount; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
|
import com.qniao.dam.domain.aggregate.revenuereward.entity.RevenueReward; |
|
|
import com.qniao.dam.domain.aggregate.virtualaccount.VirtualAccountAggregate; |
|
|
import com.qniao.dam.domain.aggregate.virtualaccount.VirtualAccountAggregate; |
|
|
import com.qniao.dam.domain.aggregate.virtualaccount.entity.VirtualAccount; |
|
|
import com.qniao.dam.domain.aggregate.virtualaccount.entity.VirtualAccount; |
|
|
import com.qniao.dam.domain.aggregate.walletaccount.WalletAccountAggregate; |
|
|
import com.qniao.dam.domain.aggregate.walletaccount.WalletAccountAggregate; |
|
|
import com.qniao.dam.domain.aggregate.walletaccount.entity.WalletAccount; |
|
|
import com.qniao.dam.domain.aggregate.walletaccount.entity.WalletAccount; |
|
|
|
|
|
import com.qniao.dam.domian.aggregate.revenuereward.event.RevenueRewardRecordCreatedEvent; |
|
|
|
|
|
import com.qniao.domain.BaseDomainEvent; |
|
|
|
|
|
import com.qniao.framework.utils.TypeConvertUtils; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.List; |
|
|
import java.util.Objects; |
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
@Service |
|
|
@Service |
|
|
@ -19,11 +26,25 @@ public class SettleOneOnOneRtcDomainService { |
|
|
private WalletAccountAggregate walletAccountAggregate; |
|
|
private WalletAccountAggregate walletAccountAggregate; |
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void handle(VirtualAccount virtualAccount, |
|
|
|
|
|
WalletAccount walletAccount) { |
|
|
|
|
|
|
|
|
public List<BaseDomainEvent> handle(VirtualAccount virtualAccount, |
|
|
|
|
|
WalletAccount walletAccount, |
|
|
|
|
|
RevenueReward revenueReward) { |
|
|
|
|
|
List<BaseDomainEvent> eventList = new ArrayList<>(); |
|
|
virtualAccountAggregate.edit(virtualAccount); |
|
|
virtualAccountAggregate.edit(virtualAccount); |
|
|
if (Objects.nonNull(walletAccount)) { |
|
|
if (Objects.nonNull(walletAccount)) { |
|
|
walletAccountAggregate.save(walletAccount); |
|
|
walletAccountAggregate.save(walletAccount); |
|
|
|
|
|
|
|
|
|
|
|
walletAccount.getRecordList().forEach(record -> { |
|
|
|
|
|
record.setAssociateId(revenueReward.getRecordList().get(0).getId()); |
|
|
|
|
|
}); |
|
|
|
|
|
walletAccountAggregate.save(walletAccount); |
|
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(revenueReward.getRecordList())) { |
|
|
|
|
|
revenueReward.getRecordList().forEach(record -> { |
|
|
|
|
|
eventList.add(TypeConvertUtils.convert(record, RevenueRewardRecordCreatedEvent.class)); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
return eventList; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |