|
|
@@ -2,25 +2,39 @@ package com.yc.ship.module.product.service.pricevoyage;
|
|
|
|
|
|
import com.yc.ship.framework.common.pojo.PageResult;
|
|
|
import com.yc.ship.framework.common.util.collection.CollectionUtils;
|
|
|
+import com.yc.ship.framework.common.util.collection.MapUtils;
|
|
|
import com.yc.ship.framework.common.util.object.BeanUtils;
|
|
|
+import com.yc.ship.module.product.controller.admin.pricetemplate.vo.*;
|
|
|
import com.yc.ship.module.product.controller.admin.pricevoyage.vo.PriceVoyagePageReqVO;
|
|
|
+import com.yc.ship.module.product.controller.admin.pricevoyage.vo.PriceVoyageRespVO;
|
|
|
import com.yc.ship.module.product.controller.admin.pricevoyage.vo.PriceVoyageSaveReqVO;
|
|
|
import com.yc.ship.module.product.controller.app.voyage.vo.AppRoomModelPriceRespVO;
|
|
|
import com.yc.ship.module.product.controller.app.voyage.vo.AppVoyageCalendarPriceReqVO;
|
|
|
import com.yc.ship.module.product.controller.app.voyage.vo.AppVoyageCalendarPriceRespVO;
|
|
|
import com.yc.ship.module.product.controller.app.voyage.vo.AppVoyageRespVO;
|
|
|
+import com.yc.ship.module.product.dal.dataobject.basicpricearea.BasicPriceAreaDO;
|
|
|
import com.yc.ship.module.product.dal.dataobject.pricearea.PriceAreaDO;
|
|
|
import com.yc.ship.module.product.dal.dataobject.pricefloor.PriceFloorDO;
|
|
|
import com.yc.ship.module.product.dal.dataobject.priceroommodel.PriceRoomModelDO;
|
|
|
+import com.yc.ship.module.product.dal.dataobject.priceroommodeltype.PriceRoomModelTypeDO;
|
|
|
import com.yc.ship.module.product.dal.dataobject.pricesinglesetting.PriceSingleSettingDO;
|
|
|
import com.yc.ship.module.product.dal.dataobject.pricespu.PriceSpuDO;
|
|
|
import com.yc.ship.module.product.dal.dataobject.pricevoyage.PriceVoyageDO;
|
|
|
+import com.yc.ship.module.product.dal.mysql.basicpricearea.BasicPriceAreaMapper;
|
|
|
import com.yc.ship.module.product.dal.mysql.pricearea.PriceAreaMapper;
|
|
|
import com.yc.ship.module.product.dal.mysql.pricefloor.PriceFloorMapper;
|
|
|
import com.yc.ship.module.product.dal.mysql.priceroommodel.PriceRoomModelMapper;
|
|
|
+import com.yc.ship.module.product.dal.mysql.priceroommodeltype.PriceRoomModelTypeMapper;
|
|
|
import com.yc.ship.module.product.dal.mysql.pricesinglesetting.PriceSingleSettingMapper;
|
|
|
import com.yc.ship.module.product.dal.mysql.pricespu.PriceSpuMapper;
|
|
|
import com.yc.ship.module.product.dal.mysql.pricevoyage.PriceVoyageMapper;
|
|
|
+import com.yc.ship.module.product.enums.ErrorCodeConstants;
|
|
|
+import com.yc.ship.module.product.service.pricearea.PriceAreaService;
|
|
|
+import com.yc.ship.module.product.service.priceroommodel.PriceRoomModelService;
|
|
|
+import com.yc.ship.module.product.service.pricespu.PriceSpuService;
|
|
|
+import com.yc.ship.module.resource.controller.admin.roommodel.vo.ResourceRoomModelRespVO;
|
|
|
+import com.yc.ship.module.resource.dal.dataobject.roommodel.ResourceRoomModelDO;
|
|
|
+import com.yc.ship.module.resource.service.roommodel.ResourceRoomModelService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
@@ -28,6 +42,7 @@ import org.springframework.validation.annotation.Validated;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import static com.yc.ship.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static com.yc.ship.module.product.enums.ErrorCodeConstants.*;
|
|
|
@@ -59,6 +74,25 @@ public class PriceVoyageServiceImpl implements PriceVoyageService {
|
|
|
@Resource
|
|
|
private PriceSpuMapper priceSpuMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private BasicPriceAreaMapper basicPriceAreaMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PriceRoomModelTypeMapper priceRoomModelTypeMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PriceRoomModelService priceRoomModelService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PriceSpuService priceSpuService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ResourceRoomModelService roomModelService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PriceAreaService priceAreaService;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Long createPriceVoyage(PriceVoyageSaveReqVO createReqVO) {
|
|
|
@@ -105,8 +139,32 @@ public class PriceVoyageServiceImpl implements PriceVoyageService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PriceVoyageDO getPriceVoyage(Long id) {
|
|
|
- return priceVoyageMapper.selectById(id);
|
|
|
+ public PriceVoyageRespVO getPriceVoyage(Long id) {
|
|
|
+ PriceVoyageDO priceVoyageDO = priceVoyageMapper.selectById(id);
|
|
|
+ PriceVoyageRespVO respVO = BeanUtils.toBean(priceVoyageDO, PriceVoyageRespVO.class);
|
|
|
+ List<PriceRoomModelDO> roomModelDOList = priceRoomModelService.getListByObjectId(id);
|
|
|
+ List<PriceRoomModelRespVO> priceRoomModelRespVOS = BeanUtils.toBean(roomModelDOList, PriceRoomModelRespVO.class);
|
|
|
+ List<PriceSingleSettingDO> singleSettingList = priceSingleSettingMapper.selectByObjectId(id);
|
|
|
+ List<PriceSingleSettingRespVO> priceSingleSettingRespVOS = BeanUtils.toBean(singleSettingList, PriceSingleSettingRespVO.class);
|
|
|
+ Map<Long, PriceSingleSettingRespVO> singleSettingRespVOMap = CollectionUtils.convertMap(priceSingleSettingRespVOS, PriceSingleSettingRespVO::getRoomModelId);
|
|
|
+ List<PriceRoomModelTypeDO> roomModelTypeList = priceRoomModelTypeMapper.selectByObjectId(id);
|
|
|
+ Map<Long, List<PriceRoomModelTypeDO>> roomModelTypeMap = CollectionUtils.convertMultiMap(roomModelTypeList, PriceRoomModelTypeDO::getRoomModelId);
|
|
|
+ priceRoomModelRespVOS.stream().forEach(item -> {
|
|
|
+ MapUtils.findAndThen(singleSettingRespVOMap, item.getRoomModelId(), item::setSingleSetting);
|
|
|
+ MapUtils.findAndThen(roomModelTypeMap, item.getRoomModelId(), itemTypeList -> item.setRoomModelTypeList(BeanUtils.toBean(itemTypeList, PriceRoomModelTypeRespVO.class)));
|
|
|
+ });
|
|
|
+ respVO.setRoomModelList(priceRoomModelRespVOS);
|
|
|
+ List<PriceFloorDO> floorDOList = priceFloorMapper.selectListByObjectId(id);
|
|
|
+ respVO.setFloorList(BeanUtils.toBean(floorDOList, PriceFloorRespVO.class));
|
|
|
+ List<PriceAreaDO> areaList = priceAreaMapper.selectListByObjectId(id);
|
|
|
+ respVO.setAreaList(BeanUtils.toBean(areaList, PriceAreaRespVO.class));
|
|
|
+ //区域基准价
|
|
|
+ List<BasicPriceAreaDO> basicPriceAreaList = basicPriceAreaMapper.selectListByObjectId(id);
|
|
|
+ respVO.setBasicAreaList(BeanUtils.toBean(basicPriceAreaList, BasicPriceAreaRespVO.class));
|
|
|
+ //附加产品
|
|
|
+ List<PriceSpuRespVO> spuList = priceSpuService.getListByObjectId(id);
|
|
|
+ respVO.setSpuList(spuList);
|
|
|
+ return respVO;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -115,8 +173,48 @@ public class PriceVoyageServiceImpl implements PriceVoyageService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PriceVoyageDO getByVoyageId(Long voyageId) {
|
|
|
- return priceVoyageMapper.selectByVoyageId(voyageId);
|
|
|
+ public PriceVoyageRespVO getByVoyageId(Long voyageId) {
|
|
|
+ PriceVoyageDO priceVoyage = priceVoyageMapper.selectByVoyageId(voyageId);
|
|
|
+ if(priceVoyage == null) {
|
|
|
+ throw exception(ErrorCodeConstants.PRICE_VOYAGE_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ Long id = priceVoyage.getId();
|
|
|
+ PriceVoyageRespVO respVO = BeanUtils.toBean(priceVoyage, PriceVoyageRespVO.class);
|
|
|
+ List<PriceRoomModelDO> roomModelDOList = priceRoomModelService.getListByObjectId(id);
|
|
|
+ List<PriceRoomModelRespVO> priceRoomModelRespVOS = BeanUtils.toBean(roomModelDOList, PriceRoomModelRespVO.class);
|
|
|
+ List<PriceSingleSettingDO> singleSettingDO = priceSingleSettingMapper.selectByObjectId(id);
|
|
|
+ List<PriceSingleSettingRespVO> priceSingleSettingRespVOS = BeanUtils.toBean(singleSettingDO, PriceSingleSettingRespVO.class);
|
|
|
+ Map<Long, PriceSingleSettingRespVO> settingRespVOMap = CollectionUtils.convertMap(priceSingleSettingRespVOS, PriceSingleSettingRespVO::getRoomModelId);
|
|
|
+
|
|
|
+ List<Long> roomModelIds = CollectionUtils.convertList(priceRoomModelRespVOS, item -> item.getRoomModelId());
|
|
|
+ List<ResourceRoomModelDO> roomModelDOS = roomModelService.getList(roomModelIds);
|
|
|
+ Map<Long, ResourceRoomModelDO> resourceRoomModelDOMap = CollectionUtils.convertMap(roomModelDOS, item -> item.getId());
|
|
|
+ List<PriceRoomModelTypeDO> roomModelTypeList = priceRoomModelTypeMapper.selectByObjectId(id);
|
|
|
+ Map<Long, List<PriceRoomModelTypeDO>> roomModelTypeMap = CollectionUtils.convertMultiMap(roomModelTypeList, PriceRoomModelTypeDO::getRoomModelId);
|
|
|
+ priceRoomModelRespVOS.stream().forEach(item -> {
|
|
|
+ MapUtils.findAndThen(roomModelTypeMap, item.getRoomModelId(), itemTypeList -> item.setRoomModelTypeList(BeanUtils.toBean(itemTypeList, PriceRoomModelTypeRespVO.class)));
|
|
|
+ MapUtils.findAndThen(settingRespVOMap, item.getRoomModelId(), item::setSingleSetting);
|
|
|
+ item.setSingleSetting(settingRespVOMap.get(item.getRoomModelId()));
|
|
|
+ if(resourceRoomModelDOMap.get(item.getRoomModelId()) != null) {
|
|
|
+ item.setRoomModel(BeanUtils.toBean(resourceRoomModelDOMap.get(item.getRoomModelId()), ResourceRoomModelRespVO.class));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ respVO.setRoomModelList(priceRoomModelRespVOS);
|
|
|
+ List<PriceFloorDO> floorDOList = priceFloorMapper.selectListByObjectId(id);
|
|
|
+ respVO.setFloorList(BeanUtils.toBean(floorDOList, PriceFloorRespVO.class));
|
|
|
+ List<PriceAreaDO> areaList = priceAreaMapper.selectListByObjectId(id);
|
|
|
+ respVO.setAreaList(BeanUtils.toBean(areaList, PriceAreaRespVO.class));
|
|
|
+ List<PriceCountryRespVO> countryList = priceAreaService.getCountryPriceByObjectId(id);
|
|
|
+ respVO.setCountryList(countryList);
|
|
|
+ //区域基准价
|
|
|
+ List<BasicPriceAreaDO> basicPriceAreaList = basicPriceAreaMapper.selectListByObjectId(id);
|
|
|
+ respVO.setBasicAreaList(BeanUtils.toBean(basicPriceAreaList, BasicPriceAreaRespVO.class));
|
|
|
+ List<BasicPriceCountryRespVO> basicPriceCountryRespVOS = basicPriceAreaMapper.selectCountryPriceByObjectId(id);
|
|
|
+ respVO.setBasicCountryList(basicPriceCountryRespVOS);
|
|
|
+ //附加产品
|
|
|
+ List<PriceSpuRespVO> spuList = priceSpuService.getListByObjectId(id);
|
|
|
+ respVO.setSpuList(spuList);
|
|
|
+ return respVO;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -145,6 +243,8 @@ public class PriceVoyageServiceImpl implements PriceVoyageService {
|
|
|
|
|
|
//插入单人票设置
|
|
|
List<PriceSingleSettingDO> singleSettingList = new ArrayList<>();
|
|
|
+ //插入房型入住价格模式
|
|
|
+ List<PriceRoomModelTypeDO> roomModelTypeDOList = new ArrayList<>();
|
|
|
roomModelList.stream().forEach(roomModel -> {
|
|
|
PriceSingleSettingDO singleSetting = roomModel.getSingleSetting();
|
|
|
if(singleSetting != null) {
|
|
|
@@ -152,10 +252,22 @@ public class PriceVoyageServiceImpl implements PriceVoyageService {
|
|
|
singleSetting.setObjectId(objectId);
|
|
|
singleSettingList.add(singleSetting);
|
|
|
}
|
|
|
+ List<PriceRoomModelTypeDO> roomModelTypeList = roomModel.getRoomModelTypeList();
|
|
|
+ if(!CollectionUtils.isAnyEmpty(roomModelTypeList)) {
|
|
|
+ roomModelTypeList.stream().forEach(roomModelType -> {
|
|
|
+ roomModelType.setRoomModelId(roomModel.getRoomModelId());
|
|
|
+ roomModelType.setRoomModelName(roomModel.getRoomModelName());
|
|
|
+ roomModelType.setObjectId(objectId);
|
|
|
+ roomModelTypeDOList.add(roomModelType);
|
|
|
+ });
|
|
|
+ }
|
|
|
});
|
|
|
if(singleSettingList.size() > 0) {
|
|
|
priceSingleSettingMapper.insertBatch(singleSettingList);
|
|
|
}
|
|
|
+ if(roomModelTypeDOList.size() > 0) {
|
|
|
+ priceRoomModelTypeMapper.insertBatch(roomModelTypeDOList);
|
|
|
+ }
|
|
|
//插入区域加价
|
|
|
List<PriceAreaDO> areaList = vo.getAreaList();
|
|
|
List<PriceAreaDO> insertAreaList = new ArrayList<>();
|
|
|
@@ -174,6 +286,26 @@ public class PriceVoyageServiceImpl implements PriceVoyageService {
|
|
|
});
|
|
|
priceAreaMapper.insertBatch(insertAreaList);
|
|
|
|
|
|
+ // 插入区域基准价
|
|
|
+ List<BasicPriceAreaDO> basicAreaList = vo.getBasicAreaList();
|
|
|
+ List<BasicPriceAreaDO> insertBasicAreaList = new ArrayList<>();
|
|
|
+ basicAreaList.stream().forEach(area -> {
|
|
|
+ area.setObjectId(objectId);
|
|
|
+ insertBasicAreaList.add(area);
|
|
|
+ List<BasicPriceAreaDO> children = area.getChildren();
|
|
|
+ if (children != null) {
|
|
|
+ children.stream().forEach(child -> {
|
|
|
+ child.setObjectId(objectId);
|
|
|
+ child.setParentAreaId(area.getAreaId());
|
|
|
+ child.setParentAreaName(area.getAreaName());
|
|
|
+ insertBasicAreaList.add(child);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if(insertBasicAreaList.size() > 0) {
|
|
|
+ basicPriceAreaMapper.insertBatch(insertBasicAreaList);
|
|
|
+ }
|
|
|
+
|
|
|
// 插入附加产品
|
|
|
List<PriceSpuDO> spuList = vo.getSpuList();
|
|
|
if(!CollectionUtils.isAnyEmpty(spuList)) {
|
|
|
@@ -190,6 +322,8 @@ public class PriceVoyageServiceImpl implements PriceVoyageService {
|
|
|
priceSingleSettingMapper.deleteByObjectId(objectId);
|
|
|
priceAreaMapper.deleteByObjectId(objectId);
|
|
|
priceSpuMapper.deleteByObjectId(objectId);
|
|
|
+ basicPriceAreaMapper.deleteByObjectId(objectId);
|
|
|
+ priceRoomModelTypeMapper.deleteByObjectId(objectId);
|
|
|
}
|
|
|
|
|
|
}
|