Pu Zhibing
2025-03-26 7f26677ab7f9b83697370fa142dd1686cdf4082a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.ruoyi.order.controller;
 
 
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.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>
 *  前端控制器
 * </p>
 *
 * @author luodangjia
 * @since 2024-11-21
 */
@RestController
@RequestMapping("/order-good")
public class OrderGoodController extends BaseController {
    @Resource
    private OrderGoodService orderGoodService;
    @Resource
    private OrderService orderService;
 
    /**
     * 查询指定商品订单
     */
    @PostMapping("/selectGoodsOrder")
    public R<List<OrderGood>> selectGoodsOrder(@RequestBody List<Long> goodsIds){
        startPage();
        List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>()
                .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);
    }
}