|
@@ -7,6 +7,7 @@ import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
import com.sd.business.entity.bom.dto.BomSpecPriceQueryDto;
|
|
|
import com.sd.business.entity.bom.enums.BomSpecPriceConfigCodeEnum;
|
|
|
import com.sd.business.entity.bom.po.BomSpecPriceConfig;
|
|
|
+import com.sd.business.entity.bom.vo.BomSpecPriceDetailsVo;
|
|
|
import com.sd.business.mapper.bom.BomSpecPriceConfigMapper;
|
|
|
import com.sd.business.service.bom.BomSpecPriceConfigService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -58,61 +59,73 @@ public class BomSpecPriceConfigServiceImpl extends ServiceImpl<BomSpecPriceConfi
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public BigDecimal getBomSpecPrice(BomSpecPriceQueryDto dto) {
|
|
|
+ public BomSpecPriceDetailsVo getBomSpecPrice(BomSpecPriceQueryDto dto) {
|
|
|
// 计算公式=(基材价格+品类+特性+颜色价格)*[(长+裁切配置)*(宽+裁切配置)/10000]*(厚度+压纹配置)*(1+损耗)+加工费+运费
|
|
|
+ BomSpecPriceDetailsVo vo = new BomSpecPriceDetailsVo();
|
|
|
+ vo.setLength(dto.getLength());
|
|
|
+ vo.setWidth(dto.getWidth());
|
|
|
+ vo.setHeight(dto.getHeight());
|
|
|
List<BomSpecPriceConfig> list = this.list();
|
|
|
Map<Long, BomSpecPriceConfig> configDetailMap = list.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
|
Map<String, List<BomSpecPriceConfig>> configCodeMap = list.stream().collect(Collectors.groupingBy(BomSpecPriceConfig::getCode));
|
|
|
|
|
|
- // 计算bom每平方价格
|
|
|
- BigDecimal price = BigDecimal.ZERO;
|
|
|
// 等级
|
|
|
BomSpecPriceConfig levelDetail = configDetailMap.get(dto.getLevelConfigId());
|
|
|
- price = price.add(levelDetail.getPrice());
|
|
|
+ vo.setBaseMaterialPrice(levelDetail.getPrice());
|
|
|
|
|
|
// 品类
|
|
|
BomSpecPriceConfig categoryDetail = configDetailMap.get(dto.getCategoryConfigId());
|
|
|
- price = price.add(categoryDetail.getPrice());
|
|
|
+ vo.setCategoryPrice(categoryDetail.getPrice());
|
|
|
|
|
|
// 特性
|
|
|
+ BigDecimal characterPrice = BigDecimal.ZERO;
|
|
|
if (StrUtil.isNotBlank(dto.getCharacterConfigIds())) {
|
|
|
String[] characterConfigIdArr = dto.getCharacterConfigIds().split(",");
|
|
|
for (String configId : characterConfigIdArr) {
|
|
|
BomSpecPriceConfig embossingDetail = configDetailMap.get(Long.parseLong(configId));
|
|
|
- price = price.add(embossingDetail.getPrice());
|
|
|
+ characterPrice = characterPrice.add(embossingDetail.getPrice());
|
|
|
}
|
|
|
}
|
|
|
+ vo.setCharacterPrice(characterPrice);
|
|
|
|
|
|
// 颜色
|
|
|
+ BigDecimal colourPrice = BigDecimal.ZERO;
|
|
|
String colourConfigIds = dto.getColourConfigIds();
|
|
|
List<String> colourConfigIdList = Arrays.asList(colourConfigIds.split(","));
|
|
|
for (String configId : colourConfigIdList) {
|
|
|
BomSpecPriceConfig colourDetail = configDetailMap.get(Long.parseLong(configId));
|
|
|
- BigDecimal colourPrice = colourDetail.getPrice();
|
|
|
if (colourConfigIdList.size() > 1) {
|
|
|
- colourPrice = colourPrice.divide(BigDecimal.valueOf(2), 2, RoundingMode.HALF_UP);
|
|
|
+ colourPrice = colourPrice.add(colourDetail.getPrice().divide(BigDecimal.valueOf(2), 2, RoundingMode.HALF_UP));
|
|
|
+ } else {
|
|
|
+ colourPrice = colourPrice.add(colourDetail.getPrice());
|
|
|
}
|
|
|
- price = price.add(colourPrice);
|
|
|
}
|
|
|
+ vo.setColourPrice(colourPrice);
|
|
|
|
|
|
// 获取裁切配置
|
|
|
+ BigDecimal cropLength = BigDecimal.ZERO;
|
|
|
+ BigDecimal cropWidth = BigDecimal.ZERO;
|
|
|
List<BomSpecPriceConfig> bomSpecCropConfigList = configCodeMap.getOrDefault(BomSpecPriceConfigCodeEnum.CROP_CONFIG.getKey(), Collections.emptyList());
|
|
|
BomSpecPriceConfig cropConfig = bomSpecCropConfigList.stream()
|
|
|
.filter(item -> item.getName().contains(categoryDetail.getName()))
|
|
|
.findAny().orElse(null);
|
|
|
if (cropConfig != null) {
|
|
|
- dto.setLength(dto.getLength().add(cropConfig.getLength()));
|
|
|
- dto.setWidth(dto.getWidth().add(cropConfig.getWidth()));
|
|
|
+ cropLength = cropConfig.getLength();
|
|
|
+ cropWidth = cropConfig.getWidth();
|
|
|
}
|
|
|
+ vo.setCropLength(cropLength);
|
|
|
+ vo.setCropWidth(cropWidth);
|
|
|
|
|
|
// 获取压纹配置
|
|
|
+ BigDecimal embossingHeight = BigDecimal.ZERO;
|
|
|
List<BomSpecPriceConfig> bomSpecEmbossingConfigList = configCodeMap.getOrDefault(BomSpecPriceConfigCodeEnum.EMBOSSING_CONFIG.getKey(), Collections.emptyList());
|
|
|
BomSpecPriceConfig embossingConfig = bomSpecEmbossingConfigList.stream()
|
|
|
.filter(item -> item.getName().contains(dto.getEmbossing()))
|
|
|
.findAny().orElse(null);
|
|
|
if (embossingConfig != null) {
|
|
|
- dto.setHeight(dto.getHeight().add(embossingConfig.getHeight()));
|
|
|
+ embossingHeight = embossingConfig.getHeight();
|
|
|
}
|
|
|
+ vo.setEmbossingHeight(embossingHeight);
|
|
|
|
|
|
// 获取损耗配置
|
|
|
BigDecimal depletion = BigDecimal.ZERO;
|
|
@@ -149,12 +162,14 @@ public class BomSpecPriceConfigServiceImpl extends ServiceImpl<BomSpecPriceConfi
|
|
|
if (additionalConfig != null) {
|
|
|
depletion = depletion.add(additionalConfig.getDepletion());
|
|
|
}
|
|
|
+ vo.setDepletion(depletion);
|
|
|
|
|
|
// 获取加工费配置
|
|
|
List<BomSpecPriceConfig> bomSpecProcessingFeeConfigList = configCodeMap.getOrDefault(BomSpecPriceConfigCodeEnum.PROCESSING_FEE_CONFIG.getKey(), Collections.emptyList());
|
|
|
BigDecimal processingFee = bomSpecProcessingFeeConfigList.stream()
|
|
|
.map(BomSpecPriceConfig::getPrice)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ vo.setProcessingFee(processingFee);
|
|
|
|
|
|
// 获取运费配置
|
|
|
List<BomSpecPriceConfig> bomSpecFreightConfigList = configCodeMap.getOrDefault(BomSpecPriceConfigCodeEnum.FREIGHT_CONFIG.getKey(), Collections.emptyList());
|
|
@@ -164,13 +179,24 @@ public class BomSpecPriceConfigServiceImpl extends ServiceImpl<BomSpecPriceConfi
|
|
|
if (freightConfig != null) {
|
|
|
freightFee = freightConfig.getPrice();
|
|
|
}
|
|
|
-
|
|
|
- return price.multiply(dto.getLength().multiply(dto.getWidth()).divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP))
|
|
|
- .multiply(dto.getHeight())
|
|
|
- .multiply(BigDecimal.ONE.add(depletion.multiply(BigDecimal.valueOf(0.01))))
|
|
|
- .add(processingFee)
|
|
|
- .add(freightFee)
|
|
|
+ vo.setFreightFee(freightFee);
|
|
|
+
|
|
|
+ BigDecimal price = vo.getBaseMaterialPrice()
|
|
|
+ .add(vo.getCategoryPrice())
|
|
|
+ .add(vo.getCharacterPrice())
|
|
|
+ .add(vo.getColourPrice());
|
|
|
+
|
|
|
+ BigDecimal unitPrice = price
|
|
|
+ .multiply(vo.getLength().add(vo.getCropLength())
|
|
|
+ .multiply(vo.getWidth().add(vo.getCropWidth())
|
|
|
+ .divide(BigDecimal.valueOf(10000), 2, RoundingMode.HALF_UP)))
|
|
|
+ .multiply(dto.getHeight().add(vo.getEmbossingHeight()))
|
|
|
+ .multiply(BigDecimal.ONE.add(vo.getDepletion().multiply(BigDecimal.valueOf(0.01))))
|
|
|
+ .add(vo.getProcessingFee())
|
|
|
+ .add(vo.getFreightFee())
|
|
|
.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ vo.setUnitPrice(unitPrice);
|
|
|
+ return vo;
|
|
|
}
|
|
|
|
|
|
/**
|