package com.ruoyi.web.controller.houseInfo;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.houseInfo.PropertyFee;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IPropertyFeeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物业费管理Controller
 *
 * @author boman
 * @date 2025-03-03
 */
@RestController
@RequestMapping("/wuYe/fee")
public class PropertyFeeController extends BaseController
{
    @Autowired
    private IPropertyFeeService propertyFeeService;

/**
 * 查询物业费管理列表
 */
@PreAuthorize("@ss.hasPermi('wuYe:fee:list')")
@GetMapping("/list")
    public TableDataInfo list(PropertyFee propertyFee)
    {
        startPage();
        List<PropertyFee> list = propertyFeeService.selectPropertyFeeList(propertyFee);
        return getDataTable(list);
    }

    /**
     * 导出物业费管理列表
     */
    @PreAuthorize("@ss.hasPermi('wuYe:fee:export')")
    @Log(title = "物业费管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PropertyFee propertyFee)
    {
        List<PropertyFee> list = propertyFeeService.selectPropertyFeeList(propertyFee);
        ExcelUtil<PropertyFee> util = new ExcelUtil<PropertyFee>(PropertyFee.class);
        util.exportExcel(response, list, "物业费管理数据");
    }

    /**
     * 获取物业费管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('wuYe:fee:query')")
    @GetMapping(value = "/{propertyId}")
    public AjaxResult getInfo(@PathVariable("propertyId") Long propertyId)
    {
        return success(propertyFeeService.selectPropertyFeeByPropertyId(propertyId));
    }

    /**
     * 新增物业费管理
     */
    @PreAuthorize("@ss.hasPermi('wuYe:fee:add')")
    @Log(title = "物业费管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PropertyFee propertyFee)
    {
        return toAjax(propertyFeeService.insertPropertyFee(propertyFee));
    }

    /**
     * 修改物业费管理
     */
    @PreAuthorize("@ss.hasPermi('wuYe:fee:edit')")
    @Log(title = "物业费管理", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody PropertyFee propertyFee)
    {
        return toAjax(propertyFeeService.updatePropertyFee(propertyFee));
    }

    /**
     * 删除物业费管理
     */
    @PreAuthorize("@ss.hasPermi('wuYe:fee:remove')")
    @Log(title = "物业费管理", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{propertyIds}")
    public AjaxResult remove(@PathVariable Long[] propertyIds)
    {
        return toAjax(propertyFeeService.deletePropertyFeeByPropertyIds(propertyIds));
    }


    /**
     * 物业费统计
     */
    @PreAuthorize("@ss.hasPermi('wuYe:fee:statistics')")
    @Log(title = "物业费管理", businessType = BusinessType.DELETE)
    @GetMapping("/statistics")
    public AjaxResult statistics(PropertyFee propertyFee)
    {
        return propertyFeeService.statistics(propertyFee);
    }

    /**
     * 物业费催缴
     */
    @PreAuthorize("@ss.hasPermi('wuYe:fee:callPayment')")
    @Log(title = "物业费管理", businessType = BusinessType.DELETE)
    @GetMapping("/callPayment/{houseId}")
    public AjaxResult CallPayment(@PathVariable Long houseId)
    {
        return propertyFeeService.CallPayment(houseId);
    }

    /**
     * 物业费催缴（一键催缴）
     */
    @PreAuthorize("@ss.hasPermi('wuYe:fee:callPaymentAll')")
    @Log(title = "物业费管理", businessType = BusinessType.DELETE)
    @GetMapping("/callPaymentAll")
    public AjaxResult CallPaymentAll(PropertyFee propertyFee)
    {
        return propertyFeeService.CallPaymentAll(propertyFee);
    }

}
