Przeglądaj źródła

refactor(order): 重构订单审核流程为客户订单流程服务

- 移除旧的 checkOrder 方法接口定义
- 添加 ServiceException、OrderCustomerFlowLink 和 OrderCustomerFlowNode 相关依赖
- 使用通配符导入 OrderMapper 相关类
- 注入 OrderCustomerFlowLinkMapper 和 OrderCustomerFlowNodeMapper 实例
- 在订单提交成功后调用 orderCustomerFlowService.initOrderFlow 初始化审批流程
- 将订单审核逻辑替换为客户订单流程审核逻辑
- 使用 OrderCustomerFlowLinkBo 封装审核数据并调用 auditOrderFlow 方法
hurx 1 miesiąc temu
rodzic
commit
e2aac45a56

+ 29 - 17
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/controller/pc/PcOrderController.java

@@ -1,5 +1,8 @@
 package org.dromara.order.controller.pc;
 
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import jakarta.validation.constraints.NotNull;
 import lombok.RequiredArgsConstructor;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.dromara.common.core.domain.R;
@@ -13,14 +16,14 @@ import org.dromara.common.satoken.utils.LoginHelper;
 import org.dromara.common.web.core.BaseController;
 import org.dromara.customer.api.RemoteCustomerService;
 import org.dromara.customer.api.domain.CustomerApiVo;
-import org.dromara.order.domain.bo.OrderMainBo;
-import org.dromara.order.domain.bo.OrderProductBo;
-import org.dromara.order.domain.bo.PcCheckOrderBo;
-import org.dromara.order.domain.bo.PcSubmitOrderBo;
+import org.dromara.order.domain.OrderCustomerFlowLink;
+import org.dromara.order.domain.bo.*;
 import org.dromara.order.domain.dto.OrderPayDto;
 import org.dromara.order.domain.vo.OrderMainVo;
 import org.dromara.order.domain.vo.OrderProductVo;
 import org.dromara.order.domain.vo.OrderStatusStats;
+import org.dromara.order.service.IOrderCustomerFlowLinkService;
+import org.dromara.order.service.IOrderCustomerFlowService;
 import org.dromara.order.service.IOrderMainService;
 import org.dromara.product.api.RemoteProductService;
 import org.dromara.product.api.RemoteProductShoppingCartService;
@@ -29,8 +32,6 @@ import org.dromara.product.api.domain.RemoteProductShoppingCartVo;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
-import jakarta.validation.constraints.NotNull;
-
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
@@ -61,6 +62,11 @@ public class PcOrderController extends BaseController {
     @DubboReference
     private RemoteProductShoppingCartService remoteProductShoppingCartService;
 
+    //客户订单流程
+    private final IOrderCustomerFlowService orderCustomerFlowService;
+
+    private final IOrderCustomerFlowLinkService orderCustomerFlowLinkService;
+
     private final IOrderMainService orderMainService;
 
     /**
@@ -310,6 +316,8 @@ public class PcOrderController extends BaseController {
             // 5. 保存订单(关键:成功后再删除购物车)
             Long orderId = orderMainService.insertByBo(mainBo);
             if (orderId != null && orderId > 0) {
+                //初始化审批流程
+                orderCustomerFlowService.initOrderFlow(orderId);
                 // 成功下单后,删除对应的购物车项
                 remoteProductShoppingCartService.deleteWithValidByIds(productShoppingCartIds);
             } else {
@@ -374,17 +382,21 @@ public class PcOrderController extends BaseController {
     @Log(title = "PC端-订单审核", businessType = BusinessType.UPDATE)
     @PostMapping("/checkOrder")
     public R<?> checkOrder(@RequestBody @Validated PcCheckOrderBo checkOrderBo) {
-        Long customerId = LoginHelper.getLoginUser().getCustomerId();
-
-        Long userId = LoginHelper.getLoginUser().getUserId();
-
-        // 调用 Service,返回结果
-        Boolean checkOrderResult = orderMainService.checkOrder(
-            customerId,
-            userId,
-            checkOrderBo
-        );
+//        Long customerId = LoginHelper.getLoginUser().getCustomerId();
+//
+//        Long userId = LoginHelper.getLoginUser().getUserId();
+
+        OrderCustomerFlowLinkBo bo = new OrderCustomerFlowLinkBo();
+        List<OrderCustomerFlowLink> flowLinks = orderCustomerFlowLinkService.list(new LambdaQueryWrapper<OrderCustomerFlowLink>().eq(OrderCustomerFlowLink::getOrderId, checkOrderBo.getOrderId()));
+        if (CollUtil.isNotEmpty(flowLinks)) {
+            bo.setNodeId(flowLinks.get(0).getNodeId());
+        }
+        bo.setOrderId(checkOrderBo.getOrderId());
+        bo.setReviewStatus(Long.valueOf(checkOrderBo.getCheckStatus()));
+        bo.setReason(checkOrderBo.getCheckRemark());
+        bo.setReason(checkOrderBo.getCheckRemark());
+        orderCustomerFlowService.auditOrderFlow(bo);
 
-        return R.ok(checkOrderResult);
+        return R.ok();
     }
 }

+ 0 - 2
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/IOrderMainService.java

@@ -82,8 +82,6 @@ public interface IOrderMainService extends IService<OrderMain> {
 
     Boolean orderPay(Long customerId, Long orderId, String payType);
 
-    Boolean checkOrder(Long customerId, Long userId, PcCheckOrderBo bo);
-
     /**
      * 修改订单审核状态
      *

+ 8 - 9
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderMainServiceImpl.java

@@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.dromara.common.core.enums.OrderPayType;
 import org.dromara.common.core.enums.OrderStatus;
+import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.PageQuery;
@@ -20,6 +21,8 @@ import org.dromara.common.redis.utils.SequenceUtils;
 import org.dromara.customer.api.RemoteCustomerSalesService;
 import org.dromara.customer.api.RemoteCustomerService;
 import org.dromara.customer.api.domain.vo.RemoteCustomerSalesVo;
+import org.dromara.order.domain.OrderCustomerFlowLink;
+import org.dromara.order.domain.OrderCustomerFlowNode;
 import org.dromara.order.domain.OrderMain;
 import org.dromara.order.domain.OrderProduct;
 import org.dromara.order.domain.bo.OrderMainBo;
@@ -29,10 +32,7 @@ import org.dromara.order.domain.dto.AssignmentStatsDto;
 import org.dromara.order.domain.vo.OrderMainVo;
 import org.dromara.order.domain.vo.OrderProductVo;
 import org.dromara.order.domain.vo.OrderStatusStats;
-import org.dromara.order.mapper.OrderDeliverMapper;
-import org.dromara.order.mapper.OrderDeliverProductMapper;
-import org.dromara.order.mapper.OrderMainMapper;
-import org.dromara.order.mapper.OrderProductMapper;
+import org.dromara.order.mapper.*;
 import org.dromara.order.service.IOrderMainService;
 import org.dromara.system.api.RemoteDeptService;
 import org.dromara.system.api.RemoteUserService;
@@ -75,6 +75,10 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
 
     private final OrderDeliverProductMapper orderDeliverProductMapper;
 
+    private final OrderCustomerFlowLinkMapper orderCustomerFlowLinkMapper;
+
+    private final OrderCustomerFlowNodeMapper orderCustomerFlowNodeMapper;
+
     /**
      * 查询订单主信息
      *
@@ -637,9 +641,4 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
 
         return updateSuccess;
     }
-
-    @Override
-    public Boolean checkOrder(Long customerId, Long userId, PcCheckOrderBo bo) {
-        return null;
-    }
 }