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


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yuchen.saas.park.api.entity.property.PropertyFeeItem;
import com.yuchen.saas.park.api.vo.property.PropertyPrepaymentFeeItemInfoVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 费用项目 Mapper 接口
 * </p>
 *
 * @author cxj
 * @since 2023-12-12
 */
public interface PropertyFeeItemMapper extends BaseMapper<PropertyFeeItem> {

    @Select("SELECT fi.id as fee_item_id" +
            " ,MAX(fi.fee_item_name) as fee_item_name" +
            " ,MAX(fi.balance_type) as balance_type" +
            " ,GROUP_CONCAT(fs.fee_name) as fee_name_str" +
            " from property_fee_item fi" +
            " LEFT JOIN property_fee_item_detail fid on fi.id = fid.fee_item_id" +
            " LEFT JOIN property_fee_standard fs on fid.fee_item_binding_id = fs.id" +
            " ${ew.customSqlSegment}" +
            " GROUP BY fi.id")
    List<PropertyPrepaymentFeeItemInfoVo> listPrepaymentFeeItemInfo(@Param(Constants.WRAPPER) QueryWrapper<String> wrapper);

}
