|
@@ -361,8 +361,12 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
|
|
|
@Override
|
|
|
public List<DocumentByOrderVo> getDocumentByOrder(Long statementOfAccountId) {
|
|
|
+
|
|
|
Assert.notNull(statementOfAccountId, "对账单id不能为空");
|
|
|
List<OrderInfo> orderList = orderService.list(q -> q.eq(OrderInfo::getStatementOfAccountId, statementOfAccountId));
|
|
|
+ if (orderList.size() == 0) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
|
|
|
List<DocumentByOrderVo> result = orderList.stream().map(item ->
|
|
|
DocumentByOrderVo.builder()
|
|
@@ -374,11 +378,50 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
|
List<Long> orderIdList = orderList.stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
|
+ List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getOrderId, orderIdList));
|
|
|
|
|
|
// 获取订单sku
|
|
|
- List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getOrderId, orderIdList));
|
|
|
- List<DocumentByOrderVo.SkuSpec.SkuSpecBuilder> collect = orderSkuList.stream()
|
|
|
+ List<DocumentByOrderVo.SkuSpec> skuSpecList = getSkuSpecList(orderSkuList);
|
|
|
+
|
|
|
+ // 获取订单bom
|
|
|
+ List<DocumentByOrderVo.BomSpec> bomSpecList = getBomSpecList(orderIdList, orderSkuList);
|
|
|
+
|
|
|
+ // sku赋值bom
|
|
|
+ Map<Long, List<DocumentByOrderVo.BomSpec>> bomSpecMap = bomSpecList.stream()
|
|
|
+ .collect(Collectors.groupingBy(DocumentByOrderVo.BomSpec::getOrderSkuId));
|
|
|
+ for (DocumentByOrderVo.SkuSpec skuSpec : skuSpecList) {
|
|
|
+ skuSpec.setBomSpecList(bomSpecMap.getOrDefault(skuSpec.getOrderSkuId(), Collections.emptyList()));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 订单赋值sku
|
|
|
+ Map<Long, List<DocumentByOrderVo.SkuSpec>> skuSpecMap = skuSpecList.stream()
|
|
|
+ .collect(Collectors.groupingBy(DocumentByOrderVo.SkuSpec::getOrderId));
|
|
|
+ for (DocumentByOrderVo documentByOrderVo : result) {
|
|
|
+ documentByOrderVo.setSkuSpecList(skuSpecMap.getOrDefault(documentByOrderVo.getOrderId(), Collections.emptyList()));
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据对账单id获取对账订单id列表
|
|
|
+ */
|
|
|
+ private List<Long> getOrderIdList(Long statementOfAccountId) {
|
|
|
+ Assert.notNull(statementOfAccountId, "对账单id不能为空");
|
|
|
+ List<OrderInfo> orderList = orderService.list(q -> q.eq(OrderInfo::getStatementOfAccountId, statementOfAccountId));
|
|
|
+ return orderList.stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取订单sku
|
|
|
+ */
|
|
|
+ private List<DocumentByOrderVo.SkuSpec> getSkuSpecList(List<OrderSku> orderSkuList) {
|
|
|
+
|
|
|
+ List<DocumentByOrderVo.SkuSpec> skuSpecList = orderSkuList.stream()
|
|
|
.map(item -> DocumentByOrderVo.SkuSpec.builder()
|
|
|
+ .orderId(item.getOrderId())
|
|
|
+ .orderSkuId(item.getId())
|
|
|
.skuSpecId(item.getSkuSpecId())
|
|
|
.quantity(item.getQuantity())
|
|
|
.unitPrice(item.getUnitPrice()
|
|
@@ -386,21 +429,61 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.add(item.getLssueFee())
|
|
|
.add(item.getDeliveryMaterialsFee())
|
|
|
.add(item.getPackingLabor())
|
|
|
- .add(item.getPackagingMaterialCost())
|
|
|
- )
|
|
|
- ).collect(Collectors.toList());
|
|
|
+ .add(item.getPackagingMaterialCost()))
|
|
|
+ .build()
|
|
|
+ )
|
|
|
+ .peek(item -> item.setSubtotal(item.getQuantity().multiply(item.getUnitPrice())))
|
|
|
+ .peek(item -> item.setTotal(item.getSubtotal()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
+ skuSpecService.attributeAssign(skuSpecList, DocumentByOrderVo.SkuSpec::getSkuSpecId, (item, skuSpec) -> {
|
|
|
+ item.setSkuSpecCode(skuSpec.getCode());
|
|
|
+ item.setSkuSpecName(skuSpec.getName());
|
|
|
+ });
|
|
|
|
|
|
- return result;
|
|
|
+ return skuSpecList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 根据对账单id获取对账订单id列表
|
|
|
+ * 获取订单bom
|
|
|
*/
|
|
|
- private List<Long> getOrderIdList(Long statementOfAccountId) {
|
|
|
- Assert.notNull(statementOfAccountId, "对账单id不能为空");
|
|
|
- List<OrderInfo> orderList = orderService.list(q -> q.eq(OrderInfo::getStatementOfAccountId, statementOfAccountId));
|
|
|
- return orderList.stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
|
+ private List<DocumentByOrderVo.BomSpec> getBomSpecList(List<Long> orderIdList, List<OrderSku> orderSkuList) {
|
|
|
+
|
|
|
+ List<DocumentByOrderVo.BomSpec> bomSpecList = orderSkuList.stream()
|
|
|
+ .map(item -> DocumentByOrderVo.BomSpec.builder()
|
|
|
+ .orderSkuId(item.getId())
|
|
|
+ .bomSpecId(item.getBomSpecId())
|
|
|
+ .quantity(item.getQuantity())
|
|
|
+ .unitPrice(item.getUnitPrice())
|
|
|
+ .laserLogoSummary((Objects.equals(item.getCustomProcessingType(), "20")
|
|
|
+ ? item.getCustomProcessingFee() : BigDecimal.ZERO).multiply(item.getQuantity()))
|
|
|
+ .laserMitochondrialSummary((Objects.equals(item.getCustomProcessingType(), "10")
|
|
|
+ ? item.getCustomProcessingFee() : BigDecimal.ZERO).multiply(item.getQuantity()))
|
|
|
+ .lssueFeeSummary(item.getLssueFee().multiply(item.getQuantity()))
|
|
|
+ .deliveryMaterialsFeeSummary(item.getDeliveryMaterialsFee().multiply(item.getQuantity()))
|
|
|
+ .packingLaborSummary(item.getPackingLabor().multiply(item.getQuantity()))
|
|
|
+ .build()
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<OrderSkuBom> orderSkuBomList = orderSkuBomService.list(q -> q.in(OrderSkuBom::getOrderId, orderIdList));
|
|
|
+
|
|
|
+ List<DocumentByOrderVo.BomSpec> packBomSpecList = orderSkuBomList.stream()
|
|
|
+ .map(item -> DocumentByOrderVo.BomSpec.builder()
|
|
|
+ .orderSkuId(item.getOrderSkuId())
|
|
|
+ .bomSpecId(item.getBomSpecId())
|
|
|
+ .quantity(item.getQuantity())
|
|
|
+ .unitPrice(item.getUnitPrice())
|
|
|
+ .build()
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+
|
|
|
+ bomSpecList.addAll(packBomSpecList);
|
|
|
+
|
|
|
+ bomSpecService.attributeAssign(bomSpecList, DocumentByOrderVo.BomSpec::getBomSpecId, (item, bomSpec) -> {
|
|
|
+ item.setBomSpecCode(bomSpec.getCode());
|
|
|
+ item.setBomSpecName(bomSpec.getName());
|
|
|
+ });
|
|
|
+
|
|
|
+ return bomSpecList;
|
|
|
}
|
|
|
|
|
|
}
|