fix(shopping): 修复机型禁售检查逻辑并简化报价单复制功能
- 在机型选择时添加代理商身份验证,仅代理商需要检查禁售状态 - 移除报价单复制功能中的冗余代码,保留核心验证逻辑 - 添加报价配置状态检查,确保价格配置有效 - 简化复制报价单接口,移除复杂的配置转换和计算逻辑
This commit is contained in:
parent
464ea4dd04
commit
67cdfc393a
|
|
@ -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<Void> copyQuotation(@Valid @RequestBody QuotationCopyRequest request) {
|
||||
// QuotationShoppingOrder order = shoppingOrderService.getById(request.getId());
|
||||
// VUtils.trueThrowBusinessError(Objects.isNull(order)).throwMessage("未找到报价单");
|
||||
// List<QuotationShoppingOrderItem> 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<BigDecimal, BigDecimal> 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<ModelConfigEffectiveDTO> 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<ModelConfigEffectiveDTO> 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<Void> copyQuotation(@Valid @RequestBody QuotationCopyRequest request) {
|
||||
QuotationShoppingOrder order = shoppingOrderService.getById(request.getId());
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(order)).throwMessage("未找到报价单");
|
||||
List<QuotationShoppingOrderItem> 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 报价单-调价或者调整有效期
|
||||
|
|
|
|||
Loading…
Reference in New Issue