package cn.pluss.platform.mapper;

import cn.pluss.platform.entity.UserProfit;
import cn.pluss.platform.vo.UserAppVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author bzg
 * @since 2022-01-14
 */
public interface UserProfitMapper extends BaseMapper<UserProfit> {


    /**
     * 获取用户月团队流水
     * @date: 2022/1/25 23:01
     * @param profitMonth:
     * @return java.util.List<cn.pluss.platform.entity.UserProfit>
     */
    List<UserProfit> selectLevelFlow(String profitMonth);

    /**
     * 查询下级数据
     * @return
     */
    Page<UserAppVO> selectPageSubTeamData(Page<UserAppVO> page, @Param("userId") String userId, @Param("userName") String userName);

    @Select("SELECT IFNULL(SUM(teamTransFlow),0) FROM tb_pluss_user_profit WHERE userId = #{userId} ")
    BigDecimal getBeforeFlowByUserId(Long userId);

    /**
     * 分页查询
     * @date: 2022/3/11 15:56
     * @param page:
     * @param entity:
     * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<cn.pluss.platform.entity.UserProfit>
     */
    Page<UserProfit> pageData(Page<UserProfit> page, @Param("entity") UserProfit entity);
}
