小程序订单详情筛选条件完成
This commit is contained in:
@@ -2,6 +2,7 @@ package com.cxyxiaomo.epp.shop.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.cxyxiaomo.epp.common.enums.OrderStatus;
|
||||
import com.cxyxiaomo.epp.common.pojo.Order;
|
||||
import com.cxyxiaomo.epp.common.pojo.OrderDetail;
|
||||
import com.cxyxiaomo.epp.common.response.Res;
|
||||
@@ -13,10 +14,7 @@ import com.cxyxiaomo.epp.shop.service.OrderService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@@ -130,12 +128,25 @@ public class OrderController {
|
||||
*/
|
||||
@GetMapping("/miniprogram/listUserOrder")
|
||||
@ResponseBody
|
||||
public Res listUserOrder(@RequestParam Integer userId) {
|
||||
public Res listUserOrder(@RequestParam Integer userId,
|
||||
@RequestParam(value = "filter", required = false) String orderStatusFilter) {
|
||||
if (userId == null) {
|
||||
return Res.error("参数错误");
|
||||
}
|
||||
List<Order> orders = orderService.listUserOrder(userId);
|
||||
List<Order> orders = orderService.listUserOrder(userId, orderStatusFilter);
|
||||
List<OrderVO> orderVOS = OrderVO.convertFrom(orders);
|
||||
return Res.success(orderVOS);
|
||||
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
|
||||
JSONObject filter = new JSONObject();
|
||||
Arrays.stream(OrderStatus.values())
|
||||
.forEach(orderStatus -> filter.put(orderStatus.getValue(), orderStatus.toString()));
|
||||
// List<String> filter = Arrays.stream(OrderStatus.values())
|
||||
// .map(OrderStatus::toString).collect(Collectors.toList());
|
||||
|
||||
map.put("filter", filter);
|
||||
map.put("orders", orderVOS);
|
||||
return Res.success(map);
|
||||
}
|
||||
}
|
||||
|
@@ -32,9 +32,10 @@ public interface OrderDao {
|
||||
* 根据用户 ID 查询订单列表
|
||||
*
|
||||
* @param userId
|
||||
* @param orderStatus
|
||||
* @return
|
||||
*/
|
||||
List<Order> listOrderByUserId(Integer userId);
|
||||
List<Order> listOrderByUserId(@Param("userId") Integer userId, @Param("orderStatus") String orderStatus);
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
|
@@ -105,8 +105,8 @@ public class OrderService {
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public List<Order> listUserOrder(Integer userId) {
|
||||
List<Order> orders = orderDao.listOrderByUserId(userId);
|
||||
public List<Order> listUserOrder(Integer userId, String orderStatus) {
|
||||
List<Order> orders = orderDao.listOrderByUserId(userId, orderStatus);
|
||||
return orders;
|
||||
}
|
||||
}
|
||||
|
@@ -37,6 +37,9 @@
|
||||
SELECT *
|
||||
FROM `order`
|
||||
WHERE user_id = #{userId}
|
||||
<if test="orderStatus != null and orderStatus != ''">
|
||||
AND order_status = #{orderStatus}
|
||||
</if>
|
||||
order by order_date desc
|
||||
</select>
|
||||
|
||||
|
Reference in New Issue
Block a user