Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

Lijingyang před 1 měsícem
rodič
revize
72b4ff794f
16 změnil soubory, kde provedl 260 přidání a 93 odebrání
  1. 6 1
      ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/enums/AssigneeTypeConstants.java
  2. 39 21
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/controller/CustomerInfoController.java
  3. 2 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/SupplyArea.java
  4. 2 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/SupplyAreaBo.java
  5. 6 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/dto/SetCustomerInfoTagDto.java
  6. 2 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/SupplyAreaVo.java
  7. 14 4
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/ICustomerInfoService.java
  8. 105 0
      ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerInfoServiceImpl.java
  9. 1 2
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/controller/pc/PcOrderEvaluationHeaderController.java
  10. 5 0
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/OrderMain.java
  11. 5 0
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/bo/OrderMainBo.java
  12. 5 0
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/vo/OrderMainVo.java
  13. 3 3
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/IOrderEvaluationHeaderService.java
  14. 2 2
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderAssignmentServiceImpl.java
  15. 59 36
      ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderEvaluationHeaderServiceImpl.java
  16. 4 24
      ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMainMapper.xml

+ 6 - 1
ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/enums/AssigneeTypeConstants.java

@@ -15,7 +15,12 @@ public enum AssigneeTypeConstants {
     /**
      * 伙伴商
      */
-    PARTNER("bp", "伙伴商");
+    PARTNER("bp", "伙伴商"),
+
+    /**
+     * 伙伴商
+     */
+    CUSTOMER("zy", "自营客户");
 
 
     private final String code;

+ 39 - 21
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/controller/CustomerInfoController.java

@@ -1,33 +1,33 @@
 package org.dromara.customer.controller;
 
-import java.util.Collection;
-import java.util.List;
-
-import lombok.RequiredArgsConstructor;
 import jakarta.servlet.http.HttpServletResponse;
-import jakarta.validation.constraints.*;
-import cn.dev33.satoken.annotation.SaCheckPermission;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import lombok.RequiredArgsConstructor;
+import org.dromara.common.core.domain.R;
 import org.dromara.common.core.utils.StringUtils;
-import org.dromara.customer.domain.CustomerSalesInfo;
-import org.dromara.customer.domain.bo.CustomerSalesInfoBo;
-import org.dromara.customer.domain.bo.CustomerListBo;
-import org.dromara.customer.domain.bo.MessagePublishCustomerBo;
-import org.dromara.customer.domain.dto.SetCustomerInfoTagDto;
-import org.dromara.customer.domain.vo.*;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.validation.annotation.Validated;
+import org.dromara.common.core.validate.AddGroup;
+import org.dromara.common.excel.utils.ExcelUtil;
 import org.dromara.common.idempotent.annotation.RepeatSubmit;
 import org.dromara.common.log.annotation.Log;
-import org.dromara.common.web.core.BaseController;
-import org.dromara.common.mybatis.core.page.PageQuery;
-import org.dromara.common.core.domain.R;
-import org.dromara.common.core.validate.AddGroup;
-import org.dromara.common.core.validate.EditGroup;
 import org.dromara.common.log.enums.BusinessType;
-import org.dromara.common.excel.utils.ExcelUtil;
+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.customer.domain.bo.CustomerInfoBo;
+import org.dromara.customer.domain.bo.CustomerListBo;
+import org.dromara.customer.domain.bo.CustomerSalesInfoBo;
+import org.dromara.customer.domain.bo.MessagePublishCustomerBo;
+import org.dromara.customer.domain.dto.SetCustomerInfoTagDto;
+import org.dromara.customer.domain.vo.ContractVo;
+import org.dromara.customer.domain.vo.CustomerInfoVo;
+import org.dromara.customer.domain.vo.CustomerListVo;
+import org.dromara.customer.domain.vo.MessagePublishCustomerVo;
 import org.dromara.customer.service.ICustomerInfoService;
-import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 /**
  * 客户信息
@@ -184,4 +184,22 @@ public class CustomerInfoController extends BaseController {
     public R<Void> setCustomerInfoTag(@RequestBody SetCustomerInfoTagDto bo) {
         return toAjax(customerInfoService.setCustomerInfoTag(bo.getCustomerIds(), bo.getTagIds()));
     }
+
+    /**
+     * 转移业务人员
+     */
+    @Log(title = "客户信息", businessType = BusinessType.UPDATE)
+    @PutMapping("/transferSalesPerson")
+    public R<Integer> transferSalesPerson(@RequestBody SetCustomerInfoTagDto bo) {
+        return R.ok(customerInfoService.transferSalesPerson(bo.getCustomerIds(), bo.getSalesPersonId(), bo.getDeptId()));
+    }
+
+    /**
+     * 转移客服人员
+     */
+    @Log(title = "客户信息", businessType = BusinessType.UPDATE)
+    @PutMapping("/transferServiceStaff")
+    public R<Integer> transferServiceStaff(@RequestBody SetCustomerInfoTagDto bo) {
+        return R.ok(customerInfoService.transferServiceStaff(bo.getCustomerIds(), bo.getServiceStaffId()));
+    }
 }

+ 2 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/SupplyArea.java

@@ -52,6 +52,8 @@ public class SupplyArea extends TenantEntity {
 
     private Long parentId;
 
+    private String parentCode;
+
     /**
      * 区域层级(1省/直辖市 2市 3区县 4街道/镇)
      */

+ 2 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/bo/SupplyAreaBo.java

@@ -49,6 +49,8 @@ public class SupplyAreaBo extends BaseEntity {
 
     private Long parentId;
 
+    private String parentCode;
+
     /**
      * 区域层级(1省/直辖市 2市 3区县 4街道/镇)
      */

+ 6 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/dto/SetCustomerInfoTagDto.java

@@ -10,4 +10,10 @@ public class SetCustomerInfoTagDto implements Serializable {
     private List<Long> customerIds;
 
     private List<Long> tagIds;
+
+    private Long deptId;
+
+    private Long salesPersonId;
+
+    private Long serviceStaffId;
 }

+ 2 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/vo/SupplyAreaVo.java

@@ -67,6 +67,8 @@ public class SupplyAreaVo implements Serializable {
     @ExcelDictFormat(readConverterExp = "如=省级编码对应市级的上级编码,顶级区域为0")
     private Long parentId;
 
+    private String parentCode;
+
     /**
      * 区域层级(1省/直辖市 2市 3区县 4街道/镇)
      */

+ 14 - 4
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/ICustomerInfoService.java

@@ -1,14 +1,17 @@
 package org.dromara.customer.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.customer.domain.CustomerInfo;
+import org.dromara.customer.domain.bo.CustomerInfoBo;
 import org.dromara.customer.domain.bo.CustomerListBo;
 import org.dromara.customer.domain.bo.CustomerRegisterBo;
 import org.dromara.customer.domain.bo.MessagePublishCustomerBo;
-import org.dromara.customer.domain.vo.*;
-import org.dromara.customer.domain.bo.CustomerInfoBo;
-import org.dromara.common.mybatis.core.page.TableDataInfo;
-import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.customer.domain.vo.ContractVo;
+import org.dromara.customer.domain.vo.CustomerInfoVo;
+import org.dromara.customer.domain.vo.CustomerListVo;
+import org.dromara.customer.domain.vo.MessagePublishCustomerVo;
 
 import java.math.BigDecimal;
 import java.util.Collection;
@@ -112,6 +115,13 @@ public interface ICustomerInfoService extends IService<CustomerInfo> {
     /*设置客户标签*/
     int setCustomerInfoTag(List<Long> customerIds, List<Long> tagIds);
 
+    /*客户转移业务人员*/
+    int transferSalesPerson(List<Long> customerIds, Long salesPersonId, Long deptId);
+
+    /*客户转移客服人员*/
+    int transferServiceStaff(List<Long> customerIds, Long serviceStaffId);
+
+
     Map<Long, String> selectCustomerNameByIds(Set<Long> ids);
 
     /**

+ 105 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerInfoServiceImpl.java

@@ -1051,4 +1051,109 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
         log.info("客户注册成功,客户ID:{},客户名称:{}", customerId, bo.getCustomerName());
         return true;
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int transferSalesPerson(List<Long> customerIds, Long salesPersonId, Long deptId) {
+        if (CollUtil.isEmpty(customerIds)) {
+            log.warn("转移业务人员失败,客户 ID 列表为空");
+            return 0;
+        }
+
+        if (salesPersonId == null || deptId == null) {
+            log.warn("转移业务人员失败,业务人员 ID 或部门 ID 为空");
+            throw new ServiceException("业务人员和所属部门不能为空");
+        }
+
+        try {
+            List<CustomerSalesInfo> updateList = new ArrayList<>();
+            CustomerSalesInfo salesInfo = null;
+            for (Long customerId : customerIds) {
+                if (customerId == null) {
+                    continue;
+                }
+
+                salesInfo = customerSalesInfoMapper.selectByCustomerId(customerId);
+                if (salesInfo != null) {
+                    salesInfo.setSalesPersonId(salesPersonId);
+                    salesInfo.setBelongingDepartmentId(deptId);
+                    updateList.add(salesInfo);
+                } else {
+                    log.warn("客户 ID: {} 的销售信息不存在,跳过更新", customerId);
+                }
+            }
+
+            if (!updateList.isEmpty()) {
+                boolean success = customerSalesInfoMapper.updateBatchById(updateList);
+                if (success) {
+                    log.info("成功转移 {} 个客户的业务人员,目标业务员 ID: {}, 部门 ID: {}",
+                        updateList.size(), salesPersonId, deptId);
+                    return updateList.size();
+                } else {
+                    log.error("批量更新销售信息失败");
+                    throw new ServiceException("批量更新销售信息失败");
+                }
+            }
+
+            log.info("没有需要更新的客户销售信息");
+            return 0;
+
+        } catch (Exception e) {
+            log.error("转移业务人员失败,客户 IDs: {}, 业务员 ID: {}, 部门 ID: {}, 错误:{}",
+                customerIds, salesPersonId, deptId, e.getMessage(), e);
+            throw new ServiceException("转移业务人员失败:" + e.getMessage());
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int transferServiceStaff(List<Long> customerIds, Long serviceStaffId) {
+        if (CollUtil.isEmpty(customerIds)) {
+            log.warn("转移客服人员失败,客户 ID 列表为空");
+            return 0;
+        }
+
+        if (serviceStaffId == null) {
+            log.warn("转移客服人员失败,客服人员 ID 为空");
+            throw new ServiceException("客服人员和不能为空");
+        }
+
+        try {
+            List<CustomerSalesInfo> updateList = new ArrayList<>();
+            CustomerSalesInfo salesInfo = null;
+            for (Long customerId : customerIds) {
+                if (customerId == null) {
+                    continue;
+                }
+
+                salesInfo = customerSalesInfoMapper.selectByCustomerId(customerId);
+                if (salesInfo != null) {
+                    salesInfo.setServiceStaffId(serviceStaffId);
+                    updateList.add(salesInfo);
+                } else {
+                    log.warn("客户 ID: {} 的销售信息不存在,跳过更新", customerId);
+                }
+            }
+
+            if (!updateList.isEmpty()) {
+                boolean success = customerSalesInfoMapper.updateBatchById(updateList);
+                if (success) {
+                    log.info("成功转移 {} 个客户的客服人员,目标客服人员 ID: {}",
+                        updateList.size(), serviceStaffId);
+                    return updateList.size();
+                } else {
+                    log.error("批量更新销售信息失败");
+                    throw new ServiceException("批量更新销售信息失败");
+                }
+            }
+
+            log.info("没有需要更新的客户销售信息");
+            return 0;
+
+        } catch (Exception e) {
+            log.error("转移客服人员失败,客户 IDs: {}, 客服人员 ID: {},  错误:{}",
+                customerIds, serviceStaffId, e.getMessage(), e);
+            throw new ServiceException("转移客服人员失败:" + e.getMessage());
+        }
+    }
 }

+ 1 - 2
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/controller/pc/PcOrderEvaluationHeader.java → ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/controller/pc/PcOrderEvaluationHeaderController.java

@@ -10,7 +10,6 @@ import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.satoken.utils.LoginHelper;
 import org.dromara.common.web.core.BaseController;
-import org.dromara.order.domain.bo.OrderEvaluationBo;
 import org.dromara.order.domain.bo.OrderEvaluationHeaderBo;
 import org.dromara.order.domain.vo.OrderEvaluationHeaderVo;
 import org.dromara.order.domain.vo.OrderEvaluationListVo;
@@ -22,7 +21,7 @@ import org.springframework.web.bind.annotation.*;
 @RequiredArgsConstructor
 @RestController
 @RequestMapping("/pcOrderEvaluationHeader")
-public class PcOrderEvaluationHeader extends BaseController {
+public class PcOrderEvaluationHeaderController extends BaseController {
 
     private final IOrderEvaluationHeaderService orderEvaluationHeaderService;
 

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

@@ -290,4 +290,9 @@ public class OrderMain extends TenantEntity {
      */
     private String assigneeType;
 
+    /**
+     * 评价状态:0-待评价,1-待追评,2-已评价
+     */
+    private Integer evaluationStatus;
+
 }

+ 5 - 0
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/domain/bo/OrderMainBo.java

@@ -295,6 +295,11 @@ public class OrderMainBo extends BaseEntity {
      */
     private String orderStatuses;
 
+    /**
+     * 评价状态:0-待评价,1-待追评,2-已评价
+     */
+    private Integer evaluationStatus;
+
     List<OrderProductBo> orderProductBos;
 
 

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

@@ -407,5 +407,10 @@ public class OrderMainVo implements Serializable {
     //包裹数量
     private Long packageNum;
 
+    /**
+     * 评价状态:0-待评价,1-待追评,2-已评价
+     */
+    private Integer evaluationStatus;
+
 
 }

+ 3 - 3
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/IOrderEvaluationHeaderService.java

@@ -1,11 +1,11 @@
 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.OrderEvaluationHeader;
-import org.dromara.order.domain.vo.OrderEvaluationHeaderVo;
 import org.dromara.order.domain.bo.OrderEvaluationHeaderBo;
-import org.dromara.common.mybatis.core.page.TableDataInfo;
-import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.order.domain.vo.OrderEvaluationHeaderVo;
 import org.dromara.order.domain.vo.OrderEvaluationListVo;
 
 import java.util.Collection;

+ 2 - 2
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderAssignmentServiceImpl.java

@@ -41,7 +41,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
-import java.time.Duration;
 import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -284,7 +283,8 @@ public class OrderAssignmentServiceImpl extends ServiceImpl<OrderAssignmentMappe
             }
             String type = rule.getAssigneeType();
             if (!AssigneeTypeConstants.SUPPLIER.getCode().equals(type) &&
-                !AssigneeTypeConstants.PARTNER.getCode().equals(type)) {
+                !AssigneeTypeConstants.PARTNER.getCode().equals(type) &&
+                !AssigneeTypeConstants.CUSTOMER.getCode().equals(type)) {
                 throw new ServiceException("分配对象类型不支持: " + type);
             }
         }

+ 59 - 36
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderEvaluationHeaderServiceImpl.java

@@ -1,30 +1,34 @@
 package org.dromara.order.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+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.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.TableDataInfo;
 import org.dromara.common.mybatis.core.page.PageQuery;
-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.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.order.domain.OrderEvaluationHeader;
 import org.dromara.order.domain.OrderEvaluationItem;
+import org.dromara.order.domain.OrderMain;
+import org.dromara.order.domain.OrderProduct;
+import org.dromara.order.domain.bo.OrderEvaluationHeaderBo;
 import org.dromara.order.domain.bo.OrderEvaluationItemBo;
+import org.dromara.order.domain.vo.OrderEvaluationHeaderVo;
 import org.dromara.order.domain.vo.OrderEvaluationItemVo;
 import org.dromara.order.domain.vo.OrderEvaluationListVo;
 import org.dromara.order.domain.vo.OrderProductBriefVo;
+import org.dromara.order.mapper.OrderEvaluationHeaderMapper;
 import org.dromara.order.mapper.OrderEvaluationItemMapper;
+import org.dromara.order.mapper.OrderMainMapper;
 import org.dromara.order.mapper.OrderProductMapper;
-import org.springframework.beans.BeanUtils;
-import org.springframework.stereotype.Service;
-import org.dromara.order.domain.bo.OrderEvaluationHeaderBo;
-import org.dromara.order.domain.vo.OrderEvaluationHeaderVo;
-import org.dromara.order.domain.OrderEvaluationHeader;
-import org.dromara.order.mapper.OrderEvaluationHeaderMapper;
 import org.dromara.order.service.IOrderEvaluationHeaderService;
+import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
@@ -41,6 +45,8 @@ import java.util.stream.Collectors;
 @Service
 public class OrderEvaluationHeaderServiceImpl extends ServiceImpl<OrderEvaluationHeaderMapper, OrderEvaluationHeader> implements IOrderEvaluationHeaderService {
 
+    private final OrderMainMapper orderMainMapper;
+
     private final OrderEvaluationHeaderMapper baseMapper;
 
     private final OrderEvaluationItemMapper itemMapper;
@@ -130,43 +136,48 @@ public class OrderEvaluationHeaderServiceImpl extends ServiceImpl<OrderEvaluatio
 
     @Override
     public TableDataInfo<OrderEvaluationListVo> getEvaluationOrderList(Long customerId, String evaluationStatus, PageQuery pageQuery) {
-        // 1. 创建分页对象
-        Page<OrderEvaluationListVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
 
-        // 2. 调用 Mapper
-        // ⚠️ 重点检查这里:参数顺序必须是 (page, customerId, evaluationStatus)
-        // 如果你之前传成了 (page, pageQuery, evaluationStatus) 或者其他组合,就会报这个错!
-        Page<OrderEvaluationListVo> resultPage = baseMapper.selectEvaluationOrderListPage(
-            page,
-            customerId,
-            evaluationStatus // 确保这里传的是 String 类型的 "0", "1", "2" 或 null,而不是对象
-        );
-
-        List<OrderEvaluationListVo> orders = resultPage.getRecords();
+        if (evaluationStatus != null && "2".equals(evaluationStatus)) {
+            evaluationStatus = "1";
+        }
+        // 1. 分页查询主订单(含评价状态)
+        IPage<OrderEvaluationListVo> page = orderMainMapper.selectEvaluationMainListPage(pageQuery.build(), customerId, evaluationStatus);
+        List<OrderEvaluationListVo> orders = page.getRecords();
 
         if (!orders.isEmpty()) {
-            // 3. 提取当前页所有订单 ID
+            // 2. 批量查商品(仅当前页的订单ID)
             List<Long> orderIds = orders.stream()
                 .map(OrderEvaluationListVo::getOrderId)
                 .collect(Collectors.toList());
 
-            // 4. 批量查询这些订单下的商品列表
+            List<OrderProduct> products = orderProductMapper.selectByOrderIds(orderIds);
 
-            List<OrderProductBriefVo> allProducts = orderProductMapper.selectBriefListByOrderIds(orderIds);
+            // 3. 按 orderId 分组
+            Map<Long, List<OrderProduct>> productMap = products.stream()
+                .collect(Collectors.groupingBy(OrderProduct::getOrderId));
 
-            // 5. 按 orderId 分组商品 (Key: orderId, Value: List<Product>)
-            Map<Long, List<OrderProductBriefVo>> productMap = allProducts.stream()
-                .collect(Collectors.groupingBy(OrderProductBriefVo::getOrderId));
-
-            // 6. 将商品列表组装到对应订单的 productList 字段
+            // 4. 转换并赋值
             for (OrderEvaluationListVo order : orders) {
-                List<OrderProductBriefVo> productList = productMap.getOrDefault(order.getOrderId(), Collections.emptyList());
-                order.setProductList(productList);
+                List<OrderProduct> list = productMap.get(order.getOrderId());
+                if (list != null) {
+                    List<OrderProductBriefVo> briefs = list.stream().map(p -> {
+                        OrderProductBriefVo b = new OrderProductBriefVo();
+                        b.setProductName(p.getProductName());
+                        b.setQuantity(p.getOrderQuantity());
+                        b.setUnitPrice(p.getOrderPrice());
+                        b.setSubtotal(p.getSubtotal());
+                        b.setProductImage(p.getProductImage());
+                        return b;
+                    }).collect(Collectors.toList());
+                    order.setProductList(briefs);
+                } else {
+                    order.setProductList(Collections.emptyList());
+                }
             }
         }
 
-        // 7. 构建返回结果
-        return TableDataInfo.build(resultPage);
+        // 5. 构造分页返回对象
+        return TableDataInfo.build(page);
     }
 
     /**
@@ -259,6 +270,18 @@ public class OrderEvaluationHeaderServiceImpl extends ServiceImpl<OrderEvaluatio
                 throw new ServiceException("评价明细保存失败");
             }
         }
+        // 更新 order_main 表的评价状态为:1 (待追评)
+        LambdaUpdateWrapper<OrderMain> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.eq(OrderMain::getId, bo.getOrderId())
+            .eq(OrderMain::getEvaluationStatus, 0) // 可
+            .set(OrderMain::getEvaluationStatus, 1); // 1 = 待追评
+
+        int updateCount = orderMainMapper.update(null, updateWrapper);
+        if (updateCount == 0) {
+            // 如果更新行数为 0,可能是订单ID不对,或者状态已经被别人改了
+            log.warn("首次评价后更新订单状态失败,orderId: {}, 可能状态已变更", bo.getOrderId());
+            throw new ServiceException("同步更新订单状态失败");
+        }
 
         bo.setId(evaluationId);
         return true;

+ 4 - 24
ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMainMapper.xml

@@ -22,36 +22,16 @@
         o.order_time AS orderTime,
         o.total_amount AS totalAmount,
         o.order_status as orderStatus,
-        CASE
-        WHEN oe.max_type IS NULL THEN '0'
-        WHEN oe.max_type = 1 THEN '1'
-        WHEN oe.max_type = 2 THEN '2'
-        ELSE '0'
-        END AS evaluationStatus
+        o.evaluation_status AS evaluationStatus -- 直接查字段
         FROM order_main o
-        LEFT JOIN (
-        SELECT order_id, MAX(evaluation_type) AS max_type
-        FROM order_evaluation_header --
-        WHERE del_flag = '0'
-        GROUP BY order_id
-        ) oe ON o.id = oe.order_id
         WHERE
         o.customer_id = #{customerId}
         AND o.order_status = '5'
         AND o.del_flag = '0'
 
-        <choose>
-            <when test="evaluationStatus != null and evaluationStatus == '0'">
-                AND oe.max_type IS NULL
-            </when>
-            <when test="evaluationStatus != null and evaluationStatus == '1'">
-                AND oe.max_type = 1
-            </when>
-            <when test="evaluationStatus != null and evaluationStatus == '2'">
-                AND oe.max_type = 2
-            </when>
-            <!-- 如果 evaluationStatus 为空或为其他值,则不过滤评价状态,返回所有 -->
-        </choose>
+        <if test="evaluationStatus != null and evaluationStatus != ''">
+            AND o.evaluation_status = #{evaluationStatus}
+        </if>
 
         ORDER BY o.order_time DESC
     </select>