package com.fs.hospital.mapper;

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

/**
 * 积分记录Mapper接口
 *
 * @author fs
 * @date 2024-03-04
 */
public interface HospitalMemberIntegralLogsMapper
{
    /**
     * 查询积分记录
     *
     * @param id 积分记录主键
     * @return 积分记录
     */
    public HospitalMemberIntegralLogs selectHospitalMemberIntegralLogsById(Long id);

    /**
     * 查询积分记录列表
     *
     * @param hospitalMemberIntegralLogs 积分记录
     * @return 积分记录集合
     */
    public List<HospitalMemberIntegralLogs> selectHospitalMemberIntegralLogsList(HospitalMemberIntegralLogs hospitalMemberIntegralLogs);

    /**
     * 新增积分记录
     *
     * @param hospitalMemberIntegralLogs 积分记录
     * @return 结果
     */
    public int insertHospitalMemberIntegralLogs(HospitalMemberIntegralLogs hospitalMemberIntegralLogs);

    /**
     * 修改积分记录
     *
     * @param hospitalMemberIntegralLogs 积分记录
     * @return 结果
     */
    public int updateHospitalMemberIntegralLogs(HospitalMemberIntegralLogs hospitalMemberIntegralLogs);

    /**
     * 删除积分记录
     *
     * @param id 积分记录主键
     * @return 结果
     */
    public int deleteHospitalMemberIntegralLogsById(Long id);

    /**
     * 批量删除积分记录
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteHospitalMemberIntegralLogsByIds(Long[] ids);

    @Select({"<script> " +
            "select l.*,u.nick_name,h.hospital_name from hospital_member_integral_logs l LEFT JOIN hospital_user u ON u.user_id=l.hospital_user_id LEFT JOIN hospital h ON h.hospital_id=l.hospital_id"+
            "<where>\n" +
            "            <if test=\"memberId != null \"> and member_id = #{memberId}</if>\n" +
            "            <if test=\"logType != null \"> and log_type = #{logType}</if>\n" +
            "            <if test=\"integral != null \"> and integral = #{integral}</if>\n" +
            "            <if test=\"balance != null \"> and balance = #{balance}</if>\n" +
            "            <if test=\"businessId != null  and businessId != ''\"> and business_id = #{businessId}</if>\n" +
            "            <if test=\"businessType != null \"> and business_type = #{businessType}</if>\n" +
            "            <if test=\"hospitalId != null \"> and hospital_id = #{hospitalId}</if>\n" +
            "        </where> order by id desc"+
            "</script>"})
    List<HospitalMemberIntegralLogsListHVO> selectHospitalMemberIntegralLogsListPVO(HospitalMemberIntegralLogs hospitalMemberIntegralLogs);
}
