| | |
| | | package com.linghu.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.linghu.model.dto.KeywordDto; |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.linghu.service.QuestionService; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | private KeywordService keywordService; |
| | | @Autowired |
| | | private QuestionService questionService; |
| | | @Autowired |
| | | private OrderMapper orderMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | } |
| | | return keywordDtos; |
| | | } |
| | | |
| | | @Override |
| | | public Page<String> getClientList(String clientName, Integer pageNum, Integer pageSize) { |
| | | Page<Orders> page = new Page<>(pageNum, pageSize); |
| | | |
| | | // 构建查询条件(根据客户名称模糊搜索) |
| | | LambdaQueryWrapper<Orders> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.select(Orders::getClient_name) // 只查询客户名称字段 |
| | | .eq(Orders::getDel_flag, 0) // 只查询未删除的订单 |
| | | .groupBy(Orders::getClient_name); // 按客户名称分组去重 |
| | | |
| | | if (clientName != null && !clientName.isEmpty()) { |
| | | queryWrapper.like(Orders::getClient_name, clientName); |
| | | } |
| | | |
| | | // 执行分页查询 |
| | | IPage<Orders> orderPage = orderMapper.selectPage(page, queryWrapper); |
| | | |
| | | // 转换为客户选项列表(统计每个客户的订单数量) |
| | | List<String> clientOptions = orderPage.getRecords().stream() |
| | | .map(order -> { |
| | | |
| | | |
| | | return order.getClient_name(); |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 构建结果分页对象 |
| | | Page<String> resultPage = new Page<>(); |
| | | resultPage.setCurrent(orderPage.getCurrent()); |
| | | resultPage.setSize(orderPage.getSize()); |
| | | resultPage.setTotal(orderPage.getTotal()); |
| | | resultPage.setRecords(clientOptions); |
| | | |
| | | return resultPage; |
| | | |
| | | |
| | | } |
| | | } |