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(); + } /** * 报价单-调价或者调整有效期