|
|
|
|
@@ -23,6 +23,7 @@ import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -192,9 +193,9 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
|
|
|
|
|
*/
|
|
|
|
|
private BigDecimal getProductCostAmount(Long shopId, LocalDate day) {
|
|
|
|
|
//获取商品sku成本价 productId skuId price
|
|
|
|
|
Map<Long, BigDecimal> skuCostAmountList = mapper.getSkuCostAmount(shopId);
|
|
|
|
|
List<ProductCostAmountVO> skuCostAmountList = mapper.getSkuCostAmount(shopId);
|
|
|
|
|
// //获取商品耗材成本价 productId price
|
|
|
|
|
Map<Long, BigDecimal> consCostAmountList = mapper.getConsCostAmount(shopId);
|
|
|
|
|
List<ProductCostAmountVO> consCostAmountList = mapper.getConsCostAmount(shopId);
|
|
|
|
|
//获取orderDetail信息 productId skuId 数量
|
|
|
|
|
BigDecimal productCostAmount = BigDecimal.ZERO;
|
|
|
|
|
if (CollUtil.isEmpty(skuCostAmountList) && CollUtil.isEmpty(consCostAmountList)) {
|
|
|
|
|
@@ -204,12 +205,16 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
|
|
|
|
|
if (CollUtil.isEmpty(orderDetailProduct)) {
|
|
|
|
|
return productCostAmount;
|
|
|
|
|
}
|
|
|
|
|
Map<Long, BigDecimal> skuCostAmountMap = skuCostAmountList.stream()
|
|
|
|
|
.collect(Collectors.toMap(ProductCostAmountVO::getSkuId, ProductCostAmountVO::getCostAmount));
|
|
|
|
|
Map<Long, BigDecimal> consCostAmountMap = consCostAmountList.stream()
|
|
|
|
|
.collect(Collectors.toMap(ProductCostAmountVO::getProductId, ProductCostAmountVO::getCostAmount));
|
|
|
|
|
for (ProductCostAmountVO productCostAmountVO : orderDetailProduct) {
|
|
|
|
|
if (skuCostAmountList.containsKey(productCostAmountVO.getSkuId())) {
|
|
|
|
|
BigDecimal costAmount = skuCostAmountList.get(productCostAmountVO.getSkuId());
|
|
|
|
|
if (skuCostAmountMap.containsKey(productCostAmountVO.getSkuId())) {
|
|
|
|
|
BigDecimal costAmount = skuCostAmountMap.get(productCostAmountVO.getSkuId());
|
|
|
|
|
productCostAmount = productCostAmount.add(costAmount.multiply(new BigDecimal(productCostAmountVO.getCount())).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
} else if (consCostAmountList.containsKey(productCostAmountVO.getProductId())) {
|
|
|
|
|
BigDecimal costAmount = consCostAmountList.get(productCostAmountVO.getProductId());
|
|
|
|
|
} else if (consCostAmountMap.containsKey(productCostAmountVO.getProductId())) {
|
|
|
|
|
BigDecimal costAmount = consCostAmountMap.get(productCostAmountVO.getProductId());
|
|
|
|
|
productCostAmount = productCostAmount.add(costAmount.multiply(new BigDecimal(productCostAmountVO.getCount())).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|