package com.community.huiju.dao;

import com.community.huiju.model.TpBillInvoice;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface TpBillInvoiceMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(TpBillInvoice record);

    int insertSelective(TpBillInvoice record);

    TpBillInvoice selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(TpBillInvoice record);

    int updateByPrimaryKey(TpBillInvoice record);
    
    /**
     * 分页获取缴费和未缴费的数据
     * @param communityId
     * @param roomNoId 房间id
     * @param payType
     * @return
     */
    List<Map<String, Object>> getBillsList(@Param("communityId") Integer communityId,@Param("roomNoId") Integer roomNoId,@Param("payType") Integer payType);
    
    /**
     * 获取账单的详细信息
     * @param billInvoiceId
     * @return
     */
    Map<String, Object> getBillInvoiceDetail(@Param("communityId") Integer communityId,@Param("billInvoiceId") Integer billInvoiceId);
    
    /**
     * 获取需要支付的金额
     * @param billInvoiceId
     * @param buildingOwnerInfoId
     * @param communityId
     * @return
     */
	TpBillInvoice selectByIdAndroomNoId(@Param("id") Integer billInvoiceId,@Param("roomNoId") Integer buildingOwnerInfoId,@Param("communityId") Integer communityId);
    
    TpBillInvoice selectByOutTradeNo(@Param("outTradeNo") String outTradeNo);

    List<TpBillInvoice> selectByBuildingOwnerInfoId(@Param("buildingOwnerInfoId") Integer buildingOwnerInfoId);

    int updateBeach(Map<String, Object> map);

    /**
     * 根据 id 查询缴费单
     * @param billId
     * @return
     */
    @ResultMap("BaseResultMap")
    @Select("select " +
            "t.* ," +
            "b.bill_name as billName " +
            "from " +
            "tp_bill_invoice t " +
            "LEFT JOIN tp_bill b ON t.bill_id = b.id " +
            "where t.id = #{billId}")
    TpBillInvoice selectByIdBillInvoiceInfo(Integer billId);
}