|
@@ -33,12 +33,10 @@ import org.dromara.external.api.zhongche.RemoteZhongChePullService;
|
|
|
import org.dromara.external.api.zhongche.domain.bo.OrderConfirmBo;
|
|
import org.dromara.external.api.zhongche.domain.bo.OrderConfirmBo;
|
|
|
import org.dromara.external.api.zhongche.domain.bo.OrderRejectBo;
|
|
import org.dromara.external.api.zhongche.domain.bo.OrderRejectBo;
|
|
|
import org.dromara.external.api.zhongche.domain.vo.GoodsUpdateVo;
|
|
import org.dromara.external.api.zhongche.domain.vo.GoodsUpdateVo;
|
|
|
-import org.dromara.order.domain.OrderDeliver;
|
|
|
|
|
-import org.dromara.order.domain.OrderMain;
|
|
|
|
|
-import org.dromara.order.domain.OrderMainCrrcExt;
|
|
|
|
|
-import org.dromara.order.domain.OrderProduct;
|
|
|
|
|
|
|
+import org.dromara.order.domain.*;
|
|
|
import org.dromara.order.domain.bo.OrderMainBo;
|
|
import org.dromara.order.domain.bo.OrderMainBo;
|
|
|
import org.dromara.order.domain.bo.OrderProductBo;
|
|
import org.dromara.order.domain.bo.OrderProductBo;
|
|
|
|
|
+import org.dromara.order.domain.bo.OrderSplitAssignBo;
|
|
|
import org.dromara.order.domain.bo.PcSubmitOrderBo;
|
|
import org.dromara.order.domain.bo.PcSubmitOrderBo;
|
|
|
import org.dromara.order.domain.dto.AssignmentStatsDto;
|
|
import org.dromara.order.domain.dto.AssignmentStatsDto;
|
|
|
import org.dromara.order.domain.vo.*;
|
|
import org.dromara.order.domain.vo.*;
|
|
@@ -48,7 +46,9 @@ import org.dromara.order.utils.kd100.Kd100Util;
|
|
|
import org.dromara.order.utils.kd100.domain.QueryTrackDTO;
|
|
import org.dromara.order.utils.kd100.domain.QueryTrackDTO;
|
|
|
import org.dromara.order.utils.kd100.domain.TrackData;
|
|
import org.dromara.order.utils.kd100.domain.TrackData;
|
|
|
import org.dromara.order.utils.kd100.domain.TrackVO;
|
|
import org.dromara.order.utils.kd100.domain.TrackVO;
|
|
|
|
|
+import org.dromara.product.api.RemoteProductService;
|
|
|
import org.dromara.product.api.RemoteProductShoppingCartService;
|
|
import org.dromara.product.api.RemoteProductShoppingCartService;
|
|
|
|
|
+import org.dromara.product.api.domain.ProductVo;
|
|
|
import org.dromara.system.api.*;
|
|
import org.dromara.system.api.*;
|
|
|
import org.dromara.system.api.model.LoginUser;
|
|
import org.dromara.system.api.model.LoginUser;
|
|
|
import org.mybatis.spring.MyBatisSystemException;
|
|
import org.mybatis.spring.MyBatisSystemException;
|
|
@@ -110,6 +110,9 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
|
|
|
@DubboReference
|
|
@DubboReference
|
|
|
private RemoteProductShoppingCartService remoteProductShoppingCartService;
|
|
private RemoteProductShoppingCartService remoteProductShoppingCartService;
|
|
|
|
|
|
|
|
|
|
+ @DubboReference
|
|
|
|
|
+ private RemoteProductService remoteProductService;
|
|
|
|
|
+
|
|
|
private final IOrderCustomerFlowLinkService orderCustomerFlowLinkService;
|
|
private final IOrderCustomerFlowLinkService orderCustomerFlowLinkService;
|
|
|
|
|
|
|
|
private final IOrderCustomerFlowNodeLinkService orderCustomerFlowNodeLinkService;
|
|
private final IOrderCustomerFlowNodeLinkService orderCustomerFlowNodeLinkService;
|
|
@@ -136,6 +139,8 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
|
|
|
@DubboReference
|
|
@DubboReference
|
|
|
private final RemoteZhongChePullService zhongChePullService;
|
|
private final RemoteZhongChePullService zhongChePullService;
|
|
|
|
|
|
|
|
|
|
+ private final IOrderAssignmentService orderAssignmentService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询订单主信息
|
|
* 查询订单主信息
|
|
|
*
|
|
*
|
|
@@ -698,6 +703,68 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
|
|
|
if (existingOrder == null) {
|
|
if (existingOrder == null) {
|
|
|
throw new ServiceException("订单不存在");
|
|
throw new ServiceException("订单不存在");
|
|
|
}
|
|
}
|
|
|
|
|
+ String platformCode = PlatformContext.getPlatform();
|
|
|
|
|
+ // 判断是否为 market 平台,且是未拆分的子订单
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(platformCode)
|
|
|
|
|
+ && "market".equals(platformCode)
|
|
|
|
|
+ && SysPlatformYesNo.NO.getCode().equals(existingOrder.getIsSplitChild())
|
|
|
|
|
+ // 确保订单还未被拆分过,防止重复拆分
|
|
|
|
|
+ ) {
|
|
|
|
|
+
|
|
|
|
|
+ log.info("Market平台订单确认,开始处理自营商品拆分,订单ID: {}", orderId);
|
|
|
|
|
+ // 1. 提取所有订单商品ID
|
|
|
|
|
+ List<Long> orderProductIds = updatedProducts.stream()
|
|
|
|
|
+ .map(OrderProductBo::getId)
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ List<OrderProductVo> orderProductVoList = orderProductMapper.selectVoByIds(orderProductIds);
|
|
|
|
|
+ // 1. 提取所有商品ID
|
|
|
|
|
+ List<Long> productIds = orderProductVoList.stream()
|
|
|
|
|
+ .map(OrderProductVo::getProductId)
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ if (CollUtil.isNotEmpty(productIds)) {
|
|
|
|
|
+ // 2. 一次性获取所有商品详情 (避免循环查库)
|
|
|
|
|
+ List<ProductVo> productDetails = remoteProductService.getProductDetails(productIds);
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 构建 自营商品ID -> ProductVo 的映射
|
|
|
|
|
+ // 假设 getIsSelf() 返回 Integer, 1 代表自营
|
|
|
|
|
+ Map<Long, ProductVo> selfProductMap = productDetails.stream()
|
|
|
|
|
+ .filter(p -> Integer.valueOf(1).equals(p.getIsSelf()))
|
|
|
|
|
+ .collect(Collectors.toMap(ProductVo::getId, Function.identity()));
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 如果存在自营商品,则构建分配规则
|
|
|
|
|
+ if (!selfProductMap.isEmpty()) {
|
|
|
|
|
+ OrderSplitAssignBo assignBo = new OrderSplitAssignBo();
|
|
|
|
|
+ assignBo.setOrderId(orderId);
|
|
|
|
|
+ assignBo.setRemark("Market平台自动拆分自营订单");
|
|
|
|
|
+
|
|
|
|
|
+ List<OrderProductAssignRule> rules = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ for (OrderProductVo bo : orderProductVoList) {
|
|
|
|
|
+ Long productId = bo.getProductId();
|
|
|
|
|
+ // 如果该商品是自营商品
|
|
|
|
|
+ if (selfProductMap.containsKey(productId)) {
|
|
|
|
|
+ OrderProductAssignRule rule = new OrderProductAssignRule();
|
|
|
|
|
+ rule.setItemId(bo.getId()); // 设置订单商品行ID
|
|
|
|
|
+ // 假设自营商品分配给特定的供应商ID,或者设置为 CUSTOMER 类型
|
|
|
|
|
+ rule.setAssigneeId(null);
|
|
|
|
|
+ rule.setAssigneeType(AssigneeTypeConstants.CUSTOMER.getCode());
|
|
|
|
|
+ rules.add(rule);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!rules.isEmpty()) {
|
|
|
|
|
+ assignBo.setItemRules(rules);
|
|
|
|
|
+ // 调用分配服务进行拆单
|
|
|
|
|
+ orderAssignmentService.splitAssign(assignBo);
|
|
|
|
|
+ log.info("订单 {} 的自营商品已成功拆分为新子单", orderId);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 2. 检查当前状态:只允许从“待确认”(比如状态0或1)变为“待发货”(2)
|
|
// 2. 检查当前状态:只允许从“待确认”(比如状态0或1)变为“待发货”(2)
|
|
|
if (!OrderStatus.PENDING_PAYMENT.getCode().equals(existingOrder.getOrderStatus()) && !OrderStatus.PENDING_CONFIRMATION.getCode().equals(existingOrder.getOrderStatus())) {
|
|
if (!OrderStatus.PENDING_PAYMENT.getCode().equals(existingOrder.getOrderStatus()) && !OrderStatus.PENDING_CONFIRMATION.getCode().equals(existingOrder.getOrderStatus())) {
|