From 082966f36f4ce65cc06b569cd26a77440b7490fa Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Wed, 22 May 2024 10:04:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/order/controller/OrderController.java | 11 ++++++++- .../java/com/hfkj/common/utils/PageUtil.java | 9 +++++++ .../hfkj/service/order/BsOrderService.java | 7 ------ .../order/impl/BsOrderServiceImpl.java | 24 ++++--------------- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/order/src/main/java/com/order/controller/OrderController.java b/order/src/main/java/com/order/controller/OrderController.java index 72c87fd..615426f 100644 --- a/order/src/main/java/com/order/controller/OrderController.java +++ b/order/src/main/java/com/order/controller/OrderController.java @@ -7,6 +7,7 @@ import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.UserCenter; +import com.hfkj.common.utils.PageUtil; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.BsOrder; import com.hfkj.model.ResponseData; @@ -29,6 +30,7 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -143,7 +145,14 @@ public class OrderController { param.put("orderStatus", orderStatus); PageHelper.startPage(pageNum, pageSize); - return ResponseMsgUtil.success(new PageInfo<>(orderService.getUserOrderList(param))); + PageInfo pageInfo = new PageInfo<>(orderService.getOrderList(param)); + PageInfo objectPageInfo = PageUtil.PageInfo2PageInfoVo(pageInfo); + List orderModelList = new ArrayList<>(); + for (BsOrder order : pageInfo.getList()) { + orderModelList.add(orderService.getDetail(order.getOrderNo())); + } + objectPageInfo.setList(orderModelList); + return ResponseMsgUtil.success(objectPageInfo); } catch (Exception e) { log.error("error!",e); diff --git a/service/src/main/java/com/hfkj/common/utils/PageUtil.java b/service/src/main/java/com/hfkj/common/utils/PageUtil.java index 248ddc7..6202dd9 100644 --- a/service/src/main/java/com/hfkj/common/utils/PageUtil.java +++ b/service/src/main/java/com/hfkj/common/utils/PageUtil.java @@ -1,5 +1,6 @@ package com.hfkj.common.utils; +import com.github.pagehelper.Page; import com.github.pagehelper.PageInfo; import java.util.List; @@ -95,4 +96,12 @@ public class PageUtil { return pageInfo; } + + public static PageInfo PageInfo2PageInfoVo(PageInfo

pageInfoPo) { + // 创建Page对象,实际上是⼀个ArrayList类型的集合 + Page page = new Page<>(pageInfoPo.getPageNum(), pageInfoPo.getPageSize()); + page.setTotal(pageInfoPo.getTotal()); + return new PageInfo<>(page); + } + } diff --git a/service/src/main/java/com/hfkj/service/order/BsOrderService.java b/service/src/main/java/com/hfkj/service/order/BsOrderService.java index c5a4fb9..f4082de 100644 --- a/service/src/main/java/com/hfkj/service/order/BsOrderService.java +++ b/service/src/main/java/com/hfkj/service/order/BsOrderService.java @@ -76,11 +76,4 @@ public interface BsOrderService { */ List getOrderList(Map param); - /** - * 查询用户订单列表 - * @param param - * @return - */ - List getUserOrderList(Map param); - } diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java index fd04117..2cbba4d 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java @@ -425,8 +425,11 @@ public class BsOrderServiceImpl implements BsOrderService { BsOrderExample example = new BsOrderExample(); BsOrderExample.Criteria criteria = example.createCriteria(); - if (StringUtils.isNotBlank(MapUtils.getString(param, "order"))) { - criteria.andOrderNoLike("%"+MapUtils.getString(param, "order")+"%"); + if (MapUtils.getLong(param, "userId") != null) { + criteria.andUserIdEqualTo(MapUtils.getLong(param, "userId")); + } + if (StringUtils.isNotBlank(MapUtils.getString(param, "orderNo"))) { + criteria.andOrderNoLike("%"+MapUtils.getString(param, "orderNo")+"%"); } if (StringUtils.isNotBlank(MapUtils.getString(param, "userPhone"))) { criteria.andUserPhoneLike("%"+MapUtils.getString(param, "userPhone")+"%"); @@ -469,21 +472,4 @@ public class BsOrderServiceImpl implements BsOrderService { return orderMapper.selectByExample(example); } - @Override - public List getUserOrderList(Map param) { - BsOrderExample example = new BsOrderExample(); - BsOrderExample.Criteria criteria = example.createCriteria(); - - if (StringUtils.isNotBlank(MapUtils.getString(param, "order"))) { - criteria.andOrderNoLike("%"+MapUtils.getString(param, "order")+"%"); - } - - example.setOrderByClause("create_time desc"); - List orderModelList = new ArrayList<>(); - List orderList = orderMapper.selectByExample(example); - for (BsOrder order : orderList) { - orderModelList.add(getDetail(order.getOrderNo())); - } - return orderModelList; - } }