diff --git a/src/main/java/com/peanut/modules/book/dao/BuyOrderDao.java b/src/main/java/com/peanut/modules/book/dao/BuyOrderDao.java index 874c26b9..4657bfe5 100644 --- a/src/main/java/com/peanut/modules/book/dao/BuyOrderDao.java +++ b/src/main/java/com/peanut/modules/book/dao/BuyOrderDao.java @@ -18,7 +18,7 @@ import java.util.List; @Mapper public interface BuyOrderDao extends BaseMapper { List orderList(BuyOrderListRequestVo requestVo); - List orderListCount(BuyOrderListRequestVo requestVo); + int orderListCount(BuyOrderListRequestVo requestVo); List orderStatusNum(Integer userId); diff --git a/src/main/java/com/peanut/modules/book/service/impl/BuyOrderServiceImpl.java b/src/main/java/com/peanut/modules/book/service/impl/BuyOrderServiceImpl.java index 9a0235bf..652ba069 100644 --- a/src/main/java/com/peanut/modules/book/service/impl/BuyOrderServiceImpl.java +++ b/src/main/java/com/peanut/modules/book/service/impl/BuyOrderServiceImpl.java @@ -422,14 +422,17 @@ public class BuyOrderServiceImpl extends ServiceImpl impl List data = new ArrayList<>(); requestVo.setIndex((requestVo.getPageIndex()-1)*10); List buyOrderList = buyOrderDao.orderList(requestVo); - int count = buyOrderDao.orderListCount(requestVo).size(); + int count = buyOrderDao.orderListCount(requestVo); for (BuyOrder buyOrder : buyOrderList) { BuyOrderResponseVo responseVo = setBuyOrderInfo(buyOrder); data.add(responseVo); } Map result = new HashMap<>(); Integer totalSize = count; - Integer totalPage = totalSize / requestVo.getPageSize() + 1; + Integer totalPage = totalSize / requestVo.getPageSize(); + if (totalSize % requestVo.getPageSize()!=0){ + totalPage = totalPage + 1; + } result.put("totalDataSize", totalSize); result.put("totalPage", totalPage); result.put("data", data); diff --git a/src/main/resources/mapper/book/BuyOrderDao.xml b/src/main/resources/mapper/book/BuyOrderDao.xml index 414e3f0f..6050501c 100644 --- a/src/main/resources/mapper/book/BuyOrderDao.xml +++ b/src/main/resources/mapper/book/BuyOrderDao.xml @@ -81,38 +81,39 @@ - + select count(1) from ( select b.* from buy_order b - - left join buy_order_product p on b.order_id = p.order_id - left join shop_product s on s.product_id = p.product_id + left join buy_order_product p on b.order_id = p.order_id + left join + shop_product s on s.product_id = p.product_id - - - and (b.order_sn like concat('%',concat(#{searchKeyWord},'%')) - or b.shipping_user like concat('%',concat(#{searchKeyWord},'%')) - or b.user_phone like concat('%',concat(#{searchKeyWord},'%'))) - + + + and (b.order_sn like concat('%',concat(#{searchKeyWord},'%')) + or b.shipping_user like concat('%',concat(#{searchKeyWord},'%')) + or b.user_phone like concat('%',concat(#{searchKeyWord},'%'))) + + + and (s.product_name like concat('%',concat(#{productName},'%'))) + + + and b.order_status = #{orderStatus} + + + and b.create_time >= #{startTime} + + + and b.create_time <= #{endTime} + + and b.order_type = 'order' + and b.del_flag = 0 + - and (s.product_name like concat('%',concat(#{productName},'%'))) + group by b.order_id - - and b.order_status = #{orderStatus} - - - and b.create_time >= #{startTime} - - - and b.create_time <= #{endTime} - - and b.order_type = 'order' - and b.del_flag = 0 - - - group by b.order_id - + ) t