历史订单查询
This commit is contained in:
parent
d72592000d
commit
4f19af093e
|
@ -66,6 +66,14 @@ public class OrderController {
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 历史订单查询
|
||||||
|
*
|
||||||
|
* @param page 当前页
|
||||||
|
* @param pageSize 每页显示条数
|
||||||
|
* @param status 状态
|
||||||
|
* @return PageResult
|
||||||
|
*/
|
||||||
@ApiOperation("历史订单查询")
|
@ApiOperation("历史订单查询")
|
||||||
@GetMapping("/historyOrders")
|
@GetMapping("/historyOrders")
|
||||||
public Result<PageResult> page(int page, int pageSize, Integer status) {
|
public Result<PageResult> page(int page, int pageSize, Integer status) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.sky.entity.OrderDetail;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface OrderDetailMapper {
|
public interface OrderDetailMapper {
|
||||||
|
@ -13,4 +14,12 @@ public interface OrderDetailMapper {
|
||||||
* @param orderDetailArrayList ArrayList<OrderDetail>
|
* @param orderDetailArrayList ArrayList<OrderDetail>
|
||||||
*/
|
*/
|
||||||
void insertBatch(ArrayList<OrderDetail> orderDetailArrayList);
|
void insertBatch(ArrayList<OrderDetail> orderDetailArrayList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询订单明细
|
||||||
|
*
|
||||||
|
* @param id Long
|
||||||
|
* @return List<OrderDetail>
|
||||||
|
*/
|
||||||
|
List<OrderDetail> getByOrderId(Long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.sky.mapper;
|
package com.sky.mapper;
|
||||||
|
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
import com.sky.dto.OrdersPageQueryDTO;
|
||||||
import com.sky.entity.Orders;
|
import com.sky.entity.Orders;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@ -45,4 +47,12 @@ public interface OrderMapper {
|
||||||
* @return 订单
|
* @return 订单
|
||||||
*/
|
*/
|
||||||
Orders getById(Long id);
|
Orders getById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户端订单分页查询
|
||||||
|
*
|
||||||
|
* @param ordersPageQueryDTO OrdersPageQueryDTO
|
||||||
|
* @return Page<Orders>
|
||||||
|
*/
|
||||||
|
Page<Orders> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,10 @@ public interface OrderService {
|
||||||
/**
|
/**
|
||||||
* 用户端订单分页查询
|
* 用户端订单分页查询
|
||||||
*
|
*
|
||||||
* @param page
|
* @param pageNum 当前页
|
||||||
* @param pageSize
|
* @param pageSize 每页显示条数
|
||||||
* @param status
|
* @param status 状态
|
||||||
* @return
|
* @return PageResult
|
||||||
*/
|
*/
|
||||||
PageResult pageQuery4User(int page, int pageSize, Integer status);
|
PageResult pageQuery4User(int pageNum, int pageSize, Integer status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package com.sky.service.impl;
|
package com.sky.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.sky.constant.MessageConstant;
|
import com.sky.constant.MessageConstant;
|
||||||
import com.sky.context.BaseContext;
|
import com.sky.context.BaseContext;
|
||||||
|
import com.sky.dto.OrdersPageQueryDTO;
|
||||||
import com.sky.dto.OrdersPaymentDTO;
|
import com.sky.dto.OrdersPaymentDTO;
|
||||||
import com.sky.dto.OrdersSubmitDTO;
|
import com.sky.dto.OrdersSubmitDTO;
|
||||||
import com.sky.entity.*;
|
import com.sky.entity.*;
|
||||||
|
@ -10,10 +13,12 @@ import com.sky.exception.AddressBookBusinessException;
|
||||||
import com.sky.exception.OrderBusinessException;
|
import com.sky.exception.OrderBusinessException;
|
||||||
import com.sky.exception.ShoppingCartBusinessException;
|
import com.sky.exception.ShoppingCartBusinessException;
|
||||||
import com.sky.mapper.*;
|
import com.sky.mapper.*;
|
||||||
|
import com.sky.result.PageResult;
|
||||||
import com.sky.service.OrderService;
|
import com.sky.service.OrderService;
|
||||||
import com.sky.utils.WeChatPayUtil;
|
import com.sky.utils.WeChatPayUtil;
|
||||||
import com.sky.vo.OrderPaymentVO;
|
import com.sky.vo.OrderPaymentVO;
|
||||||
import com.sky.vo.OrderSubmitVO;
|
import com.sky.vo.OrderSubmitVO;
|
||||||
|
import com.sky.vo.OrderVO;
|
||||||
import com.sky.websocket.WebSocketServer;
|
import com.sky.websocket.WebSocketServer;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -167,6 +172,41 @@ public class OrderServiceImpl implements OrderService {
|
||||||
map.put("content", "订单号" + orderDB.getNumber());
|
map.put("content", "订单号" + orderDB.getNumber());
|
||||||
webSocketServer.sendToAllClient(JSONObject.toJSONString(map));
|
webSocketServer.sendToAllClient(JSONObject.toJSONString(map));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户端订单分页查询
|
||||||
|
*
|
||||||
|
* @param pageNum 当前页
|
||||||
|
* @param pageSize 每页显示条数
|
||||||
|
* @param status 状态
|
||||||
|
* @return PageResult
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageResult pageQuery4User(int pageNum, int pageSize, Integer status) {
|
||||||
|
// 设置分页大小和每页条数
|
||||||
|
PageHelper.startPage(pageNum, pageSize);
|
||||||
|
// 封装查询条件
|
||||||
|
OrdersPageQueryDTO ordersPageQueryDTO = new OrdersPageQueryDTO();
|
||||||
|
ordersPageQueryDTO.setUserId(BaseContext.getCurrentId());
|
||||||
|
ordersPageQueryDTO.setStatus(status);
|
||||||
|
// 分页条件查询
|
||||||
|
Page<Orders> page = orderMapper.pageQuery(ordersPageQueryDTO);
|
||||||
|
ArrayList<OrderVO> list = new ArrayList<>();
|
||||||
|
// 查询订单明细,并封装入orderMapper进行响应
|
||||||
|
if (page != null && page.getTotal() > 0) {
|
||||||
|
for (Orders orders : page) {
|
||||||
|
Long id = orders.getId();
|
||||||
|
// 查询订单明细
|
||||||
|
List<OrderDetail> orderDetails = orderDetailMapper.getByOrderId(id);
|
||||||
|
OrderVO orderVO = new OrderVO();
|
||||||
|
BeanUtils.copyProperties(orders, orderVO);
|
||||||
|
orderVO.setOrderDetailList(orderDetails);
|
||||||
|
list.add(orderVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert page != null;
|
||||||
|
return new PageResult(page.getTotal(), list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,4 +11,11 @@
|
||||||
#{od.amount})
|
#{od.amount})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<!-- 查询订单明细 -->
|
||||||
|
<select id="getByOrderId" resultType="com.sky.entity.OrderDetail">
|
||||||
|
select *
|
||||||
|
from order_detail
|
||||||
|
where order_id = #{orderId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -68,4 +68,31 @@
|
||||||
from orders
|
from orders
|
||||||
where id = #{id};
|
where id = #{id};
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 用户端订单分页查询 -->
|
||||||
|
<select id="pageQuery" resultType="com.sky.entity.Orders">
|
||||||
|
select *
|
||||||
|
from orders
|
||||||
|
<where>
|
||||||
|
<if test="number != null and number!=''">
|
||||||
|
and number like concat('%',#{number},'%')
|
||||||
|
</if>
|
||||||
|
<if test="phone != null and phone!=''">
|
||||||
|
and phone like concat('%',#{phone},'%')
|
||||||
|
</if>
|
||||||
|
<if test="userId != null">
|
||||||
|
and user_id = #{userId}
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
and status = #{status}
|
||||||
|
</if>
|
||||||
|
<if test="beginTime != null">
|
||||||
|
and order_time >= #{beginTime}
|
||||||
|
</if>
|
||||||
|
<if test="endTime != null">
|
||||||
|
and order_time <= #{endTime}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by order_time desc
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue