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


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuchen.saas.park.api.dto.property.PropertyPrepaymentDeductDto;
import com.yuchen.saas.park.api.dto.property.PropertyPrepaymentQryDto;
import com.yuchen.saas.park.api.dto.property.PropertyPrepaymentSaveDto;
import com.yuchen.saas.park.api.vo.property.PropertyPrepaymentBalanceVo;
import com.yuchen.saas.park.api.vo.property.PropertyPrepaymentDeductVo;
import com.yuchen.saas.park.api.vo.property.PropertyPrepaymentDetailListVo;
import com.yuchen.saas.park.api.vo.property.PropertyPrepaymentListVo;
import com.yuchen.saas.park.service.service.property.PropertyPrepaymentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.validation.annotation.Validated;
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.validation.Valid;

/**
 * @Author: baichoajie
 * @CreateTime: 2024/09/23 10:33
 * @Description: TODO
 * @Version: 1.0
 */


@Api(tags = "物业-收费-客户账户-预存账户 前端控制器")
@RestController
@RequestMapping("/saasParkPropertyPrepayment")
public class SaasParkPropertyPrepaymentController {
    @Resource
    private PropertyPrepaymentService propertyPrepaymentService;

    @PostMapping("/save")
    @ApiOperation(value = "物业-收费-客户账户-预存账户-预缴退款")
    public R save(@Valid @RequestBody PropertyPrepaymentSaveDto dto) {
        propertyPrepaymentService.savePrepayment(dto);
        return R.success();
    }

    @PostMapping("/list")
    @ApiOperation(value = "物业-收费-客户账户-预存账户-列表")
    public R<Page<PropertyPrepaymentBalanceVo>> list(@RequestBody PropertyPrepaymentQryDto qryDto) {
        return R.data(propertyPrepaymentService.selectPage(qryDto));
    }

    @PostMapping("/deductDetail")
    @ApiOperation(value = "物业-收费-客户账户-预存账户-冲抵欠费详情")
    public R<PropertyPrepaymentDeductVo> deductDetail(@Valid @RequestBody PropertyPrepaymentDeductDto deductDto) {
        return R.data(propertyPrepaymentService.deductDetail(deductDto));
    }


    @PostMapping("/deduct")
    @ApiOperation(value = "物业-收费-客户账户-预存账户-预存款抵扣")
    public R deduct(@Valid @RequestBody PropertyPrepaymentDeductDto deductDto) {
        propertyPrepaymentService.deduct(deductDto);
        return R.success();
    }

    @PostMapping("/prepaymentList")
    @ApiOperation(value = "物业-收费-客户账户-预存账户-收支明细")
    public R<Page<PropertyPrepaymentListVo>> prepaymentList(@Validated(PropertyPrepaymentQryDto.Detail.class)
                                                            @RequestBody PropertyPrepaymentQryDto qryDto) {
        return R.data(propertyPrepaymentService.prepaymentList(qryDto));
    }

    @PostMapping("/prepaymentDetailList")
    @ApiOperation(value = "物业-收费-客户账户-预存账户-核销明细")
    public R<Page<PropertyPrepaymentDetailListVo>> prepaymentDetailList(@RequestBody PropertyPrepaymentQryDto qryDto) {
        return R.data(propertyPrepaymentService.prepaymentDetailList(qryDto));
    }


}
