fix:订单列表按照ID降序排序,补充分页条件

This commit is contained in:
chenxiky 2025-07-26 15:53:46 +08:00
parent c7ade06d75
commit 8cb37d0e8a
4 changed files with 24 additions and 9 deletions

View File

@ -35,6 +35,8 @@ import com.aircraft.modules.system.service.IAttachmentMaterialService;
import com.aircraft.utils.RedisUtils; import com.aircraft.utils.RedisUtils;
import com.aircraft.utils.SecurityUtils; import com.aircraft.utils.SecurityUtils;
import com.aircraft.utils.enums.UserTypeEnum; import com.aircraft.utils.enums.UserTypeEnum;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -83,7 +85,7 @@ public class OrderBiz {
@Resource @Resource
private AircraftDeviceService aircraftDeviceService; private AircraftDeviceService aircraftDeviceService;
public List<OrderMainPageQueryVO> queryAll(OrderMainPageQueryDTO pageQueryDTO) { public IPage<OrderMainPageQueryVO> queryAll(OrderMainPageQueryDTO pageQueryDTO, Page page) {
// 根据不同的客户端获取数据 // 根据不同的客户端获取数据
UserTypeEnum currentUserType = SecurityUtils.getCurrentUserType(); UserTypeEnum currentUserType = SecurityUtils.getCurrentUserType();
@ -106,7 +108,7 @@ public class OrderBiz {
break; break;
} }
if (CollectionUtil.isEmpty(orderMainList)) { if (CollectionUtil.isEmpty(orderMainList)) {
return new ArrayList<>(); return new Page<>();
} }
// 查询发起人信息 // 查询发起人信息
@ -143,7 +145,20 @@ public class OrderBiz {
pageQueryVO.setCustomerPhone(orderMain.getPhone()); pageQueryVO.setCustomerPhone(orderMain.getPhone());
orderMainPageList.add(pageQueryVO); orderMainPageList.add(pageQueryVO);
} }
return orderMainPageList; // 内存分页
Page<OrderMainPageQueryVO> pageResult = new Page<>(page.getCurrent(), page.getSize());
pageResult.setTotal(orderMainPageList.size());
// 计算分页起始和结束位置
long start = (page.getCurrent() - 1) * page.getSize();
long end = Math.min(start + page.getSize(), orderMainPageList.size());
// 如果起始位置超出了数据总量则返回空列表
if (start >= orderMainPageList.size()) {
pageResult.setRecords(new ArrayList<>());
} else {
// 截取当前页数据
pageResult.setRecords(orderMainPageList.subList((int) start, (int) end));
}
return pageResult;
} }
/** /**

View File

@ -8,8 +8,8 @@ import com.aircraft.modules.order.domain.dto.OrderMainPageQueryDTO;
import com.aircraft.modules.order.domain.dto.UpdateOrderDTO; import com.aircraft.modules.order.domain.dto.UpdateOrderDTO;
import com.aircraft.modules.order.domain.vo.OrderAllDetailVO; import com.aircraft.modules.order.domain.vo.OrderAllDetailVO;
import com.aircraft.modules.order.domain.vo.OrderMainPageQueryVO; import com.aircraft.modules.order.domain.vo.OrderMainPageQueryVO;
import com.aircraft.utils.PageResult; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.aircraft.utils.PageUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
@ -19,7 +19,6 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
/** /**
* <p> * <p>
@ -39,9 +38,8 @@ public class OrderMainController {
@ApiOperation("查询订单列表-多端查询") @ApiOperation("查询订单列表-多端查询")
@GetMapping("/allOrder") @GetMapping("/allOrder")
public ResponseEntity<PageResult<OrderMainPageQueryVO>> queryOrderList(OrderMainPageQueryDTO pageQueryDTO) { public ResponseEntity<IPage<OrderMainPageQueryVO>>queryOrderList(OrderMainPageQueryDTO pageQueryDTO, Page page) {
List<OrderMainPageQueryVO> orderList = orderBiz.queryAll(pageQueryDTO); return new ResponseEntity<>(orderBiz.queryAll(pageQueryDTO, page), HttpStatus.OK);
return new ResponseEntity<>(PageUtil.toPage(orderList),HttpStatus.OK);
} }
@ApiOperation("新增订单") @ApiOperation("新增订单")

View File

@ -42,6 +42,7 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
queryWrapper.le(ObjectUtil.isNotNull(pageQueryDTO.getQueryEndTime()), OrderMain::getOrderCreateTime, pageQueryDTO.getQueryEndTime()); queryWrapper.le(ObjectUtil.isNotNull(pageQueryDTO.getQueryEndTime()), OrderMain::getOrderCreateTime, pageQueryDTO.getQueryEndTime());
queryWrapper.eq(ObjectUtil.isNotNull(pageQueryDTO.getMainOrderStatus()), OrderMain::getMainOrderStatus, pageQueryDTO.getMainOrderStatus()); queryWrapper.eq(ObjectUtil.isNotNull(pageQueryDTO.getMainOrderStatus()), OrderMain::getMainOrderStatus, pageQueryDTO.getMainOrderStatus());
queryWrapper.eq(ObjectUtil.isNotNull(pageQueryDTO.getSettlementStatus()), OrderMain::getSettlementStatus, pageQueryDTO.getSettlementStatus()); queryWrapper.eq(ObjectUtil.isNotNull(pageQueryDTO.getSettlementStatus()), OrderMain::getSettlementStatus, pageQueryDTO.getSettlementStatus());
queryWrapper.orderByDesc(OrderMain::getId);
return list(queryWrapper); return list(queryWrapper);
} }

View File

@ -29,5 +29,6 @@
<if test="attractionId != null"> <if test="attractionId != null">
and attraction_id = #{attractionId} and attraction_id = #{attractionId}
</if> </if>
order by id desc
</select> </select>
</mapper> </mapper>