|
@@ -23,6 +23,7 @@ import com.sd.business.entity.order.enums.OrderClassifyEnum;
|
|
|
import com.sd.business.entity.order.po.OrderInfo;
|
|
|
import com.sd.business.entity.order.po.OrderSku;
|
|
|
import com.sd.business.entity.order.po.OrderSkuBom;
|
|
|
+import com.sd.business.entity.sku.po.SkuSpec;
|
|
|
import com.sd.business.entity.statement.dto.FileUploadDto;
|
|
|
import com.sd.business.entity.statement.dto.StatementOfAccountDto;
|
|
|
import com.sd.business.entity.statement.dto.StatementOfAccountSelectDto;
|
|
@@ -49,6 +50,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
@@ -279,18 +281,32 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.add(item.getManagementFee())
|
|
|
)
|
|
|
.build())
|
|
|
- .peek(item -> item.setSubtotal(ObjectUtil.equals(item.getQuantity(), BigDecimal.ZERO) ? item.getUnitPrice() : item.getQuantity().multiply(item.getUnitPrice())))
|
|
|
+ .peek(item -> item.setSubtotal(item.getQuantity().multiply(item.getUnitPrice()).setScale(2, RoundingMode.HALF_UP)))
|
|
|
.peek(item -> item.setTotal(item.getSubtotal()))
|
|
|
+ .peek(item -> item.setUnitPrice(item.getUnitPrice().setScale(2, RoundingMode.HALF_UP)))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 查询赠品sku
|
|
|
+ List<Long> skuSpecIds = documentBySkuVoList.stream().map(DocumentBySkuVo::getSkuSpecId).collect(Collectors.toList());
|
|
|
+ Map<Long, SkuSpec> skuSpecMap = skuSpecService.byIdsToMap(skuSpecIds);
|
|
|
+ List<Long> giftSkuSpecIds = skuSpecMap.values().stream()
|
|
|
+ .filter(item -> Objects.equals(item.getGiftTag(), StatusConstant.YES))
|
|
|
+ .map(BaseIdPo::getId)
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
// 赋值sku规格品名和品号
|
|
|
- skuSpecService.attributeAssign(documentBySkuVoList, DocumentBySkuVo::getSkuSpecId, (item, skuSpec) -> {
|
|
|
- item.setSkuSpecCode(skuSpec.getCode());
|
|
|
- item.setSkuSpecName(skuSpec.getName());
|
|
|
- });
|
|
|
+ for (DocumentBySkuVo documentBySkuVo : documentBySkuVoList) {
|
|
|
+ SkuSpec skuSpec = skuSpecMap.get(documentBySkuVo.getSkuSpecId());
|
|
|
+ if (skuSpec == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ documentBySkuVo.setSkuSpecCode(skuSpec.getCode());
|
|
|
+ documentBySkuVo.setSkuSpecName(skuSpec.getName());
|
|
|
+ }
|
|
|
|
|
|
// 合并单价、小计、sku规格id系统的对账数据
|
|
|
Collection<DocumentBySkuVo> documentBySkuVoCollection = documentBySkuVoList.stream()
|
|
|
+ .filter(item -> giftSkuSpecIds.isEmpty() || !giftSkuSpecIds.contains(item.getSkuSpecId()))
|
|
|
.sorted(comparing(DocumentBySkuVo::getSkuSpecCode))
|
|
|
.collect(Collectors.toMap(
|
|
|
item -> item.getUnitPrice() + ":" + item.getSkuSpecId(),
|
|
@@ -318,8 +334,13 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
// 获取订单sku
|
|
|
List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getOrderId, orderIdList));
|
|
|
|
|
|
+ // 筛选掉赠品sku
|
|
|
+ List<Long> skuSpecIds = orderSkuList.stream().map(OrderSku::getSkuSpecId).collect(Collectors.toList());
|
|
|
+ List<Long> giftSkuSpecIds = skuSpecService.getGiftIdListByIdList(skuSpecIds);
|
|
|
+
|
|
|
// 主材bom
|
|
|
List<DocumentByBomVo> result = orderSkuList.stream()
|
|
|
+ .filter(item -> giftSkuSpecIds.isEmpty() || !giftSkuSpecIds.contains(item.getSkuSpecId()))
|
|
|
.map(item -> DocumentByBomVo.builder()
|
|
|
.bomSpecId(item.getBomSpecId())
|
|
|
.orderId(item.getOrderId())
|
|
@@ -343,6 +364,7 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.add(item.getDeliveryMaterialsFeeSummary())
|
|
|
.add(item.getPackingLaborSummary())
|
|
|
.add(item.getManagementFeeSummary())
|
|
|
+ .setScale(2, RoundingMode.HALF_UP)
|
|
|
))
|
|
|
.peek(item -> item.setTotal(item.getSubtotal()))
|
|
|
.collect(Collectors.toList());
|
|
@@ -453,19 +475,25 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
|
|
|
List<Long> orderIdList = orderList.stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
|
List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getOrderId, orderIdList));
|
|
|
+ // 筛选掉赠品sku
|
|
|
+ List<Long> skuSpecIds = orderSkuList.stream().map(OrderSku::getSkuSpecId).collect(Collectors.toList());
|
|
|
+ List<Long> giftSkuSpecIds = skuSpecService.getGiftIdListByIdList(skuSpecIds);
|
|
|
+ List<OrderSku> tempOrderSkuList = orderSkuList.stream()
|
|
|
+ .filter(item -> giftSkuSpecIds.isEmpty() || !giftSkuSpecIds.contains(item.getSkuSpecId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
SecurityContext context = SecurityContextHolder.getContext();
|
|
|
|
|
|
CompletableFuture<List<DocumentByOrderVo.SkuSpec>> skuSpecListCompletableFuture = CompletableFuture.supplyAsync(
|
|
|
() -> {
|
|
|
SecurityContextHolder.setContext(context);
|
|
|
- return getSkuSpecList(orderSkuList);
|
|
|
+ return getSkuSpecList(tempOrderSkuList);
|
|
|
}, threadPoolExecutor);
|
|
|
|
|
|
CompletableFuture<List<DocumentByOrderVo.BomSpec>> bomSpecListCompletableFuture = CompletableFuture.supplyAsync(
|
|
|
() -> {
|
|
|
SecurityContextHolder.setContext(context);
|
|
|
- return getBomSpecList(orderIdList, orderSkuList);
|
|
|
+ return getBomSpecList(orderIdList, tempOrderSkuList);
|
|
|
}, threadPoolExecutor);
|
|
|
|
|
|
// 获取订单bom
|
|
@@ -576,7 +604,8 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.add(item.getManagementFee()));
|
|
|
return skuSpec;
|
|
|
})
|
|
|
- .peek(item -> item.setSubtotal(item.getQuantity().multiply(item.getUnitPrice())))
|
|
|
+ .peek(item -> item.setSubtotal(item.getQuantity().multiply(item.getUnitPrice()).setScale(2, RoundingMode.HALF_UP)))
|
|
|
+ .peek(item -> item.setUnitPrice(item.getUnitPrice().setScale(2, RoundingMode.HALF_UP)))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
skuSpecService.attributeAssign(skuSpecList, DocumentByOrderVo.SkuSpec::getSkuSpecId, (item, skuSpec) -> {
|