package com.fs.his.mapper;

import com.fs.his.domain.FsDoctorBill;
import com.fs.his.param.FsDoctorBillListSParam;
import com.fs.his.param.FsDoctorBillParam;
import com.fs.his.vo.FsDoctorBillListSVO;
import com.fs.his.vo.FsDoctorBillVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 医生账单记录Mapper接口
 *
 * @author fs
 * @date 2023-06-25
 */
public interface FsDoctorBillMapper
{
    /**
     * 查询医生账单记录
     *
     * @param billId 医生账单记录主键
     * @return 医生账单记录
     */
    public FsDoctorBill selectFsDoctorBillByBillId(Long billId);

    /**
     * 查询医生账单记录列表
     *
     * @param fsDoctorBill 医生账单记录
     * @return 医生账单记录集合
     */
    public List<FsDoctorBill> selectFsDoctorBillList(FsDoctorBill fsDoctorBill);

    /**
     * 新增医生账单记录
     *
     * @param fsDoctorBill 医生账单记录
     * @return 结果
     */
    public int insertFsDoctorBill(FsDoctorBill fsDoctorBill);

    /**
     * 修改医生账单记录
     *
     * @param fsDoctorBill 医生账单记录
     * @return 结果
     */
    public int updateFsDoctorBill(FsDoctorBill fsDoctorBill);

    /**
     * 删除医生账单记录
     *
     * @param billId 医生账单记录主键
     * @return 结果
     */
    public int deleteFsDoctorBillByBillId(Long billId);

    /**
     * 批量删除医生账单记录
     *
     * @param billIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFsDoctorBillByBillIds(Long[] billIds);

    @Select({"<script> " +
                " select b.*,d.doctor_name name from fs_doctor_bill b LEFT JOIN fs_doctor d ON b.doctor_id=d.doctor_id "+
            "<where>  \n" +

            "   <if test=\"billId != null \"> and b.bill_id = #{billId}</if>\n" +
            "            <if test=\"doctorId != null \"> and b.doctor_id = #{doctorId}</if>\n" +
            "            <if test=\"title != null  and title != ''\"> and b.title like concat('%', #{title}, '%')</if>\n" +
            "            <if test=\"doctorName != null  and doctorName != ''\"> and d.doctor_name like concat('%', #{doctorName}, '%')</if>\n" +
            "            <if test=\"billType != null \"> and b.bill_type = #{billType}</if>\n" +
            "            <if test=\"createTime != null \"> and  DATE(b.create_time) = #{createTime}</if>\n" +
            "            <if test=\"businessId != null  and businessId != ''\"> and b.business_id = #{businessId}</if>\n" +
            "            <if test=\"sTime != null \">  and DATE(b.create_time) &gt;= DATE(#{sTime})</if>\n" +
            "            <if test=\"eTime != null \">  and DATE(b.create_time) &lt;= DATE(#{eTime})</if>\n" +
            "        </where>"+
            "order by b.bill_id desc"+
            "</script>"})
    List<FsDoctorBillVO> selectFsDoctorBillListVO(FsDoctorBillParam fsDoctorBill);
    @Select({"<script> " +
            "select b.*  from   fs_doctor_bill b   " +
            "where 1=1  " +
            "<if test = 'maps.doctorId != null     '> " +
            "and b.doctor_id = #{maps.doctorId} " +
            "</if>" +
            "<if test = 'maps.billType != null     '> " +
            "and b.bill_type = #{maps.billType} " +
            "</if>" +
            " order by b.bill_id desc "+
            "</script>"})
    List<FsDoctorBillListSVO> selectFsDoctorBillListSVO(@Param("maps") FsDoctorBillListSParam param);
}
