package com.fs.hospital.mapper;

import java.util.List;
import com.fs.hospital.domain.HospitalMemberBill;
import com.fs.hospital.vo.HospitalMemberBillHVO;
import org.apache.ibatis.annotations.Select;

/**
 * 会员帐单Mapper接口
 *
 * @author fs
 * @date 2024-03-04
 */
public interface HospitalMemberBillMapper
{
    /**
     * 查询会员帐单
     *
     * @param billId 会员帐单主键
     * @return 会员帐单
     */
    public HospitalMemberBill selectHospitalMemberBillByBillId(Long billId);

    /**
     * 查询会员帐单列表
     *
     * @param hospitalMemberBill 会员帐单
     * @return 会员帐单集合
     */
    public List<HospitalMemberBill> selectHospitalMemberBillList(HospitalMemberBill hospitalMemberBill);

    /**
     * 新增会员帐单
     *
     * @param hospitalMemberBill 会员帐单
     * @return 结果
     */
    public int insertHospitalMemberBill(HospitalMemberBill hospitalMemberBill);

    /**
     * 修改会员帐单
     *
     * @param hospitalMemberBill 会员帐单
     * @return 结果
     */
    public int updateHospitalMemberBill(HospitalMemberBill hospitalMemberBill);

    /**
     * 删除会员帐单
     *
     * @param billId 会员帐单主键
     * @return 结果
     */
    public int deleteHospitalMemberBillByBillId(Long billId);

    /**
     * 批量删除会员帐单
     *
     * @param billIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteHospitalMemberBillByBillIds(Long[] billIds);

    @Select({"<script> " +
            "select mb.*,m.nick_name from hospital_member_bill mb left join hospital_member m on m.member_id = mb.member_id " +
            " where 1=1 " +
            " <if test=\"memberId != null \"> and mb.member_id = #{memberId}</if>\n" +
            "            <if test=\"title != null  and title != ''\"> and mb.title = #{title}</if>\n" +
            "            <if test=\"money != null \"> and mb.money = #{money}</if>\n" +
            "            <if test=\"balance != null \"> and mb.balance = #{balance}</if>\n" +
            "            <if test=\"billType != null \"> and mb.bill_type = #{billType}</if>\n" +
            "            <if test=\"businessId != null  and mb.businessId != ''\"> and business_id = #{businessId}</if>\n" +
            "            <if test=\"hospitalId != null \"> and mb.hospital_id = #{hospitalId}</if>" +
            " order by bill_id desc"+
            "</script>"})
    List<HospitalMemberBillHVO> selectHospitalMemberBillListPVO(HospitalMemberBill hospitalMemberBill);
}
