package com.leromro.core.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.leromro.common.core.domain.R;
import com.leromro.common.utils.SecurityUtils;
import com.leromro.core.domain.SecondOrder;
import com.leromro.core.domain.vo.VolunteerOrdersVO;
import com.leromro.core.service.ISecondOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 订单主Controller
 *
 * @author ruoyi
 * @date 2025-04-09
 */
@RestController
@Api(tags = "志愿者订单")
@RequestMapping("/core/volunteer/orders")
public class volunteerOrderController {
    @Autowired
    private ISecondOrderService secondOrderService;
    @ApiOperation("志愿者查询小订单列表")
    @GetMapping("/volunteerOrderList")
    public R<List<VolunteerOrdersVO>> selectVolunteerList(Long orderStatus) {
        Long userId = SecurityUtils.getUserId();
        List<VolunteerOrdersVO> list = secondOrderService.selectOrderList(userId, orderStatus);
        return R.ok(list);
    }

    @ApiOperation("志愿者订单详情,（收货地址和状态）")
    @GetMapping("/volunteerOrderInfo")
    public R<SecondOrder> selectVolunteerOrderInfo(String orderId) {
        QueryWrapper<SecondOrder> wrapper = new QueryWrapper<SecondOrder>().eq("second_order_id", orderId);
        SecondOrder secondOrderInfo = secondOrderService.list(wrapper).get(0);
        return R.ok(secondOrderInfo);
    }

}
