|
@@ -282,8 +282,7 @@ public class PcOrderController extends BaseController {
|
|
|
// mainBo.setOrderProductBos(bo.getOrderProductBos());
|
|
// mainBo.setOrderProductBos(bo.getOrderProductBos());
|
|
|
Map<Long, Long> productNumMap;
|
|
Map<Long, Long> productNumMap;
|
|
|
// 1. 获取购物车项
|
|
// 1. 获取购物车项
|
|
|
- if(bo.getPlaceOrderType() == 1){
|
|
|
|
|
- productNumMap = Map.of();
|
|
|
|
|
|
|
+ if (bo.getPlaceOrderType() == 1) {
|
|
|
Set<Long> productShoppingCartIds = bo.getProductShoppingCartId();
|
|
Set<Long> productShoppingCartIds = bo.getProductShoppingCartId();
|
|
|
if (productShoppingCartIds == null || productShoppingCartIds.isEmpty()) {
|
|
if (productShoppingCartIds == null || productShoppingCartIds.isEmpty()) {
|
|
|
throw new IllegalArgumentException("购物车项ID不能为空");
|
|
throw new IllegalArgumentException("购物车项ID不能为空");
|
|
@@ -295,14 +294,14 @@ public class PcOrderController extends BaseController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 2. 构建 productId -> productNum 映射(防御性:过滤 null key)
|
|
// 2. 构建 productId -> productNum 映射(防御性:过滤 null key)
|
|
|
- shoppingCartList.stream()
|
|
|
|
|
|
|
+ productNumMap = shoppingCartList.stream()
|
|
|
.filter(item -> item.getProductId() != null && item.getProductNum() != null)
|
|
.filter(item -> item.getProductId() != null && item.getProductNum() != null)
|
|
|
.collect(Collectors.toMap(
|
|
.collect(Collectors.toMap(
|
|
|
RemoteProductShoppingCartVo::getProductId,
|
|
RemoteProductShoppingCartVo::getProductId,
|
|
|
RemoteProductShoppingCartVo::getProductNum,
|
|
RemoteProductShoppingCartVo::getProductNum,
|
|
|
(existing, replacement) -> existing // 防止重复 key 冲突(理论上不应发生)
|
|
(existing, replacement) -> existing // 防止重复 key 冲突(理论上不应发生)
|
|
|
));
|
|
));
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
productNumMap = bo.getProductInfo().stream()
|
|
productNumMap = bo.getProductInfo().stream()
|
|
|
.filter(item -> item.getProductId() != null && item.getProductNum() != null)
|
|
.filter(item -> item.getProductId() != null && item.getProductNum() != null)
|
|
|
.collect(Collectors.toMap(
|
|
.collect(Collectors.toMap(
|
|
@@ -358,9 +357,9 @@ public class PcOrderController extends BaseController {
|
|
|
if (orderId != null && orderId > 0) {
|
|
if (orderId != null && orderId > 0) {
|
|
|
//初始化审批流程
|
|
//初始化审批流程
|
|
|
orderCustomerFlowService.initOrderFlow(orderId);
|
|
orderCustomerFlowService.initOrderFlow(orderId);
|
|
|
- if(bo.getPlaceOrderType() == 1){
|
|
|
|
|
|
|
+ if (bo.getPlaceOrderType() == 1) {
|
|
|
// 成功下单后,删除对应的购物车项
|
|
// 成功下单后,删除对应的购物车项
|
|
|
- remoteProductShoppingCartService.deleteWithValidByIds(productShoppingCartIds);
|
|
|
|
|
|
|
+ remoteProductShoppingCartService.deleteWithValidByIds(bo.getProductShoppingCartId());
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
throw new RuntimeException("订单创建失败");
|
|
throw new RuntimeException("订单创建失败");
|