From 492f57ebbe5de69c92edaa1e0da536c4f6fa54a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Mon, 25 May 2026 17:27:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(shopping):=20=E4=BF=AE=E5=A4=8D=E8=B4=AD?= =?UTF-8?q?=E7=89=A9=E8=BD=A6=E9=80=89=E9=85=8D=E4=BB=B6=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E5=8F=8A=E9=87=91=E9=A2=9D=E8=AE=A1=E7=AE=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 注释掉 ModelConfigSearchRequest 中 planId 的 @JsonIgnore 注解取消忽略 - 注释掉 PlanController 中根据 planId 设置请求参数的代码 - PriceConfigController 中标记价格配置是否可用字段 enable - 将 QuotationPriceUpdateItemRequest 中 parts 重命名为 optionalParts - 调整 QuotationUserPlanModelItemMapper 查询,优化关联表及条件 - 修复购物车金额计算,增加对children非空判断避免空指针 - 修改购物车选配件处理逻辑,支持 optionalParts 及相关购物车项更新 - 确保批量更新购物车选配和购物车本身数据 --- .../request/ModelConfigSearchRequest.java | 4 +- .../admin/PriceConfigController.java | 2 + .../controller/app/PlanController.java | 6 +- .../controller/app/ShoppingController.java | 62 ++++++++++++------- .../QuotationPriceUpdateItemRequest.java | 2 +- .../QuotationUserPlanModelItemMapper.xml | 12 ++-- 6 files changed, 53 insertions(+), 35 deletions(-) diff --git a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/ModelConfigSearchRequest.java b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/ModelConfigSearchRequest.java index 0d19481b..35ab2d69 100644 --- a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/ModelConfigSearchRequest.java +++ b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/request/ModelConfigSearchRequest.java @@ -28,6 +28,6 @@ public class ModelConfigSearchRequest extends PageRequest { */ private Long typeNumber; - @JsonIgnore - private Long planId; +// @JsonIgnore +// private Long planId; } diff --git a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/admin/PriceConfigController.java b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/admin/PriceConfigController.java index ed462d89..f15adc9c 100644 --- a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/admin/PriceConfigController.java +++ b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/admin/PriceConfigController.java @@ -130,6 +130,8 @@ public class PriceConfigController extends ControllerBase { md.put("children", new ArrayList<>()); vo.getChildren().forEach(item -> convert(md, item)); } + //是否可以配置价格 + md.put("enable", CollectionUtil.isEmpty(vo.getChildren())); } /** diff --git a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/PlanController.java b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/PlanController.java index 94d6f199..d298da88 100644 --- a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/PlanController.java +++ b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/PlanController.java @@ -154,9 +154,9 @@ public class PlanController extends ControllerBase { .eq(QuotationUserPlanModel::getCreateById, AppUserUtil.getUserId()) .one(); vo.setInfo(Convert.convert(QuotationModelRatioVO.class, plan)); - if (Objects.nonNull(plan)) { - request.setPlanId(plan.getId()); - } +// if (Objects.nonNull(plan)) { +// request.setPlanId(plan.getId()); +// } List items = planModelItemService.search(request, AppUserUtil.isAgent() ? 1 : 0, AppUserUtil.getUserId()); int index = 0, startIndex = (request.getPage() - 1) * request.getPageSize(), endIndex = request.getPage() * request.getPageSize(); PageData pageData = new PageData<>(); diff --git a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/ShoppingController.java b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/ShoppingController.java index ea60d269..8ca68098 100644 --- a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/ShoppingController.java +++ b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/ShoppingController.java @@ -514,15 +514,15 @@ public class ShoppingController extends ControllerBase { List children = parts.stream() .filter(pi -> pi.getParentId().equals(part.getId())) .collect(Collectors.toList()); - vi.setAmount( - vi.getAmount().add( - children.stream() - .map(ModelConfigEffectiveDTO::getAmount) - .filter(Objects::nonNull) - .reduce(BigDecimal::add) - .orElse(BigDecimal.ZERO) - ) - ); + if (CollectionUtil.isNotEmpty(children)) { + vi.setAmount( + children.stream() + .map(ModelConfigEffectiveDTO::getAmount) + .filter(Objects::nonNull) + .reduce(BigDecimal::add) + .orElse(BigDecimal.ZERO) + ); + } vi.setChildren( children.stream() .map(pi -> { @@ -816,15 +816,15 @@ public class ShoppingController extends ControllerBase { List children = parts.stream() .filter(pi -> pi.getParentId().equals(part.getId())) .collect(Collectors.toList()); - vi.setAmount( - vi.getAmount().add( - children.stream() - .filter(pi -> pi.getType() == 0) - .map(ModelConfigEffectiveDTO::getAmount) - .reduce(BigDecimal::add) - .orElse(BigDecimal.ZERO) - ) - ); + if (CollectionUtil.isNotEmpty(children)) { + vi.setAmount( + children.stream() + .filter(pi -> pi.getType() == 0) + .map(ModelConfigEffectiveDTO::getAmount) + .reduce(BigDecimal::add) + .orElse(BigDecimal.ZERO) + ); + } vi.setChildren( children.stream() .map(pi -> convert(pi, BigDecimal.ONE)) @@ -1072,15 +1072,29 @@ public class ShoppingController extends ControllerBase { .setOldFee(item.getOldStandardFee()) .setNewFee(item.getNewStandardFee()) ); - if (CollectionUtil.isNotEmpty(item.getParts())) { + if (CollectionUtil.isNotEmpty(item.getOptionalParts())) { cart.setOptionalFee(cart.getOptionalFee() - .add(item.getParts() + .add(item.getOptionalParts() .stream() .map(QuotationPriceUpdateItemPartRequest::getSpread) .reduce(BigDecimal.ZERO, BigDecimal::add) ) ); - item.getParts().forEach(part -> { + List optionalParts = shoppingCartItemService.lambdaQuery() + .eq(QuotationShoppingCartItem::getCartId, item.getCartId()) + .in(QuotationShoppingCartItem::getConfigItemId, item.getOptionalParts() + .stream() + .map(QuotationPriceUpdateItemPartRequest::getConfigItemId) + .collect(Collectors.toList()) + ) + .list(); + item.getOptionalParts().forEach(part -> { + QuotationShoppingCartItem optionalPart = optionalParts.stream() + .filter(p -> Objects.equals(p.getConfigItemId(), part.getConfigItemId())) + .findFirst() + .get(); + optionalPart.setAmount(part.getNewStandardFee()); + optionalPart.setDiscount(part.getSpread()); adjustItems.add( new QuotationShoppingOrderAdjustItem() .setAdjustId(adjust.getId()) @@ -1091,10 +1105,16 @@ public class ShoppingController extends ControllerBase { .setNewFee(part.getNewStandardFee()) ); }); + if (CollectionUtil.isNotEmpty(optionalParts)) { + shoppingCartItemService.updateBatchById(optionalParts); + } } }); shoppingOrderAdjustItemService.saveBatch(adjustItems); shoppingOrderAdjustService.save(adjust); + if (CollectionUtil.isNotEmpty(carts)) { + shoppingCartService.updateBatchById(carts); + } } shoppingOrderService.lambdaUpdate() .set(Objects.nonNull(request.getActualFee()), QuotationShoppingOrder::getActualFee, request.getActualFee()) diff --git a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/pojo/request/QuotationPriceUpdateItemRequest.java b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/pojo/request/QuotationPriceUpdateItemRequest.java index 496acea0..561402ca 100644 --- a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/pojo/request/QuotationPriceUpdateItemRequest.java +++ b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/pojo/request/QuotationPriceUpdateItemRequest.java @@ -32,5 +32,5 @@ public class QuotationPriceUpdateItemRequest { * 选配调价 */ @Valid - List parts; + List optionalParts; } diff --git a/nflg-mobilebroken-repository/src/main/resources/mapper/QuotationUserPlanModelItemMapper.xml b/nflg-mobilebroken-repository/src/main/resources/mapper/QuotationUserPlanModelItemMapper.xml index 783426a6..ef57007c 100644 --- a/nflg-mobilebroken-repository/src/main/resources/mapper/QuotationUserPlanModelItemMapper.xml +++ b/nflg-mobilebroken-repository/src/main/resources/mapper/QuotationUserPlanModelItemMapper.xml @@ -10,16 +10,12 @@