package com.ycwl.basic.controller.pc;

import com.github.pagehelper.PageInfo;
import com.ycwl.basic.model.mobile.order.RefundOrderReq;
import com.ycwl.basic.model.pc.order.entity.OrderEntity;
import com.ycwl.basic.model.pc.order.req.OrderReqQuery;
import com.ycwl.basic.model.pc.order.resp.OrderRespVO;
import com.ycwl.basic.service.pc.OrderService;
import com.ycwl.basic.utils.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：longbinbin
 * @Date：2024/12/3 13:49
 */
@RestController
@RequestMapping("/api/order/v1")
// 订单管理
public class OrderController {

    @Autowired
    private OrderService orderService;

    // 审核退款: 审核退款
    @PostMapping("/auditRefundOrder")
    public ApiResponse<?> auditRefundOrder(@RequestBody RefundOrderReq refundOrderReq) {
        return orderService.auditRefundOrder(refundOrderReq);
    }


    // 分页查询订单
    @PostMapping("page")
    public ApiResponse<PageInfo<OrderRespVO>> pageQuery(@RequestBody OrderReqQuery query) {
        return orderService.pageQuery(query);
    }

    // 订单列表查询
    @PostMapping("list")
    public ApiResponse<List<OrderRespVO>> list(@RequestBody OrderReqQuery query) {
        return orderService.list(query);
    }
    // 订单详情查询
    @GetMapping("detail/{id}")
    public ApiResponse<OrderRespVO> detail(@PathVariable("id") Long orderId) {
        return orderService.detail(orderId);
    }


    // 订单备注
    @PostMapping("remark/{id}")
    public ApiResponse<?> updateRemark(@PathVariable("id") Long orderId, @RequestBody OrderEntity query) {
        orderService.remarkOrder(orderId, query);
        return ApiResponse.success(null);
    }
}
