|
|
@ -0,0 +1,102 @@ |
|
|
|
|
|
package com.qniao.dam.infrastructure.persistent.repository.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
|
import com.qniao.dam.application.service.marriagebounty.repository.MarriageBountyOrderRepository; |
|
|
|
|
|
import com.qniao.dam.domain.aggregate.marriagebounty.entity.MarriageBountyOrder; |
|
|
|
|
|
import com.qniao.dam.domain.aggregate.marriagebounty.entity.MarriageBountyOrderReward; |
|
|
|
|
|
import com.qniao.dam.domain.aggregate.marriagebounty.valueobj.MarriageBountyOrderProductRecord; |
|
|
|
|
|
import com.qniao.dam.domain.aggregate.marriagebounty.valueobj.MarriageBountyOrderProductSpecRecord; |
|
|
|
|
|
import com.qniao.dam.domain.aggregate.marriagebounty.valueobj.MarriageBountyOrderRel; |
|
|
|
|
|
import com.qniao.dam.domain.aggregate.marriagebounty.valueobj.MarriageBountyOrderRewardReceiveRecord; |
|
|
|
|
|
import com.qniao.dam.infrastructure.persistent.dao.domain.*; |
|
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
|
|
public class MarriageBountyOrderRepositoryImpl implements MarriageBountyOrderRepository { |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private MarriageBountyOrderDao marriageBountyOrderDao; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private MarriageBountyOrderRelDao marriageBountyOrderRelDao; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private MarriageBountyOrderRewardDao marriageBountyOrderRewardDao; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private MarriageBountyOrderRewardReceiveRecordDao marriageBountyOrderRewardReceiveRecordDao; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private MarriageBountyOrderProductRecordDao marriageBountyOrderProductRecordDao; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private MarriageBountyOrderProductSpecRecordDao marriageBountyOrderProductSpecRecordDao; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public MarriageBountyOrder load(Long id) { |
|
|
|
|
|
MarriageBountyOrder marriageBountyOrder = marriageBountyOrderDao.selectById(id); |
|
|
|
|
|
if (Objects.nonNull(marriageBountyOrder)) { |
|
|
|
|
|
marriageBountyOrder.setOrderRelList(marriageBountyOrderRelDao.selectList(new LambdaQueryWrapper<MarriageBountyOrderRel>() |
|
|
|
|
|
.eq(MarriageBountyOrderRel::getMarriageBountyOrderId, id))); |
|
|
|
|
|
marriageBountyOrder.setOrderRewardList(marriageBountyOrderRewardDao.selectList(new LambdaQueryWrapper<MarriageBountyOrderReward>() |
|
|
|
|
|
.eq(MarriageBountyOrderReward::getMarriageBountyOrderId, id))); |
|
|
|
|
|
marriageBountyOrder.getOrderRewardList().forEach(orderReward -> { |
|
|
|
|
|
orderReward.setRewardReceiveRecordList(marriageBountyOrderRewardReceiveRecordDao.selectList(new LambdaQueryWrapper<MarriageBountyOrderRewardReceiveRecord>() |
|
|
|
|
|
.eq(MarriageBountyOrderRewardReceiveRecord::getMarriageBountyOrderRewardId, orderReward.getId()))); |
|
|
|
|
|
}); |
|
|
|
|
|
marriageBountyOrder.setProductRecordList(marriageBountyOrderProductRecordDao.selectList(new LambdaQueryWrapper<MarriageBountyOrderProductRecord>() |
|
|
|
|
|
.eq(MarriageBountyOrderProductRecord::getMarriageBountyOrderId, id))); |
|
|
|
|
|
marriageBountyOrder.getProductRecordList().forEach(productRecord -> { |
|
|
|
|
|
productRecord.setProductSpecRecordList(marriageBountyOrderProductSpecRecordDao.selectList(new LambdaQueryWrapper<MarriageBountyOrderProductSpecRecord>() |
|
|
|
|
|
.eq(MarriageBountyOrderProductSpecRecord::getMarriageBountyOrderProductRecordId, productRecord.getId()))); |
|
|
|
|
|
; |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
return marriageBountyOrder; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
@Override |
|
|
|
|
|
public Long save(MarriageBountyOrder entity) { |
|
|
|
|
|
if (Objects.isNull(entity.getId()) || Objects.isNull(marriageBountyOrderDao.selectById(entity.getId()))) { |
|
|
|
|
|
marriageBountyOrderDao.insert(entity); |
|
|
|
|
|
} else { |
|
|
|
|
|
marriageBountyOrderDao.updateById(entity); |
|
|
|
|
|
} |
|
|
|
|
|
if (CollUtil.isNotEmpty(entity.getOrderRelList())) { |
|
|
|
|
|
entity.getOrderRelList().forEach(orderRel -> { |
|
|
|
|
|
orderRel.setMarriageBountyOrderId(entity.getId()); |
|
|
|
|
|
marriageBountyOrderRelDao.insert(orderRel); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
if (CollUtil.isNotEmpty(entity.getProductRecordList())) { |
|
|
|
|
|
entity.getProductRecordList().forEach(productRecord -> { |
|
|
|
|
|
productRecord.setMarriageBountyOrderId(entity.getId()); |
|
|
|
|
|
marriageBountyOrderProductRecordDao.insert(productRecord); |
|
|
|
|
|
if (CollUtil.isNotEmpty(productRecord.getProductSpecRecordList())) { |
|
|
|
|
|
productRecord.getProductSpecRecordList().forEach(productSpecRecord -> { |
|
|
|
|
|
productSpecRecord.setMarriageBountyOrderProductRecordId(productRecord.getId()); |
|
|
|
|
|
marriageBountyOrderProductSpecRecordDao.insert(productSpecRecord); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
if (CollUtil.isNotEmpty(entity.getInsertOrderRewardList())) { |
|
|
|
|
|
entity.getInsertOrderRewardList().forEach(orderReward -> { |
|
|
|
|
|
orderReward.setMarriageBountyOrderId(entity.getId()); |
|
|
|
|
|
marriageBountyOrderRewardDao.insert(orderReward); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
if (CollUtil.isNotEmpty(entity.getUpdateOrderRewardList())) { |
|
|
|
|
|
entity.getUpdateOrderRewardList().forEach(orderReward -> { |
|
|
|
|
|
orderReward.setMarriageBountyOrderId(entity.getId()); |
|
|
|
|
|
marriageBountyOrderRewardDao.updateById(orderReward); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
if (CollUtil.isNotEmpty(entity.getDeleteOrderRewardList())) { |
|
|
|
|
|
marriageBountyOrderRewardDao.deleteBatchIds(entity.getDeleteOrderRewardList().stream().map(MarriageBountyOrderReward::getId).collect(Collectors.toList())); |
|
|
|
|
|
} |
|
|
|
|
|
return entity.getId(); |
|
|
|
|
|
} |
|
|
|
|
|
} |