feat(shopping): 新增购物车其他要求及订单交付方式支持
- 在ShoppingCartVO中添加others字段以支持其他要求数据 - ShoppingController注入shoppingOrderDeliveryMethodService资源 - 购物车获取报价主体接口增加others数据加载 - 下单接口改用Convert转换request为QuotationShoppingOrder对象 - 设置订单编号、用户及时间信息,计算总费用及实际费用 - 保存订单项及新增订单交付方式批量保存逻辑 - 兼容无交付方式情况下的订单处理流程
This commit is contained in:
parent
0e2b46713f
commit
d751e6dbd3
|
|
@ -140,6 +140,9 @@ public class ShoppingController extends ControllerBase {
|
|||
@Resource
|
||||
private ITBaseDepartmentService departmentService;
|
||||
|
||||
@Resource
|
||||
private IQuotationShoppingOrderDeliveryMethodService shoppingOrderDeliveryMethodService;
|
||||
|
||||
/**
|
||||
* 购物车-获取报价主体
|
||||
*/
|
||||
|
|
@ -498,6 +501,10 @@ public class ShoppingController extends ControllerBase {
|
|||
.eq(QuotationShoppingCartService::getCartId, cart.getId())
|
||||
.list()
|
||||
);
|
||||
vo.setOthers(shoppingCartOtherService.lambdaQuery()
|
||||
.eq(QuotationShoppingCartOther::getCartId, cart.getId())
|
||||
.list()
|
||||
);
|
||||
return ApiResult.success(vo);
|
||||
}
|
||||
|
||||
|
|
@ -554,18 +561,19 @@ public class ShoppingController extends ControllerBase {
|
|||
.throwMessage("客户名称不一致");
|
||||
VUtils.trueThrowBusinessError(carts.stream().map(QuotationShoppingCart::getTargetId).collect(Collectors.toSet()).size() > 1)
|
||||
.throwMessage("报价主体不一致");
|
||||
QuotationShoppingOrder order = new QuotationShoppingOrder()
|
||||
.setCreateByType(AppUserUtil.isAgent() ? 1 : 0)
|
||||
.setCreateBy(AppUserUtil.getUserName())
|
||||
.setCreateById(AppUserUtil.getUserId())
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
.setId(IdUtil.getId())
|
||||
.setCustomerName(carts.get(0).getCustomerName())
|
||||
.setEffectiveStartTime(DateTimeUtil.format(LocalDate.now(), "yyyy-MM-dd"))
|
||||
.setEffectiveEndTime(DateTimeUtil.format(LocalDate.now().plusMonths(1), "yyyy-MM-dd"))
|
||||
.setQuotationCode(getQuotationCode())
|
||||
.setTargetId(carts.get(0).getTargetId())
|
||||
.setTotalFee(carts.stream().map(QuotationShoppingCart::getActualFee).reduce(BigDecimal::add).get());
|
||||
QuotationShoppingOrder order = Convert.convert(QuotationShoppingOrder.class, request);
|
||||
order.setId(IdUtil.getId());
|
||||
order.setNo(genOrderNo());
|
||||
order.setCreateByType(AppUserUtil.isAgent() ? 1 : 0);
|
||||
order.setCreateBy(AppUserUtil.getUserName());
|
||||
order.setCreateById(AppUserUtil.getUserId());
|
||||
order.setCreateTime(LocalDateTime.now());
|
||||
order.setCustomerName(carts.get(0).getCustomerName());
|
||||
order.setEffectiveStartTime(DateTimeUtil.format(LocalDate.now(), "yyyy-MM-dd"));
|
||||
order.setEffectiveEndTime(DateTimeUtil.format(LocalDate.now().plusMonths(1), "yyyy-MM-dd"));
|
||||
order.setQuotationCode(getQuotationCode());
|
||||
order.setTargetId(carts.get(0).getTargetId());
|
||||
order.setTotalFee(carts.stream().map(QuotationShoppingCart::getActualFee).reduce(BigDecimal::add).orElse(BigDecimal.ZERO));
|
||||
order.setActualFee(order.getTotalFee());
|
||||
order.setExchangeFee(NumberUtil.multiply(order.getActualFee(), request.getExchangeRate()));
|
||||
shoppingOrderItemService.saveBatch(
|
||||
|
|
@ -575,7 +583,17 @@ public class ShoppingController extends ControllerBase {
|
|||
.setCartId(cart.getId()))
|
||||
.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);
|
||||
shoppingCartService.lambdaUpdate()
|
||||
.set(QuotationShoppingCart::getStatus, 1)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.nflg.mobilebroken.quotation.pojo.vo;
|
||||
|
||||
import com.nflg.mobilebroken.repository.entity.QuotationShoppingCartAccessory;
|
||||
import com.nflg.mobilebroken.repository.entity.QuotationShoppingCartOther;
|
||||
import com.nflg.mobilebroken.repository.entity.QuotationShoppingCartService;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
|
@ -209,4 +210,9 @@ public class ShoppingCartVO {
|
|||
* 交机服务
|
||||
*/
|
||||
private List<QuotationShoppingCartService> services;
|
||||
|
||||
/**
|
||||
* 其他要求
|
||||
*/
|
||||
private List<QuotationShoppingCartOther> others;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue