|
|
@@ -32,16 +32,16 @@ import org.dromara.order.domain.OrderMainCrrcExt;
|
|
|
import org.dromara.order.domain.OrderProduct;
|
|
|
import org.dromara.order.domain.bo.OrderMainBo;
|
|
|
import org.dromara.order.domain.bo.OrderProductBo;
|
|
|
+import org.dromara.order.domain.bo.PcSubmitOrderBo;
|
|
|
import org.dromara.order.domain.dto.AssignmentStatsDto;
|
|
|
import org.dromara.order.domain.vo.*;
|
|
|
import org.dromara.order.mapper.*;
|
|
|
-import org.dromara.order.service.IOrderDeliverService;
|
|
|
-import org.dromara.order.service.IOrderMainCrrcExtService;
|
|
|
-import org.dromara.order.service.IOrderMainService;
|
|
|
+import org.dromara.order.service.*;
|
|
|
import org.dromara.order.utils.kd100.Kd100Util;
|
|
|
import org.dromara.order.utils.kd100.domain.QueryTrackDTO;
|
|
|
import org.dromara.order.utils.kd100.domain.TrackData;
|
|
|
import org.dromara.order.utils.kd100.domain.TrackVO;
|
|
|
+import org.dromara.product.api.RemoteProductShoppingCartService;
|
|
|
import org.dromara.system.api.RemoteComLogisticsCompanyService;
|
|
|
import org.dromara.system.api.RemoteDeptService;
|
|
|
import org.dromara.system.api.RemoteUserService;
|
|
|
@@ -79,6 +79,16 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
|
|
|
@DubboReference
|
|
|
private RemoteCustomerSalesService remoteCustomerSalesService;
|
|
|
|
|
|
+ //客户订单流程
|
|
|
+ private final IOrderCustomerFlowService orderCustomerFlowService;
|
|
|
+
|
|
|
+ @DubboReference
|
|
|
+ private RemoteProductShoppingCartService remoteProductShoppingCartService;
|
|
|
+
|
|
|
+ private final IOrderCustomerFlowLinkService orderCustomerFlowLinkService;
|
|
|
+
|
|
|
+ private final IOrderCustomerFlowNodeLinkService orderCustomerFlowNodeLinkService;
|
|
|
+
|
|
|
private final OrderMainMapper baseMapper;
|
|
|
|
|
|
private final OrderProductMapper orderProductMapper;
|
|
|
@@ -465,6 +475,35 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Long insertOrder(PcSubmitOrderBo bo, OrderMainBo mainBo) {
|
|
|
+ // 1. 插入主订单,获取生成的 ID
|
|
|
+ Long orderId = this.insertByBo(mainBo);
|
|
|
+
|
|
|
+ // 2. 校验插入是否成功
|
|
|
+ if (orderId != null && orderId > 0) {
|
|
|
+ // 3. 初始化审批流程
|
|
|
+ Boolean initOrderFlow = orderCustomerFlowService.initOrderFlow(orderId);
|
|
|
+
|
|
|
+ // 4. 如果流程初始化成功,更新订单状态 (注意:这里再次触发了数据库更新)
|
|
|
+ if (initOrderFlow) {
|
|
|
+ this.update(Wrappers.lambdaUpdate(OrderMain.class)
|
|
|
+ .eq(OrderMain::getId, orderId)
|
|
|
+ .set(OrderMain::getOrderStatus, 1)); // 假设 1 代表某种特定状态,需确认枚举值
|
|
|
+ }
|
|
|
+
|
|
|
+ // 5. 如果是从购物车下单,删除购物车数据
|
|
|
+ if (bo.getPlaceOrderType() == 1) {
|
|
|
+ remoteProductShoppingCartService.deleteWithValidByIds(bo.getProductShoppingCartId());
|
|
|
+ }
|
|
|
+
|
|
|
+ return orderId;
|
|
|
+ } else {
|
|
|
+ // 插入失败,抛出异常触发事务回滚
|
|
|
+ throw new RuntimeException("订单创建失败:未能生成有效的订单ID");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 订单确认
|
|
|
@@ -724,20 +763,35 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean batchConfirmation(Set<Long> ids) {
|
|
|
- // 2. 参数校验
|
|
|
+ // 1. 参数校验
|
|
|
if (CollectionUtils.isEmpty(ids)) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ // 将 Set 转为 List 以便 Wrapper 使用 (MyBatis-Plus in 方法通常接受 Collection)
|
|
|
+ List<Long> idList = new ArrayList<>(ids);
|
|
|
+
|
|
|
+ // 2. 构造更新条件
|
|
|
LambdaUpdateWrapper<OrderMain> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.in(OrderMain::getId, ids)
|
|
|
- .eq(OrderMain::getOrderStatus, OrderStatus.SHIPPED.getCode()) // 只有已发货的订单才能确认收货
|
|
|
- .set(OrderMain::getOrderStatus, OrderStatus.COMPLETED.getCode());
|
|
|
|
|
|
- // 执行更新
|
|
|
- boolean updateSuccess = this.update(updateWrapper);
|
|
|
+ // 设置更新后的值
|
|
|
+ updateWrapper.set(OrderMain::getOrderStatus, OrderStatus.COMPLETED.getCode());
|
|
|
+
|
|
|
+ // 构建 WHERE 条件逻辑:
|
|
|
+ // (id IN (...) OR parentOrderId IN (...)) AND orderStatus = SHIPPED
|
|
|
+ updateWrapper.and(wrapper -> wrapper
|
|
|
+ .in(OrderMain::getId, idList)
|
|
|
+ .or()
|
|
|
+ .in(OrderMain::getParentOrderId, idList)
|
|
|
+ )
|
|
|
+ // 只有已发货的订单才能确认收货 (同时限制父单和子单的原状态)
|
|
|
+ .eq(OrderMain::getOrderStatus, OrderStatus.SHIPPED.getCode());
|
|
|
+
|
|
|
+ // 3. 执行更新
|
|
|
+ // 如果至少有一行被更新,则视为成功
|
|
|
+ int updateCount = baseMapper.update(updateWrapper);
|
|
|
|
|
|
- return updateSuccess;
|
|
|
+ return updateCount > 0;
|
|
|
}
|
|
|
|
|
|
@Override
|