package cn.pluss.platform.mapper;

import cn.pluss.platform.entity.UserManageProfit;
import cn.pluss.platform.entity.UserPromotion;
import cn.pluss.platform.vo.MerchantChannelStatusVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

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

@Mapper
public interface  UserPromotionMapper extends BaseMapper<UserPromotion> {
    List<UserPromotion> selectListByUserId(@Param("userIdList") List<Integer> userIdList);



    @Select(value = "SELECT\n" +
            "\tP.user_id AS userId,\n" +
            "\tP.type_code AS typeCode,\n" +
            "\tP.current_fee AS currentFee,\n" +
            "\tP.parent_user_id AS parentUserId,\n" +
            "\tP.is_extend AS isExtend,\n" +
            "\tP.create_time AS createTime,\n" +
            "\tP.update_time AS updateTime,\n" +
            "\tu.loginName \n" +
            "FROM\n" +
            "\ttb_pluss_user_promotion P\n" +
            "\tLEFT JOIN tb_pluss_user_info u ON P.user_id = u.id \n" +
            "WHERE\n" +
            "\tP.user_id = #{userId}")
    UserPromotion selectByUserId(@Param("userId") String userId);

    UserPromotion selectByPrimaryKey(Long userId);
    UserPromotion selectByUserIdMC(Long userId);
    @Select("select max(current_fee)  from tb_pluss_user_promotion where parent_user_id=#{id}")
    BigDecimal selectMaxFeeByUserId(@Param("id")String id);
    @Select(" select *\n" +
            "        from tb_pluss_user_promotion\n" +
            "        where user_id = #{userId}" +
            "        limit 1 ")
    UserPromotion getOne(@Param("userId") Long userId);
    int updateByPrimaryKey(UserPromotion record);
}
