| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.order.model.Order; |
| | | import com.ruoyi.order.model.OrderGood; |
| | | import com.ruoyi.order.service.OrderGoodService; |
| | | import com.ruoyi.model.OrderGood; |
| | | import com.ruoyi.order.service.OrderService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public class OrderGoodController extends BaseController { |
| | | @Resource |
| | | private OrderGoodService orderGoodService; |
| | | @Resource |
| | | private OrderService orderService; |
| | | |
| | | /** |
| | | * 查询指定商品订单 |
| | |
| | | .in(OrderGood::getGoodsId, goodsIds)); |
| | | return R.ok(orderGoods); |
| | | } |
| | | |
| | | @GetMapping("/getOrderListByUserIdAndGoodsId") |
| | | public R<List<OrderGood>> getOrderListByUserIdAndGoodsId(Long userId, Integer goodsId){ |
| | | return R.ok(orderGoodService.getOrderListByUserIdAndGoodsId(userId, goodsId)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取指定用户未分销的订单 |
| | | */ |
| | | @PostMapping("/getUnDistributedOrder") |
| | | public R<List<OrderGood>> getUnDistributedOrder(@RequestBody List<Long> appUserIds) { |
| | | List<Order> list = orderService.list(new LambdaQueryWrapper<Order>() |
| | | .in(Order::getAppUserId, appUserIds) |
| | | .eq(Order::getIsCommission, 0) |
| | | .eq(Order::getDelFlag, 0)); |
| | | if(list.isEmpty()){ |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | |
| | | List<Long> orderIds = list.stream().map(Order::getId).collect(Collectors.toList()); |
| | | List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>() |
| | | .in(OrderGood::getOrderId, orderIds)); |
| | | return R.ok(orderGoods); |
| | | } |
| | | } |
| | | |