package com.yida.data.device.consume.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.device.consume.service.EduConsumeOrderService;
import com.yida.data.device.dto.consume.ConsumeOrderPageDTO;
import com.yida.data.device.vo.consume.ConsumeOrderPageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 消费订单 Controller
 *
 * @author ZYJ
 * @date 2023/4/14
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/consumeOrder")
@Api(tags = "消费订单api")
public class EduConsumeOrderController {

    private final EduConsumeOrderService eduConsumeOrderService;

    @ApiOperation("消费订单列表分页查询")
    @GetMapping("/listConsumeOrderPage")
    public ResultBean<Page<ConsumeOrderPageVO>> listConsumeOrderPage(ConsumeOrderPageDTO dto) {
        return ResultBean.buildSuccess(eduConsumeOrderService.listConsumeOrderPage(dto));
    }

    @GetMapping(value = "refundOrder")
    @ApiOperation(value = "消费订单退款")
    public ResultBean<String> refundOrder(
            @ApiParam(value = "订单号", required = true) @RequestParam String orderCode) {
        eduConsumeOrderService.refundOrder(orderCode);
        return ResultBean.buildSuccess();
    }
}
