package com.cpop.mall.business.controller.backstage;

import com.cpop.core.base.R;
import com.cpop.mall.business.bo.OrderRefundPageBo;
import com.cpop.mall.business.bo.OrderRejectRefundBo;
import com.cpop.mall.business.service.OrderRefundService;
import com.cpop.mall.business.vo.OrderRefundPageVo;
import com.mybatisflex.core.paginate.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 商城订单退款记录表 控制层。
 *
 * @author DB
 * @since 2023-10-24
 */
@RestController
@Api(tags = "商城订单退款记录表接口")
@RequestMapping("/backstage/orderRefund")
public class BackstageOrderRefundController {

    @Autowired
    private OrderRefundService orderRefundService;

    /**
     * @descriptions 商城退款列表
     * @author DB
     * @date 2023/10/27 17:33
     * @param bo 请求参数
     * @return: com.cpop.core.base.R<com.mybatisflex.core.paginate.Page<com.cpop.mall.business.vo.ProductPageVo>>
     */
    @GetMapping("/getOrderRefundPage")
    @ApiOperation("分页查询商城-退款列表")
    public R<Page<OrderRefundPageVo>> getOrderRefundPage(@ApiParam("分页参数") OrderRefundPageBo bo) {
        Page<OrderRefundPageVo> page = orderRefundService.getOrderRefundPage(bo);
        return R.ok(page);
    }

    /**
     * @descriptions 同意退款
     * @author DB
     * @date 2023/10/23 12:15
     * @param id 订单id
     * @return: com.cpop.core.base.R<java.lang.Void>
     */
    @PutMapping("/agreeRefund/{id}")
    @ApiOperation("同意退款")
    public R<Void> agreeRefund(@PathVariable("id") String id) {
        orderRefundService.agreeRefund(id);
        return R.ok();
    }

    /**
     * @descriptions 拒绝退款
     * @author DB
     * @date 2023/10/23 12:15
     * @param bo 请求参数
     * @return: com.cpop.core.base.R<java.lang.Void>
     */
    @PostMapping("/rejectRefund")
    @ApiOperation("拒绝退款")
    public R<Void> rejectRefund(@RequestBody @Validated OrderRejectRefundBo bo) {
        orderRefundService.rejectRefund(bo);
        return R.ok();
    }
}
