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

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.dto.property.PropertyBillPayBto;
import com.yuchen.saas.park.api.dto.property.PropertyBillPayCallBackDto;
import com.yuchen.saas.park.api.dto.property.PropertyBillPayQueryDto;
import com.yuchen.saas.park.api.entity.property.PropertyBillPay;
import com.yuchen.saas.park.api.vo.property.PropertyBillPayListVo;
import com.yuchen.saas.park.service.service.property.IPropertyBillPayService;
import io.swagger.annotations.ApiOperation;
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.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author 蔡文强
 * @Date 2024-01-04 10:56
 * @Description 账单缴费记录 前端控制器
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/propertyBillPay")
public class PropertyBillPayController {

    @Resource
    private IPropertyBillPayService baseService;


    @PostMapping("/getBillPayList")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "收费记录列表", notes = "收费记录列表")
    public R<NestPage<PropertyBillPayListVo>> getBillPayList(@RequestBody PropertyBillPayQueryDto queryDto) {
        return R.data(baseService.getBillPayList(queryDto));
    }

    @PostMapping("/billPayListExport")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "收费记录列表导出", notes = "收费记录列表导出")
    public void billPayListExport(@RequestBody PropertyBillPayQueryDto queryDto, HttpServletResponse response) {
        baseService.billPayListExport(queryDto, response);
    }

    @PostMapping("/insert")
    @ApiOperation(value = "物业账单缴费记录")
    public R<PropertyBillPay> insert(@RequestBody PropertyBillPayBto billPayBto) {
        return R.data(baseService.insertBillPay(billPayBto));
    }

    @PostMapping("/propertyFeePaySuccessCallBack")
    @ApiOperation(value = "物业缴费支付成功回调")
    public R propertyFeePaySuccessCallBack(@RequestBody PropertyBillPayCallBackDto dto) {
        baseService.propertyFeePaySuccessCallBack(dto);
        return R.success();
    }

    @PostMapping("/propertyPrepaymentFeePaySuccessCallBack")
    @ApiOperation(value = "物业预存款支付成功回调")
    public R propertyPrepaymentFeePaySuccessCallBack(@RequestBody PropertyBillPayCallBackDto dto) {
        baseService.propertyPrepaymentFeePaySuccessCallBack(dto);
        return R.success();
    }


}
