|
|
@@ -580,12 +580,12 @@ public class SaleOrderServiceImpl extends BaseMpServiceImpl<SaleOrderMapper, Sal
|
|
580
|
580
|
}
|
|
581
|
581
|
|
|
582
|
582
|
order.setScId(vo.getScId());
|
|
583
|
|
- order.setPlanId(vo.getPlanId());
|
|
584
|
|
- Customer customer = customerService.findById(vo.getCustomerId());
|
|
585
|
|
- if (customer == null) {
|
|
586
|
|
- throw new InputErrorException("客户不存在!");
|
|
587
|
|
- }
|
|
588
|
|
- order.setCustomerId(vo.getCustomerId());
|
|
|
583
|
+ // order.setPlanId(vo.getPlanId());
|
|
|
584
|
+// Customer customer = customerService.findById(vo.getCustomerId());
|
|
|
585
|
+// if (customer == null) {
|
|
|
586
|
+// throw new InputErrorException("客户不存在!");
|
|
|
587
|
+// }
|
|
|
588
|
+ // order.setCustomerId(vo.getCustomerId());
|
|
589
|
589
|
|
|
590
|
590
|
if (!StringUtil.isBlank(vo.getSalerId())) {
|
|
591
|
591
|
UserDto saler = userService.findById(vo.getSalerId());
|
|
|
@@ -628,71 +628,71 @@ public class SaleOrderServiceImpl extends BaseMpServiceImpl<SaleOrderMapper, Sal
|
|
628
|
628
|
|
|
629
|
629
|
orderDetail.setProductId(productVo.getProductId());
|
|
630
|
630
|
orderDetail.setOrderNum(productVo.getOrderNum());
|
|
631
|
|
- orderDetail.setOriPrice(productVo.getOriPrice());
|
|
632
|
|
- orderDetail.setDiscountRate(productVo.getDiscountRate());
|
|
633
|
|
- orderDetail.setTaxPrice(productVo.getTaxPrice());
|
|
634
|
|
- orderDetail.setIsGift(isGift);
|
|
635
|
|
- orderDetail.setTaxRate(product.getSaleTaxRate());
|
|
|
631
|
+ // orderDetail.setOriPrice(productVo.getOriPrice());
|
|
|
632
|
+ // orderDetail.setDiscountRate(productVo.getDiscountRate());
|
|
|
633
|
+ // orderDetail.setTaxPrice(productVo.getTaxPrice());
|
|
|
634
|
+ // orderDetail.setIsGift(isGift);
|
|
|
635
|
+ // orderDetail.setTaxRate(product.getSaleTaxRate());
|
|
636
|
636
|
orderDetail.setDescription(
|
|
637
|
637
|
StringUtil.isBlank(productVo.getDescription()) ? StringPool.EMPTY_STR
|
|
638
|
638
|
: productVo.getDescription());
|
|
639
|
639
|
orderDetail.setOrderNo(orderNo);
|
|
640
|
640
|
|
|
641
|
|
- saleOrderDetailService.save(orderDetail);
|
|
642
|
|
-
|
|
643
|
|
- // 这里处理组合商品
|
|
644
|
|
- if (product.getProductType() == ProductType.BUNDLE) {
|
|
645
|
|
- List<ProductBundle> productBundles = productBundleService.getByMainProductId(
|
|
646
|
|
- product.getId());
|
|
647
|
|
- // 构建指标项
|
|
648
|
|
- Map<Object, Number> bundleWeight = new HashMap<>(productBundles.size());
|
|
649
|
|
- for (ProductBundle productBundle : productBundles) {
|
|
650
|
|
- bundleWeight.put(productBundle.getProductId(),
|
|
651
|
|
- NumberUtil.mul(productBundle.getSalePrice(), productBundle.getBundleNum()));
|
|
652
|
|
- }
|
|
653
|
|
- Map<Object, Number> splitPriceMap = SplitNumberUtil.split(orderDetail.getTaxPrice(),
|
|
654
|
|
- bundleWeight, 2);
|
|
655
|
|
- List<SaleOrderDetailBundle> saleOrderDetailBundles = productBundles.stream()
|
|
656
|
|
- .map(productBundle -> {
|
|
657
|
|
- Product bundle = productService.findById(productBundle.getProductId());
|
|
658
|
|
- SaleOrderDetailBundle saleOrderDetailBundle = new SaleOrderDetailBundle();
|
|
659
|
|
- saleOrderDetailBundle.setId(IdUtil.getId());
|
|
660
|
|
- saleOrderDetailBundle.setOrderId(order.getId());
|
|
661
|
|
- saleOrderDetailBundle.setDetailId(orderDetail.getId());
|
|
662
|
|
- saleOrderDetailBundle.setMainProductId(product.getId());
|
|
663
|
|
- saleOrderDetailBundle.setOrderNum(orderDetail.getOrderNum());
|
|
664
|
|
- saleOrderDetailBundle.setProductId(productBundle.getProductId());
|
|
665
|
|
- saleOrderDetailBundle.setProductOrderNum(
|
|
666
|
|
- NumberUtil.mul(orderDetail.getOrderNum(), productBundle.getBundleNum())
|
|
667
|
|
- .intValue());
|
|
668
|
|
- saleOrderDetailBundle.setProductOriPrice(productBundle.getSalePrice());
|
|
669
|
|
- // 这里会有尾差
|
|
670
|
|
- saleOrderDetailBundle.setProductTaxPrice(NumberUtil.getNumber(NumberUtil.div(
|
|
671
|
|
- BigDecimal.valueOf(
|
|
672
|
|
- splitPriceMap.get(productBundle.getProductId()).doubleValue()), productBundle.getBundleNum()), 2));
|
|
673
|
|
- saleOrderDetailBundle.setProductTaxRate(bundle.getSaleTaxRate());
|
|
674
|
|
-
|
|
675
|
|
- return saleOrderDetailBundle;
|
|
676
|
|
- }).collect(Collectors.toList());
|
|
677
|
|
-
|
|
678
|
|
- saleOrderDetailBundleService.saveBatch(saleOrderDetailBundles);
|
|
679
|
|
- }
|
|
|
641
|
+ boolean rrr= saleOrderDetailService.save(orderDetail);
|
|
|
642
|
+
|
|
|
643
|
+// // 这里处理组合商品
|
|
|
644
|
+// if (product.getProductType() == ProductType.BUNDLE) {
|
|
|
645
|
+// List<ProductBundle> productBundles = productBundleService.getByMainProductId(
|
|
|
646
|
+// product.getId());
|
|
|
647
|
+// // 构建指标项
|
|
|
648
|
+// Map<Object, Number> bundleWeight = new HashMap<>(productBundles.size());
|
|
|
649
|
+// for (ProductBundle productBundle : productBundles) {
|
|
|
650
|
+// bundleWeight.put(productBundle.getProductId(),
|
|
|
651
|
+// NumberUtil.mul(productBundle.getSalePrice(), productBundle.getBundleNum()));
|
|
|
652
|
+// }
|
|
|
653
|
+// Map<Object, Number> splitPriceMap = SplitNumberUtil.split(orderDetail.getTaxPrice(),
|
|
|
654
|
+// bundleWeight, 2);
|
|
|
655
|
+// List<SaleOrderDetailBundle> saleOrderDetailBundles = productBundles.stream()
|
|
|
656
|
+// .map(productBundle -> {
|
|
|
657
|
+// Product bundle = productService.findById(productBundle.getProductId());
|
|
|
658
|
+// SaleOrderDetailBundle saleOrderDetailBundle = new SaleOrderDetailBundle();
|
|
|
659
|
+// saleOrderDetailBundle.setId(IdUtil.getId());
|
|
|
660
|
+// saleOrderDetailBundle.setOrderId(order.getId());
|
|
|
661
|
+// saleOrderDetailBundle.setDetailId(orderDetail.getId());
|
|
|
662
|
+// saleOrderDetailBundle.setMainProductId(product.getId());
|
|
|
663
|
+// saleOrderDetailBundle.setOrderNum(orderDetail.getOrderNum());
|
|
|
664
|
+// saleOrderDetailBundle.setProductId(productBundle.getProductId());
|
|
|
665
|
+// saleOrderDetailBundle.setProductOrderNum(
|
|
|
666
|
+// NumberUtil.mul(orderDetail.getOrderNum(), productBundle.getBundleNum())
|
|
|
667
|
+// .intValue());
|
|
|
668
|
+// saleOrderDetailBundle.setProductOriPrice(productBundle.getSalePrice());
|
|
|
669
|
+// // 这里会有尾差
|
|
|
670
|
+// saleOrderDetailBundle.setProductTaxPrice(NumberUtil.getNumber(NumberUtil.div(
|
|
|
671
|
+// BigDecimal.valueOf(
|
|
|
672
|
+// splitPriceMap.get(productBundle.getProductId()).doubleValue()), productBundle.getBundleNum()), 2));
|
|
|
673
|
+// saleOrderDetailBundle.setProductTaxRate(bundle.getSaleTaxRate());
|
|
|
674
|
+//
|
|
|
675
|
+// return saleOrderDetailBundle;
|
|
|
676
|
+// }).collect(Collectors.toList());
|
|
|
677
|
+//
|
|
|
678
|
+// saleOrderDetailBundleService.saveBatch(saleOrderDetailBundles);
|
|
|
679
|
+// }
|
|
680
|
680
|
orderNo++;
|
|
681
|
681
|
}
|
|
682
|
682
|
order.setTotalNum(totalNum);
|
|
683
|
|
- order.setTotalGiftNum(giftNum);
|
|
684
|
|
- order.setTotalAmount(totalAmount);
|
|
|
683
|
+ // order.setTotalGiftNum(giftNum);
|
|
|
684
|
+ // order.setTotalAmount(totalAmount);
|
|
685
|
685
|
order.setDescription(
|
|
686
|
686
|
StringUtil.isBlank(vo.getDescription()) ? StringPool.EMPTY_STR : vo.getDescription());
|
|
687
|
687
|
|
|
688
|
|
- orderPayTypeService.create(order.getId(), vo.getPayTypes());
|
|
|
688
|
+ // orderPayTypeService.create(order.getId(), vo.getPayTypes());
|
|
689
|
689
|
}
|
|
690
|
690
|
|
|
691
|
691
|
private void sendApprovePassEvent(SaleOrder order) {
|
|
692
|
692
|
|
|
693
|
693
|
ApprovePassSaleOrderEvent event = new ApprovePassSaleOrderEvent(this);
|
|
694
|
694
|
event.setId(order.getId());
|
|
695
|
|
- event.setTotalAmount(order.getTotalAmount());
|
|
|
695
|
+ // event.setTotalAmount(order.getTotalAmount());
|
|
696
|
696
|
event.setApproveTime(order.getApproveTime());
|
|
697
|
697
|
event.setCreateUser(order.getCreateById());
|
|
698
|
698
|
ApplicationUtil.publishEvent(event);
|