Просмотр исходного кода

feat(order): 添加订单商品可用数量查询功能

- 在IOrderMainService中新增getOrderProductsWithAvailableQty方法
- 实现订单商品表中计算未退数量的SQL查询逻辑
- 添加OrderProductVo中availableQty字段用于显示可用数量
- 在OrderCustomerFlowServiceImpl中增加订单状态更新功能
- 修改OrderReturn相关实体类将afterSaleAmount类型从Long改为BigDecimal
- 在PcOrderController中新增获取订单商品可用数量的API接口
- 配置平台数据权限拦截器忽略订单退货相关表的权限控制
- 添加PC端退货原因管理控制器和相关接口
hurx 1 месяц назад
Родитель
Сommit
819710fcc0
14 измененных файлов с 177 добавлено и 35 удалено
  1. 3 1
      ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/interceptor/PlatformDataScopeInterceptor.java
  2. 26 0
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/controller/pc/PcOrderController.java
  3. 3 1
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/OrderReturn.java
  4. 1 1
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/bo/OrderReturnBo.java
  5. 5 0
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/vo/OrderProductVo.java
  6. 1 2
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/vo/OrderReturnItemVo.java
  7. 1 1
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/vo/OrderReturnVo.java
  8. 2 0
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/mapper/OrderProductMapper.java
  9. 5 5
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/IOrderMainService.java
  10. 22 14
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderCustomerFlowServiceImpl.java
  11. 7 4
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderMainServiceImpl.java
  12. 18 5
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderReturnServiceImpl.java
  13. 56 1
      ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderProductMapper.xml
  14. 27 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/pc/PcOrderReturnReasonController.java

+ 3 - 1
ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/interceptor/PlatformDataScopeInterceptor.java

@@ -94,7 +94,9 @@ public class PlatformDataScopeInterceptor implements Interceptor {
         "address_area",
         "supplier_",
         "supply_area",
-        "authorize_type_level"
+        "authorize_type_level",
+        "order_return",
+        "order_return_item"
 
 
         // 注意:前缀匹配需特殊处理(如 qrtz_),见 isIgnoreTable 方法

+ 26 - 0
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/controller/pc/PcOrderController.java

@@ -148,6 +148,32 @@ public class PcOrderController extends BaseController {
         return orderMainService.getCustomerOrderProductList(uniqueOrderIds);
     }
 
+    @GetMapping("/productsWithAvailableQty")
+    public TableDataInfo<OrderProductVo> getOrderProductsWithAvailableQty(@RequestParam("orderIds") List<Long> orderIds) {
+        if (orderIds == null || orderIds.isEmpty()) {
+            throw new IllegalArgumentException("订单ID列表不能为空");
+        }
+        if (orderIds.size() > 1000) {
+            throw new IllegalArgumentException("订单ID数量不能超过1000个");
+        }
+
+        // 获取当前登录用户的企业ID
+        Long customerId = LoginHelper.getLoginUser().getCustomerId();
+
+        // 验证所有订单是否都属于当前用户的企业
+        for (Long orderId : orderIds) {
+            OrderMainVo order = orderMainService.queryById(orderId);
+            if (order == null) {
+                throw new IllegalArgumentException("订单ID " + orderId + " 不存在");
+            }
+            if (!customerId.equals(order.getCustomerId())) {
+                throw new IllegalArgumentException("无权访问订单ID " + orderId);
+            }
+        }
+
+        return orderMainService.getOrderProductsWithAvailableQty(orderIds.get(0));
+    }
+
     /**
      * 取消订单
      * PC端用户只能取消自己企业的订单

+ 3 - 1
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/OrderReturn.java

@@ -4,8 +4,10 @@ import org.dromara.common.tenant.core.TenantEntity;
 import com.baomidou.mybatisplus.annotation.*;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+
 import java.math.BigDecimal;
 import java.util.Date;
+
 import com.fasterxml.jackson.annotation.JsonFormat;
 
 import java.io.Serial;
@@ -73,7 +75,7 @@ public class OrderReturn extends TenantEntity {
     /**
      * 售后金额
      */
-    private Long afterSaleAmount;
+    private BigDecimal afterSaleAmount;
 
     /**
      * 退货订单状态

+ 1 - 1
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/bo/OrderReturnBo.java

@@ -74,7 +74,7 @@ public class OrderReturnBo extends BaseEntity {
     /**
      * 售后金额
      */
-    private Long afterSaleAmount;
+    private BigDecimal afterSaleAmount;
 
     /**
      * 退货订单状态

+ 5 - 0
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/vo/OrderProductVo.java

@@ -198,6 +198,11 @@ public class OrderProductVo implements Serializable {
     @ExcelProperty(value = "售后申请数量")
     private Long afterSaleQuantity;
 
+    /**
+     * 未退数量
+     */
+    private Integer availableQty;
+
     /**
      * 退款金额(元)
      */

+ 1 - 2
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/vo/OrderReturnItemVo.java

@@ -1,6 +1,7 @@
 package org.dromara.order.domain.vo;
 
 import java.math.BigDecimal;
+
 import org.dromara.order.domain.OrderReturnItem;
 import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
 import cn.idev.excel.annotation.ExcelProperty;
@@ -14,7 +15,6 @@ import java.io.Serializable;
 import java.util.Date;
 
 
-
 /**
  * 退货商品明细视图对象 order_return_item
  *
@@ -96,5 +96,4 @@ public class OrderReturnItemVo implements Serializable {
     @ExcelProperty(value = "备注")
     private String remark;
 
-
 }

+ 1 - 1
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/vo/OrderReturnVo.java

@@ -92,7 +92,7 @@ public class OrderReturnVo implements Serializable {
      * 售后金额
      */
     @ExcelProperty(value = "售后金额")
-    private Long afterSaleAmount;
+    private BigDecimal afterSaleAmount;
 
     /**
      * 退货订单状态

+ 2 - 0
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/mapper/OrderProductMapper.java

@@ -23,6 +23,8 @@ public interface OrderProductMapper extends BaseMapperPlus<OrderProduct, OrderPr
     /*查询订单关联的商品列表--并且查询商品已发货数量与未发货数量*/
     List<OrderProductVo> selectProductsWithDelivered(@Param("orderId") Long orderId);
 
+    List<OrderProductVo> selectProductsWithAvailableQty(@Param("orderId") Long orderId);
+
     OrderQuantitySummary selectOrderAndDeliveredQuantity(@Param("orderId") Long orderId);
 
     void updatePlatformAndStatusByOrderIds(

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

@@ -1,14 +1,12 @@
 package org.dromara.order.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.order.domain.OrderMain;
-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.PcCheckOrderBo;
 import org.dromara.order.domain.vo.OrderMainVo;
-import org.dromara.order.domain.bo.OrderMainBo;
-import org.dromara.common.mybatis.core.page.TableDataInfo;
-import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.order.domain.vo.OrderProductVo;
 import org.dromara.order.domain.vo.OrderStatusStats;
 
@@ -51,6 +49,8 @@ public interface IOrderMainService extends IService<OrderMain> {
 
     TableDataInfo<OrderProductVo> getCustomerOrderProductList(Set<Long> orderIdList);
 
+    TableDataInfo<OrderProductVo> getOrderProductsWithAvailableQty(Long orderId);
+
     OrderStatusStats queryOrderStatusStats();
 
     /**

+ 22 - 14
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderCustomerFlowServiceImpl.java

@@ -2,6 +2,7 @@ package org.dromara.order.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
 import org.dromara.common.core.utils.MapstructUtils;
@@ -12,9 +13,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.extern.slf4j.Slf4j;
-import org.dromara.order.domain.OrderCustomerFlowLink;
-import org.dromara.order.domain.OrderCustomerFlowNodeLink;
+import org.dromara.order.domain.*;
 import org.dromara.order.domain.bo.OrderCustomerFlowLinkBo;
+import org.dromara.order.mapper.OrderMainMapper;
 import org.dromara.order.service.IOrderCustomerFlowLinkService;
 import org.dromara.order.service.IOrderCustomerFlowNodeLinkService;
 import org.springframework.stereotype.Service;
@@ -23,8 +24,6 @@ import org.dromara.order.domain.bo.OrderCustomerFlowSaveBo;
 import org.dromara.order.domain.bo.OrderCustomerFlowNodeBo;
 import org.dromara.order.domain.bo.OrderCustomerFlowNodeLinkBo;
 import org.dromara.order.domain.vo.OrderCustomerFlowVo;
-import org.dromara.order.domain.OrderCustomerFlow;
-import org.dromara.order.domain.OrderCustomerFlowNode;
 import org.dromara.order.domain.OrderCustomerFlowLink;
 import org.dromara.order.domain.OrderCustomerFlowNodeLink;
 import org.dromara.order.mapper.OrderCustomerFlowMapper;
@@ -45,10 +44,12 @@ import org.springframework.transaction.annotation.Transactional;
 @Slf4j
 @RequiredArgsConstructor
 @Service
-public class OrderCustomerFlowServiceImpl  extends ServiceImpl<OrderCustomerFlowMapper, OrderCustomerFlow> implements IOrderCustomerFlowService {
+public class OrderCustomerFlowServiceImpl extends ServiceImpl<OrderCustomerFlowMapper, OrderCustomerFlow> implements IOrderCustomerFlowService {
 
     private final OrderCustomerFlowMapper baseMapper;
 
+    private final OrderMainMapper orderMainMapper;
+
     private final IOrderCustomerFlowNodeService nodeService;
 
     private final IOrderCustomerFlowLinkService linkService;
@@ -56,8 +57,6 @@ public class OrderCustomerFlowServiceImpl  extends ServiceImpl<OrderCustomerFlow
     private final IOrderCustomerFlowNodeLinkService nodeLinkService;
 
 
-
-
     /**
      * 查询客户订单流程
      *
@@ -65,7 +64,7 @@ public class OrderCustomerFlowServiceImpl  extends ServiceImpl<OrderCustomerFlow
      * @return 客户订单流程
      */
     @Override
-    public OrderCustomerFlowVo queryById(Long id){
+    public OrderCustomerFlowVo queryById(Long id) {
         OrderCustomerFlowVo orderCustomerFlowVo = baseMapper.selectVoById(id);
         List<OrderCustomerFlowNode> orderCustomerFlowNodes = nodeService.list(Wrappers.lambdaQuery(OrderCustomerFlowNode.class).eq(OrderCustomerFlowNode::getFlowId, orderCustomerFlowVo.getId()));
         orderCustomerFlowVo.setFlowNodes(orderCustomerFlowNodes);
@@ -143,7 +142,7 @@ public class OrderCustomerFlowServiceImpl  extends ServiceImpl<OrderCustomerFlow
     /**
      * 保存前的数据校验
      */
-    private void validEntityBeforeSave(OrderCustomerFlow entity){
+    private void validEntityBeforeSave(OrderCustomerFlow entity) {
         //TODO 做一些数据校验,如唯一约束
     }
 
@@ -218,7 +217,7 @@ public class OrderCustomerFlowServiceImpl  extends ServiceImpl<OrderCustomerFlow
      */
     @Override
     public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
-        if(isValid){
+        if (isValid) {
             //TODO 做一些业务上的校验,判断是否需要校验
         }
         return baseMapper.deleteByIds(ids) > 0;
@@ -244,7 +243,7 @@ public class OrderCustomerFlowServiceImpl  extends ServiceImpl<OrderCustomerFlow
         List<OrderCustomerFlowNode> orderCustomerFlowNodes = nodeService.list(
             new LambdaQueryWrapper<OrderCustomerFlowNode>().eq(OrderCustomerFlowNode::getFlowId, flow.getId())
         );
-        if (ObjectUtil.isEmpty(orderCustomerFlowNodes)){
+        if (ObjectUtil.isEmpty(orderCustomerFlowNodes)) {
             return;
         }
         //
@@ -345,7 +344,6 @@ public class OrderCustomerFlowServiceImpl  extends ServiceImpl<OrderCustomerFlow
         );
 
 
-
         if (ObjectUtil.isEmpty(flowNodes)) {
             throw new RuntimeException("流程节点配置异常");
         }
@@ -388,7 +386,10 @@ public class OrderCustomerFlowServiceImpl  extends ServiceImpl<OrderCustomerFlow
             updateLink.setId(currentLink.getId());
             updateLink.setReviewStatus(1L); // 流程完成
 
-            linkService.updateById(updateLink);
+            boolean b = linkService.updateById(updateLink);
+            if (b) {
+                updateMainOrderStatus(orderId, updateLink.getReviewStatus().toString());
+            }
         }
     }
 
@@ -414,6 +415,13 @@ public class OrderCustomerFlowServiceImpl  extends ServiceImpl<OrderCustomerFlow
         // 比如:驳回到指定节点、重新提交等
 
         log.info("订单{}的节点{}被驳回,驳回原因:{}",
-                 currentLink.getOrderId(), currentLink.getNodeId(), bo.getReason());
+            currentLink.getOrderId(), currentLink.getNodeId(), bo.getReason());
+    }
+
+    private void updateMainOrderStatus(Long orderId, String status) {
+        LambdaUpdateWrapper<OrderMain> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.eq(OrderMain::getId, orderId)
+            .set(OrderMain::getCheckStatus, status);
+        orderMainMapper.update(null, updateWrapper);
     }
 }

+ 7 - 4
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderMainServiceImpl.java

@@ -12,7 +12,6 @@ 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;
@@ -21,13 +20,10 @@ 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;
 import org.dromara.order.domain.bo.OrderProductBo;
-import org.dromara.order.domain.bo.PcCheckOrderBo;
 import org.dromara.order.domain.dto.AssignmentStatsDto;
 import org.dromara.order.domain.vo.OrderMainVo;
 import org.dromara.order.domain.vo.OrderProductVo;
@@ -164,6 +160,13 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
         return TableDataInfo.build(orderProductVoList);
     }
 
+    @Override
+    public TableDataInfo<OrderProductVo> getOrderProductsWithAvailableQty(Long orderId) {
+
+        List<OrderProductVo> orderProductVoList = orderProductMapper.selectProductsWithAvailableQty(orderId);
+        return TableDataInfo.build(orderProductVoList);
+    }
+
     @Override
     public OrderStatusStats queryOrderStatusStats() {
         return baseMapper.selectOrderStatusCounts();

+ 18 - 5
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderReturnServiceImpl.java

@@ -1,16 +1,19 @@
 package org.dromara.order.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.redis.utils.SequenceUtils;
+import org.dromara.customer.api.RemoteCustomerService;
 import org.dromara.order.domain.OrderReturn;
 import org.dromara.order.domain.OrderReturnItem;
 import org.dromara.order.domain.bo.OrderReturnBo;
@@ -22,10 +25,8 @@ import org.dromara.order.service.IOrderReturnService;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.math.BigDecimal;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -39,6 +40,9 @@ import java.util.stream.Collectors;
 @Service
 public class OrderReturnServiceImpl extends ServiceImpl<OrderReturnMapper, OrderReturn> implements IOrderReturnService {
 
+    @DubboReference
+    private RemoteCustomerService remoteCustomerService;
+
     private final OrderReturnMapper baseMapper;
 
     private final OrderReturnItemMapper orderReturnItemMapper;
@@ -68,6 +72,14 @@ public class OrderReturnServiceImpl extends ServiceImpl<OrderReturnMapper, Order
     public TableDataInfo<OrderReturnVo> queryPageList(OrderReturnBo bo, PageQuery pageQuery) {
         LambdaQueryWrapper<OrderReturn> lqw = buildQueryWrapper(bo);
         Page<OrderReturnVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
+        List<OrderReturnVo> records = result.getRecords();
+        if (CollUtil.isNotEmpty(records)) {
+            Set<Long> customerIds = records.stream().map(OrderReturnVo::getCustomerId).collect(Collectors.toSet());
+            Map<Long, String> customerMap = remoteCustomerService.selectCustomerNameByIds(customerIds);
+            records.forEach(vo -> {
+                vo.setCustomerName(customerMap.get(vo.getCustomerId()));
+            });
+        }
         return TableDataInfo.build(result);
     }
 
@@ -146,7 +158,7 @@ public class OrderReturnServiceImpl extends ServiceImpl<OrderReturnMapper, Order
 
         // 生成单号
         bo.setReturnNo(SequenceUtils.generateOrderCode("OR"));
-
+        bo.setReturnTime(new Date());
         // 转换并校验
         OrderReturn entity = MapstructUtils.convert(bo, OrderReturn.class);
         validEntityBeforeSave(entity);
@@ -227,6 +239,7 @@ public class OrderReturnServiceImpl extends ServiceImpl<OrderReturnMapper, Order
         List<OrderReturnItem> items = itemList.stream()
             .filter(Objects::nonNull) // 防止空元素
             .map(bo -> {
+                bo.setTotalAmount(bo.getUnitPrice().multiply(new BigDecimal(bo.getReturnQuantity())));
                 OrderReturnItem item = MapstructUtils.convert(bo, OrderReturnItem.class);
                 item.setReturnId(orderReturnId);
                 return item;

+ 56 - 1
ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderProductMapper.xml

@@ -79,7 +79,7 @@
         FROM order_product
         WHERE order_id = #{orderId}
           AND assignment_status != '1'
-      AND del_flag = '0'
+       AND del_flag = '0'
     </select>
 
     <select id="getAssignmentStats" resultType="org.dromara.order.domain.dto.AssignmentStatsDto">
@@ -116,4 +116,59 @@
         AND del_flag = '0'
     </select>
 
+    <select id="selectProductsWithAvailableQty" resultType="org.dromara.order.domain.vo.OrderProductVo">
+        SELECT
+        op.id,
+        op.order_id AS orderId,
+        op.order_no AS orderNo,
+        op.shipment_no AS shipmentNo,
+        op.product_id AS productId,
+        op.product_no AS productNo,
+        op.product_name AS productName,
+        op.product_unit AS productUnit,
+        op.product_image AS productImage,
+        op.platform_price AS platformPrice,
+        op.min_order_quantity AS minOrderQuantity,
+        op.order_price AS orderPrice,
+        op.order_quantity AS orderQuantity,
+        op.subtotal AS subtotal,
+        op.min_selling_price AS minSellingPrice,
+        op.signed_quantity AS signedQuantity,
+
+        op.is_after_sale AS isAfterSale,
+        op.after_sale_quantity AS afterSaleQuantity,
+        op.return_amount AS returnAmount,
+        op.pre_delivery_date AS preDeliveryDate,
+        op.assignment_status AS assignmentStatus,
+        op.status AS status,
+        op.del_flag AS delFlag,
+        op.remark AS remark,
+
+        <!-- 【核心修正】计算未退数量 (availableQty) -->
+        <!-- 逻辑:订购数量 - (有效退货单中的退货数量之和) -->
+        GREATEST(
+        0,
+        COALESCE(op.order_quantity, 0) - COALESCE(SUM(ori.return_quantity), 0)
+        ) AS availableQty
+
+        FROM order_product op
+
+        <!-- 【核心修正】关联退货明细 -->
+        LEFT JOIN order_return_item ori ON ori.order_product_id = op.id
+        AND ori.del_flag = '0'  <!-- 过滤已删除的明细 -->
+        <!-- 【关键】只关联状态有效的退货单 (排除已取消、已拒绝) -->
+        AND ori.return_id IN (
+        SELECT orm.id
+        FROM order_return orm
+        WHERE orm.order_id = op.order_id
+        AND orm.del_flag = '0'
+        AND orm.return_status NOT IN ('2','4')
+        )
+
+        WHERE op.order_id = #{orderId}
+        AND op.del_flag = '0'
+
+        GROUP BY op.id
+        ORDER BY op.id
+    </select>
 </mapper>

+ 27 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/pc/PcOrderReturnReasonController.java

@@ -0,0 +1,27 @@
+package org.dromara.system.controller.pc;
+
+import lombok.RequiredArgsConstructor;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.web.core.BaseController;
+import org.dromara.system.domain.bo.OrderReturnReasonBo;
+import org.dromara.system.domain.vo.OrderReturnReasonVo;
+import org.dromara.system.service.IOrderReturnReasonService;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/pcOrderReturnReason")
+public class PcOrderReturnReasonController extends BaseController {
+
+    private final IOrderReturnReasonService orderReturnReasonService;
+
+    @GetMapping("/list")
+    public TableDataInfo<OrderReturnReasonVo> list(PageQuery pageQuery) {
+        return orderReturnReasonService.queryPageList(new OrderReturnReasonBo(), pageQuery);
+    }
+}