|
@@ -6,12 +6,16 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.tenant.entity.dict.po.DictCommonData;
|
|
|
+import com.fjhx.tenant.service.dict.DictCommonDataService;
|
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.sd.business.entity.board.dto.SkuSpecQuotationDto;
|
|
|
import com.sd.business.entity.board.vo.SkuSpecQuotationVo;
|
|
|
import com.sd.business.entity.bom.bo.BomSpecBo;
|
|
|
+import com.sd.business.entity.bom.po.Bom;
|
|
|
+import com.sd.business.entity.bom.po.BomSpec;
|
|
|
import com.sd.business.entity.department.po.Department;
|
|
|
import com.sd.business.entity.inventory.po.Inventory;
|
|
|
import com.sd.business.entity.price.po.PriceBillingStandard;
|
|
@@ -71,6 +75,9 @@ public class SkuSpecServiceImpl extends ServiceImpl<SkuSpecMapper, SkuSpec> impl
|
|
|
@Autowired
|
|
|
private PriceBillingStandardDetailService priceBillingStandardDetailService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DictCommonDataService dictCommonDataService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<SkuSpecVo> getPage(SkuSpecSelectDto dto) {
|
|
|
IWrapper<SkuSpec> wrapper = getWrapper();
|
|
@@ -186,12 +193,15 @@ public class SkuSpecServiceImpl extends ServiceImpl<SkuSpecMapper, SkuSpec> impl
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
|
|
|
- Map<Long, Sku> skuMap = skuService.mapKEntity(BaseIdPo::getId, q -> q.in(Sku::getBrand, brandList));
|
|
|
- List<SkuSpec> skuSpecList = this.list(q -> q
|
|
|
- .in(SkuSpec::getSkuId, skuMap.keySet())
|
|
|
- .isNotNull(SkuSpec::getBomSpecId)
|
|
|
- .like(StrUtil.isNotBlank(dto.getSkuSpecCode()), SkuSpec::getCode, dto.getSkuSpecCode())
|
|
|
- .like(StrUtil.isNotBlank(dto.getSkuSpecName()), SkuSpec::getName, dto.getSkuSpecName()));
|
|
|
+ IWrapper<SkuSpec> wrapper = getWrapper();
|
|
|
+ wrapper.orderByDesc("ss", SkuSpec::getId);
|
|
|
+ wrapper.in("s", Sku::getBrand, brandList);
|
|
|
+ wrapper.like("ss", SkuSpec::getCode, dto.getSkuSpecCode());
|
|
|
+ wrapper.like("bs", BomSpec::getCode, dto.getBomSpecCode());
|
|
|
+ wrapper.like("bs", BomSpec::getColour, dto.getColour());
|
|
|
+ wrapper.eq("b", Bom::getChromatophore, dto.getChromatophore());
|
|
|
+ wrapper.isNotNull("ss.bom_spec_id");
|
|
|
+ List<SkuSpecQuotationVo> skuSpecList = this.baseMapper.getSkuSpecQuotationList(wrapper);
|
|
|
|
|
|
if (skuSpecList.isEmpty()) {
|
|
|
return Collections.emptyList();
|
|
@@ -207,24 +217,25 @@ public class SkuSpecServiceImpl extends ServiceImpl<SkuSpecMapper, SkuSpec> impl
|
|
|
q -> q.in(PriceBillingStandardDetail::getPriceBillingStandardId, priceBillingStandardIds));
|
|
|
|
|
|
// 获取sku关联的所有bom数据
|
|
|
- List<Long> skuSpecIds = skuSpecList.stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
|
- Map<Long, List<SkuSpecLink>> linkMap = skuSpecLinkService.mapKGroup(SkuSpecLink::getSkuSpecId,
|
|
|
- q -> q.in(SkuSpecLink::getSkuSpecId, skuSpecIds).eq(SkuSpecLink::getType, 1));
|
|
|
- Set<Long> bomSpecIds = skuSpecList.stream().map(SkuSpec::getBomSpecId).collect(Collectors.toSet());
|
|
|
- bomSpecIds.addAll(linkMap.values().stream().flatMap(item -> item.stream().map(SkuSpecLink::getBomSpecId)).collect(Collectors.toList()));
|
|
|
+ List<Long> skuSpecIds = skuSpecList.stream().map(SkuSpecQuotationVo::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<SkuSpecLink> skuSpecLinkList = skuSpecLinkService.list(q -> q.in(SkuSpecLink::getSkuSpecId, skuSpecIds));
|
|
|
+ Map<Long, Map<Integer, List<SkuSpecLink>>> skuSpecLinkBomSpecMap = skuSpecLinkList.stream().collect(
|
|
|
+ Collectors.groupingBy(SkuSpecLink::getSkuSpecId, Collectors.groupingBy(SkuSpecLink::getType)));
|
|
|
+
|
|
|
+ Set<Long> bomSpecIds = skuSpecList.stream().map(SkuSpecQuotationVo::getBomSpecId).collect(Collectors.toSet());
|
|
|
+ bomSpecIds.addAll(skuSpecLinkList.stream().map(SkuSpecLink::getBomSpecId).collect(Collectors.toList()));
|
|
|
Map<Long, BomSpecBo> bomSpecBoMap = this.getBomSpecBoByIdList(bomSpecIds);
|
|
|
|
|
|
- List<SkuSpecQuotationVo> list = new ArrayList<>();
|
|
|
+ Map<String, String> bomChromatophoreMap = dictCommonDataService.list(q -> q.eq(DictCommonData::getDictCode, "bom_chromatophore"))
|
|
|
+ .stream().collect(Collectors.toMap(DictCommonData::getDictKey, DictCommonData::getDictValue));
|
|
|
+
|
|
|
|
|
|
- for (SkuSpec skuSpec : skuSpecList) {
|
|
|
- Sku sku = skuMap.get(skuSpec.getSkuId());
|
|
|
- BomSpecBo bomSpecBo = bomSpecBoMap.get(skuSpec.getBomSpecId());
|
|
|
+ for (SkuSpecQuotationVo vo : skuSpecList) {
|
|
|
+ BomSpecBo bomSpecBo = bomSpecBoMap.get(vo.getBomSpecId());
|
|
|
|
|
|
// 赋值
|
|
|
- SkuSpecQuotationVo vo = new SkuSpecQuotationVo();
|
|
|
- vo.setBrand(sku.getBrand());
|
|
|
- vo.setSkuSpecCode(skuSpec.getCode());
|
|
|
- vo.setSkuSpecName(skuSpec.getName());
|
|
|
+ vo.setChromatophore(bomChromatophoreMap.get(vo.getChromatophore()));
|
|
|
vo.setBomSpecUnitPrice(bomSpecBo.getInternalSellingPrice());
|
|
|
vo.setPackagingMaterialCost(BigDecimal.ZERO);
|
|
|
vo.setLineProcessingFee(BigDecimal.ZERO);
|
|
@@ -235,9 +246,10 @@ public class SkuSpecServiceImpl extends ServiceImpl<SkuSpecMapper, SkuSpec> impl
|
|
|
vo.setManagementFee(BigDecimal.ZERO);
|
|
|
|
|
|
// 获取包材费
|
|
|
- List<SkuSpecLink> skuSpecLinkList = linkMap.get(skuSpec.getId());
|
|
|
- if (ObjectUtil.isNotEmpty(skuSpecLinkList)) {
|
|
|
- BigDecimal packagingMaterialCost = skuSpecLinkList.stream().map(item -> {
|
|
|
+ Map<Integer, List<SkuSpecLink>> linkMap = skuSpecLinkBomSpecMap.getOrDefault(vo.getId(), Collections.emptyMap());
|
|
|
+ List<SkuSpecLink> packagingLinkList = linkMap.getOrDefault(1, Collections.emptyList());
|
|
|
+ if (ObjectUtil.isNotEmpty(packagingLinkList)) {
|
|
|
+ BigDecimal packagingMaterialCost = packagingLinkList.stream().map(item -> {
|
|
|
BomSpecBo skuSpecLinkBomSpec = bomSpecBoMap.get(item.getBomSpecId());
|
|
|
if (skuSpecLinkBomSpec == null) {
|
|
|
return BigDecimal.ZERO;
|
|
@@ -272,14 +284,27 @@ public class SkuSpecServiceImpl extends ServiceImpl<SkuSpecMapper, SkuSpec> impl
|
|
|
case "50":
|
|
|
vo.setIssueFee(chargePrice);
|
|
|
break;
|
|
|
- case "60":
|
|
|
- vo.setDeliveryMaterialsFee(chargePrice);
|
|
|
- break;
|
|
|
case "70":
|
|
|
vo.setManagementFee(chargePrice);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ // 计算快递包材费
|
|
|
+ List<SkuSpecLink> deliveryLinkList = linkMap.getOrDefault(2, Collections.emptyList());
|
|
|
+ if (deliveryLinkList.isEmpty()) {
|
|
|
+ vo.setDeliveryMaterialsFee(BigDecimal.ZERO);
|
|
|
+ } else {
|
|
|
+ BigDecimal deliveryMaterialsFee = deliveryLinkList.stream()
|
|
|
+ .map(item -> {
|
|
|
+ BomSpecBo bomSpec = bomSpecBoMap.get(item.getBomSpecId());
|
|
|
+ if (bomSpec == null) {
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ return item.getQuantity().multiply(bomSpec.getInternalSellingPrice());
|
|
|
+ })
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ vo.setDeliveryMaterialsFee(deliveryMaterialsFee);
|
|
|
+ }
|
|
|
|
|
|
// 计算Sku单价
|
|
|
vo.setSkuSpecUnitPrice(
|
|
@@ -291,11 +316,9 @@ public class SkuSpecServiceImpl extends ServiceImpl<SkuSpecMapper, SkuSpec> impl
|
|
|
.add(vo.getManagementFee()));
|
|
|
vo.setSkuSpecUnitPriceLogo(vo.getSkuSpecUnitPrice().add(vo.getLogoProcessingFee()));
|
|
|
vo.setSkuSpecUnitPriceLine(vo.getSkuSpecUnitPrice().add(vo.getLineProcessingFee()));
|
|
|
-
|
|
|
- list.add(vo);
|
|
|
}
|
|
|
|
|
|
- return list;
|
|
|
+ return skuSpecList;
|
|
|
}
|
|
|
|
|
|
}
|