From 67cdfc393aeed69448c47c6c1263f8ba4b66b606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 7 Apr 2026 09:02:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(shopping):=20=E4=BF=AE=E5=A4=8D=E6=9C=BA?= =?UTF-8?q?=E5=9E=8B=E7=A6=81=E5=94=AE=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=B9=B6=E7=AE=80=E5=8C=96=E6=8A=A5=E4=BB=B7=E5=8D=95=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在机型选择时添加代理商身份验证,仅代理商需要检查禁售状态 - 移除报价单复制功能中的冗余代码,保留核心验证逻辑 - 添加报价配置状态检查,确保价格配置有效 - 简化复制报价单接口,移除复杂的配置转换和计算逻辑 --- .../controller/app/ShoppingController.java | 155 +++--------------- 1 file changed, 20 insertions(+), 135 deletions(-) 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 f19dfd97..51524efd 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 @@ -161,7 +161,7 @@ public class ShoppingController extends ControllerBase { ProductModel model = productModelService.lambdaQuery().eq(ProductModel::getState, 1).eq(ProductModel::getNo, request.getModelNo()).one(); VUtils.trueThrowBusinessError(Objects.isNull(model)).throwMessage("未找到该机型"); request.setModelId(model.getBatchNumber()); - VUtils.trueThrowBusinessError(forbidService.isForbid(request.getModelId(), 1, request.getTargetId())) + VUtils.trueThrowBusinessError(AppUserUtil.isAgent() && forbidService.isForbid(request.getModelId(), 1, request.getTargetId())) .throwMessage("该机型已禁售"); ModelPrice1VO modelPrice = priceService.getModelPrice(request.getModelId(), categoryId); VUtils.trueThrowBusinessError(Objects.isNull(modelPrice)).throwMessage("该机型尚未设置价格"); @@ -713,140 +713,25 @@ public class ShoppingController extends ControllerBase { // return ApiResult.success(); // } -// /** -// * 报价单-复制报价单 -// */ -// @PostMapping("/quotation/copy") -// public ApiResult copyQuotation(@Valid @RequestBody QuotationCopyRequest request) { -// QuotationShoppingOrder order = shoppingOrderService.getById(request.getId()); -// VUtils.trueThrowBusinessError(Objects.isNull(order)).throwMessage("未找到报价单"); -// List orderItems = shoppingOrderItemService.lambdaQuery() -// .eq(QuotationShoppingOrderItem::getOrderId, request.getId()) -// .list(); -// VUtils.trueThrowBusinessError(orderItems.size() > 1).throwMessage("多机型报价单不能复制"); -// QuotationShoppingCart cart = shoppingCartService.getById(orderItems.get(0).getCartId()); -// ShoppingCartVO vo = new ShoppingCartVO() -// .setModelId(cart.getModelId()) -// .setTargetId(request.getTargetId()) -// .setCustomerName(request.getCustomerName()) -// .setPriceId(cart.getPriceId()) -// .setConfigId(cart.getConfigId()) -// .setTotalFee(cart.getAmount()) -// .setActualFee(cart.getAmount()); -// log.debug("机型【{}】售价为{}", request.getModelNo(), modelPrice); -// if (AppUserUtil.isAgent()) { -// //代理商 -// QuotationDiscountDTO discountDTO = discountService.getEffectiveForCustomer(request.getModelId(), request.getTargetId(), categoryId); -// if (Objects.nonNull(discountDTO)) { -// vo.setDiscountId(discountDTO.getDiscountId()); -// vo.setActualFee(vo.getTotalFee().multiply(discountDTO.getRatio())); -// vo.setDiscount(vo.getTotalFee().subtract(vo.getActualFee())); -// log.debug("机型【{}】打折后价格为{},优惠{}", request.getModelNo(), vo.getActualFee(), vo.getDiscount()); -// } -// } -// //系数 -// Pair pair = getRatio(request.getModelId()); -// BigDecimal standardRatio = pair.getLeft(), optionalRatio = pair.getRight(); -// log.debug("机型【{}】标准配件系数为{},可选配件系数为{}", request.getModelNo(), standardRatio, optionalRatio); -// if (!request.getShowLowestPrice()) { -// //方案 -// QuotationUserPlanModelItem planModelItem = userPlanModelItemService.getEffectiveForUser(request.getModelId(), AppUserUtil.isAgent() ? 1 : 0, AppUserUtil.getUserId()); -// if (Objects.nonNull(planModelItem)) { -// log.debug("机型【{}】方案为{},系数:{}", request.getModelNo(), planModelItem.getName(), planModelItem.getRatio()); -// standardRatio = NumberUtil.multiply(standardRatio, planModelItem.getRatio()); -// log.debug("机型【{}】标准配件系数为{},可选配件系数为{}", request.getModelNo(), standardRatio, optionalRatio); -// vo.setPlanItemId(planModelItem.getId()); -// } else { -// QuotationUserPlanDefault userPlanDefault = userPlanDefaultService.getEffectiveForUser(AppUserUtil.isAgent() ? 1 : 0, AppUserUtil.getUserId()); -// if (Objects.nonNull(userPlanDefault)) { -// log.debug("用户方案默认系数为{}", userPlanDefault.getRatio()); -// standardRatio = NumberUtil.multiply(standardRatio, userPlanDefault.getRatio()); -// log.debug("机型【{}】标准配件系数为{},可选配件系数为{}", request.getModelNo(), standardRatio, optionalRatio); -// } -// } -// } -// vo.setActualFee(vo.getTotalFee().subtract(vo.getDiscount()).multiply(standardRatio)); -// log.debug("机型【{}】价格为{},优惠{}", request.getModelNo(), vo.getActualFee(), vo.getDiscount()); -// //获取部件配置 -// List parts = modelConfigService.getEffectives(modelPrice.getPriceId(), categoryId, MultilingualUtil.getLanguage()); -// VUtils.trueThrowBusinessError(CollectionUtil.isEmpty(parts)).throwMessage("未获取到部件信息"); -// vo.setStandardParts(parts.stream() -// .filter(part -> part.getParentId() == 0L && part.getType() == 1) -// .map(part -> { -// ShoppingCartPartVO vi = convert(part, optionalRatio); -// vi.setChildren( -// parts.stream() -// .filter(pi -> pi.getParentId().equals(part.getId())) -// .map(pi -> convert(pi, optionalRatio)) -// .collect(Collectors.toList()) -// ); -// return vi; -// } -// ).collect(Collectors.toList()) -// ); -// vo.setOptionalParts(parts.stream() -// .filter(part -> part.getParentId() == 0L && part.getType() == 0) -// .map(part -> { -// ShoppingCartPartVO vi = convert(part, optionalRatio); -// vi.setChildren( -// parts.stream() -// .filter(pi -> pi.getParentId().equals(part.getId())) -// .map(pi -> convert(pi, optionalRatio)) -// .collect(Collectors.toList()) -// ); -// return vi; -// } -// ).collect(Collectors.toList()) -// ); -// vo.setStandardFee(vo.getActualFee()); -// return ApiResult.success(vo); -// carts.forEach(cart -> { -// QuotationShoppingOrderItem orderItem = orderItems.stream() -// .filter(item -> item.getCartId().equals(cart.getId())) -// .findFirst() -// .orElse(null); -// //获取部件配置 -// List parts = shoppingCartItemService.getSelectedParts(cart.getId(), MultilingualUtil.getLanguage()); -// -// -// cartVO.setStandardParts(parts.stream() -// .filter(part -> part.getParentId() == 0L && part.getType() == 1) -// .map(part -> { -// ShoppingCartPartVO vi = Convert.convert(ShoppingCartPartVO.class, part); -// vi.setAmount( -// vi.getAmount().add( -// parts.stream() -// .filter(pi -> pi.getParentId().equals(part.getId()) && pi.getType() == 0) -// .map(ModelConfigEffectiveDTO::getAmount) -// .reduce(BigDecimal::add) -// .orElse(BigDecimal.ZERO) -// ) -// ); -// return vi; -// } -// ).collect(Collectors.toList()) -// ); -// cartVO.setOptionalParts(parts.stream() -// .filter(part -> part.getParentId() == 0L && part.getType() == 0) -// .map(part -> { -// ShoppingCartPartVO vi = Convert.convert(ShoppingCartPartVO.class, part); -// vi.setAmount( -// vi.getAmount().add( -// parts.stream() -// .filter(pi -> pi.getParentId().equals(part.getId()) && pi.getType() == 0) -// .map(ModelConfigEffectiveDTO::getAmount) -// .reduce(BigDecimal::add) -// .orElse(BigDecimal.ZERO) -// ) -// ); -// return vi; -// } -// ).collect(Collectors.toList()) -// ); -// vo.getItems().add(cartVO); -// }); -// return ApiResult.success(vo); -// } + /** + * 报价单-复制报价单 + */ + @PostMapping("/quotation/copy") + public ApiResult copyQuotation(@Valid @RequestBody QuotationCopyRequest request) { + QuotationShoppingOrder order = shoppingOrderService.getById(request.getId()); + VUtils.trueThrowBusinessError(Objects.isNull(order)).throwMessage("未找到报价单"); + List orderItems = shoppingOrderItemService.lambdaQuery() + .eq(QuotationShoppingOrderItem::getOrderId, request.getId()) + .list(); + VUtils.trueThrowBusinessError(orderItems.size() > 1).throwMessage("多机型报价单不能复制"); + QuotationShoppingCart cart = shoppingCartService.getById(orderItems.get(0).getCartId()); + VUtils.trueThrowBusinessError(priceService.getById(cart.getPriceId()).getPriceStatus() != 1) + .throwMessage("报价配置已失效"); + VUtils.trueThrowBusinessError(AppUserUtil.isAgent() && forbidService.isForbid(cart.getModelId(), 1, request.getTargetId())) + .throwMessage("该机型已禁售"); + + return ApiResult.success(); + } /** * 报价单-调价或者调整有效期