package com.yuchen.saas.park.service.controller.property;


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.manage.system.api.param.CommonIdParam;
import com.yuchen.saas.park.api.dto.property.PropertyOfflinePaymentRecordAuditDto;
import com.yuchen.saas.park.api.dto.property.PropertyOfflinePaymentRecordQueryDto;
import com.yuchen.saas.park.api.dto.property.PropertyPublicMeterQueryDto;
import com.yuchen.saas.park.api.vo.property.PropertyOfflinePaymentRecordDetailVo;
import com.yuchen.saas.park.api.vo.property.PropertyOfflinePaymentRecordPageVo;
import com.yuchen.saas.park.api.vo.property.PropertyPublicMeterPageVo;
import com.yuchen.saas.park.service.service.property.IPropertyOfflinePaymentRecordService;
import com.yuchen.saas.parking.api.dto.coupon.PmgBatCouponRecordUseDetailQueryDTO;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nest.springwrap.core.mp.support.NestPage;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * <p>
 * 线下缴费记录(线下缴费审核) 前端控制器
 * </p>
 *
 * @author cxj
 * @since 2023-12-14
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/propertyOfflinePaymentRecord")
@Validated
public class PropertyOfflinePaymentRecordController {

    private final IPropertyOfflinePaymentRecordService baseService;

    @GetMapping("getPage")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "线下缴费审核分页", notes = "线下缴费审核分页")
    public R<NestPage<PropertyOfflinePaymentRecordPageVo>> getPage(PropertyOfflinePaymentRecordQueryDto dto) {
        NestPage<PropertyOfflinePaymentRecordPageVo> page = baseService.getPage(dto);
        return R.data(page);
    }

    @PostMapping("/audit")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "审核", notes = "审核")
    public R audit(@Valid @RequestBody PropertyOfflinePaymentRecordAuditDto dto) {
        return R.status(baseService.audit(dto));
    }

    @PostMapping("/export")
    @ApiOperation(value = "优惠卡/优惠活动优惠券使用明细数据导出", notes = "优惠卡/优惠活动优惠券使用明细数据导出")
    public void couponRecordUseDetailListExport(@RequestBody PropertyOfflinePaymentRecordQueryDto queryDTO, HttpServletResponse response){
        baseService.export(queryDTO, response);
    }

    @GetMapping("getDetailById")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "线下缴费审核明细", notes = "线下缴费审核明细")
    public R<PropertyOfflinePaymentRecordDetailVo> getDetailById(@ApiParam(value = "id") @RequestParam Long id) {
        PropertyOfflinePaymentRecordDetailVo vo = baseService.getDetailById(id);
        return R.data(vo);
    }
}
