feat(shopping): 新增购物车其他要求及订单交付方式支持

- 在ShoppingCartVO中添加others字段以支持其他要求数据
- ShoppingController注入shoppingOrderDeliveryMethodService资源
- 购物车获取报价主体接口增加others数据加载
- 下单接口改用Convert转换request为QuotationShoppingOrder对象
- 设置订单编号、用户及时间信息,计算总费用及实际费用
- 保存订单项及新增订单交付方式批量保存逻辑
- 兼容无交付方式情况下的订单处理流程
This commit is contained in:
曹鹏飞 2026-05-15 14:00:49 +08:00
parent 0e2b46713f
commit d751e6dbd3
2 changed files with 37 additions and 13 deletions

View File

@ -140,6 +140,9 @@ public class ShoppingController extends ControllerBase {
@Resource @Resource
private ITBaseDepartmentService departmentService; private ITBaseDepartmentService departmentService;
@Resource
private IQuotationShoppingOrderDeliveryMethodService shoppingOrderDeliveryMethodService;
/** /**
* 购物车-获取报价主体 * 购物车-获取报价主体
*/ */
@ -498,6 +501,10 @@ public class ShoppingController extends ControllerBase {
.eq(QuotationShoppingCartService::getCartId, cart.getId()) .eq(QuotationShoppingCartService::getCartId, cart.getId())
.list() .list()
); );
vo.setOthers(shoppingCartOtherService.lambdaQuery()
.eq(QuotationShoppingCartOther::getCartId, cart.getId())
.list()
);
return ApiResult.success(vo); return ApiResult.success(vo);
} }
@ -554,18 +561,19 @@ public class ShoppingController extends ControllerBase {
.throwMessage("客户名称不一致"); .throwMessage("客户名称不一致");
VUtils.trueThrowBusinessError(carts.stream().map(QuotationShoppingCart::getTargetId).collect(Collectors.toSet()).size() > 1) VUtils.trueThrowBusinessError(carts.stream().map(QuotationShoppingCart::getTargetId).collect(Collectors.toSet()).size() > 1)
.throwMessage("报价主体不一致"); .throwMessage("报价主体不一致");
QuotationShoppingOrder order = new QuotationShoppingOrder() QuotationShoppingOrder order = Convert.convert(QuotationShoppingOrder.class, request);
.setCreateByType(AppUserUtil.isAgent() ? 1 : 0) order.setId(IdUtil.getId());
.setCreateBy(AppUserUtil.getUserName()) order.setNo(genOrderNo());
.setCreateById(AppUserUtil.getUserId()) order.setCreateByType(AppUserUtil.isAgent() ? 1 : 0);
.setCreateTime(LocalDateTime.now()) order.setCreateBy(AppUserUtil.getUserName());
.setId(IdUtil.getId()) order.setCreateById(AppUserUtil.getUserId());
.setCustomerName(carts.get(0).getCustomerName()) order.setCreateTime(LocalDateTime.now());
.setEffectiveStartTime(DateTimeUtil.format(LocalDate.now(), "yyyy-MM-dd")) order.setCustomerName(carts.get(0).getCustomerName());
.setEffectiveEndTime(DateTimeUtil.format(LocalDate.now().plusMonths(1), "yyyy-MM-dd")) order.setEffectiveStartTime(DateTimeUtil.format(LocalDate.now(), "yyyy-MM-dd"));
.setQuotationCode(getQuotationCode()) order.setEffectiveEndTime(DateTimeUtil.format(LocalDate.now().plusMonths(1), "yyyy-MM-dd"));
.setTargetId(carts.get(0).getTargetId()) order.setQuotationCode(getQuotationCode());
.setTotalFee(carts.stream().map(QuotationShoppingCart::getActualFee).reduce(BigDecimal::add).get()); order.setTargetId(carts.get(0).getTargetId());
order.setTotalFee(carts.stream().map(QuotationShoppingCart::getActualFee).reduce(BigDecimal::add).orElse(BigDecimal.ZERO));
order.setActualFee(order.getTotalFee()); order.setActualFee(order.getTotalFee());
order.setExchangeFee(NumberUtil.multiply(order.getActualFee(), request.getExchangeRate())); order.setExchangeFee(NumberUtil.multiply(order.getActualFee(), request.getExchangeRate()));
shoppingOrderItemService.saveBatch( shoppingOrderItemService.saveBatch(
@ -575,7 +583,17 @@ public class ShoppingController extends ControllerBase {
.setCartId(cart.getId())) .setCartId(cart.getId()))
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
order.setNo(genOrderNo()); if (CollectionUtil.isNotEmpty(request.getDeliveryMethods())) {
shoppingOrderDeliveryMethodService.saveBatch(
request.getDeliveryMethods().stream()
.map(deliveryMethod -> {
QuotationShoppingOrderDeliveryMethod dm = Convert.convert(QuotationShoppingOrderDeliveryMethod.class, deliveryMethod);
dm.setOrderId(order.getId());
return dm;
})
.collect(Collectors.toList())
);
}
shoppingOrderService.save(order); shoppingOrderService.save(order);
shoppingCartService.lambdaUpdate() shoppingCartService.lambdaUpdate()
.set(QuotationShoppingCart::getStatus, 1) .set(QuotationShoppingCart::getStatus, 1)

View File

@ -1,6 +1,7 @@
package com.nflg.mobilebroken.quotation.pojo.vo; package com.nflg.mobilebroken.quotation.pojo.vo;
import com.nflg.mobilebroken.repository.entity.QuotationShoppingCartAccessory; import com.nflg.mobilebroken.repository.entity.QuotationShoppingCartAccessory;
import com.nflg.mobilebroken.repository.entity.QuotationShoppingCartOther;
import com.nflg.mobilebroken.repository.entity.QuotationShoppingCartService; import com.nflg.mobilebroken.repository.entity.QuotationShoppingCartService;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@ -209,4 +210,9 @@ public class ShoppingCartVO {
* 交机服务 * 交机服务
*/ */
private List<QuotationShoppingCartService> services; private List<QuotationShoppingCartService> services;
/**
* 其他要求
*/
private List<QuotationShoppingCartOther> others;
} }