package com.fs.his.mapper;

import com.fs.his.domain.FsUserRecharge;
import com.fs.his.param.FsUserRechargeParam;
import com.fs.his.vo.FsUserRechargeListVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 会员充值Mapper接口
 *
 * @author fs
 * @date 2023-11-02
 */
public interface FsUserRechargeMapper
{
    /**
     * 查询会员充值
     *
     * @param rechargeId 会员充值主键
     * @return 会员充值
     */
    public FsUserRecharge selectFsUserRechargeByRechargeId(Long rechargeId);

    /**
     * 查询会员充值列表
     *
     * @param fsUserRecharge 会员充值
     * @return 会员充值集合
     */
    public List<FsUserRecharge> selectFsUserRechargeList(FsUserRecharge fsUserRecharge);

    /**
     * 新增会员充值
     *
     * @param fsUserRecharge 会员充值
     * @return 结果
     */
    public int insertFsUserRecharge(FsUserRecharge fsUserRecharge);

    /**
     * 修改会员充值
     *
     * @param fsUserRecharge 会员充值
     * @return 结果
     */
    public int updateFsUserRecharge(FsUserRecharge fsUserRecharge);

    /**
     * 删除会员充值
     *
     * @param rechargeId 会员充值主键
     * @return 结果
     */
    public int deleteFsUserRechargeByRechargeId(Long rechargeId);

    /**
     * 批量删除会员充值
     *
     * @param rechargeIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFsUserRechargeByRechargeIds(Long[] rechargeIds);
    @Select({"<script> select r.*,u.nick_name,u.phone from fs_user_recharge r LEFT JOIN fs_user u ON u.user_id=r.user_id " +
            "<where>  \n" +
            "            <if test=\"userId != null \"> and user_id = #{userId}</if>\n" +
            "            <if test=\"phone != null \"> and u.phone = #{phone}</if>\n" +
            "            <if test=\"freeMoney != null \"> and free_money = #{freeMoney}</if>\n" +
            "            <if test=\"sTime != null \">  and DATE(r.create_time) &gt;= DATE(#{sTime})</if>\n" +
            "            <if test=\"eTime != null \">  and DATE(r.create_time) &lt;= DATE(#{eTime})</if>\n" +
            "            <if test=\"payTime != null \"> and pay_time = #{payTime}</if>\n" +
            "            <if test=\"isPay != null \"> and is_pay = #{isPay}</if>\n" +
            "            <if test=\"tradeNo != null  and tradeNo != ''\"> and trade_no = #{tradeNo}</if>\n" +
            "        </where> order by recharge_id desc "+
            "</script>"})
    List<FsUserRechargeListVO> selectFsUserRechargeListVO(FsUserRechargeParam fsUserRecharge);
}
