package com.yami.shop.platform.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.binarywang.wxpay.service.WxPayService;
import com.yami.shop.bean.dto.OrderRefundDto;
import com.yami.shop.bean.model.OrderRefund;
import com.yami.shop.common.util.PageParam;
import com.yami.shop.service.OrderRefundService;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.yami.shop.common.util.R;
/**
 * 订单退款管理实现
 *
 * @author lgh
 * @version 1.0.0
 * @since 2018-09-15
 */
@RestController
@AllArgsConstructor
@RequestMapping("/platform/orderRefund")
public class OrderRefundController {

    private final OrderRefundService orderRefundService;

    /**
     * 分页查询
     *
     * @param page           分页对象
     * @param orderRefundDto 实体对象
     * @return 分页数据
     */
    @GetMapping("/page")
    @PreAuthorize("@pms.hasPermission('platform:orderRefund:page')")
    public R<IPage<OrderRefundDto>> getOrderRefundPage(PageParam<OrderRefundDto> page, OrderRefundDto orderRefundDto,
                                                                    @RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime) {
        IPage<OrderRefundDto> page1 = orderRefundService.getPage(page, orderRefundDto, startTime, endTime);
        return R.SUCCESS(orderRefundService.getPage(page, orderRefundDto, startTime, endTime));
    }

    /**
     * 通过id查询
     *
     * @param refundId id
     * @return 查询详细信息
     */
    @GetMapping("/info")
    @PreAuthorize("@pms.hasPermission('platform:orderRefund:info')")
    public R<OrderRefund> info(@RequestParam("refundId") Long refundId, @RequestParam("shopId") Long shopId) {
        OrderRefund orderRefund = orderRefundService.getOrderRefundById(refundId, shopId);
        return R.SUCCESS(orderRefund);
    }

}
