package com.gxwebsoft.cms.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gxwebsoft.cms.entity.LeadReferral;
import com.gxwebsoft.cms.param.CustomerLeadParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 推荐人关系Mapper
 *
 * @author 科技小王子
 * @since 2026-04-14
 */
@Mapper
public interface LeadReferralMapper extends BaseMapper<LeadReferral> {

    /**
     * 分页查询推荐关系
     */
    List<LeadReferral> selectReferralPage(CustomerLeadParam param);

    /**
     * 查询用户的推荐记录
     */
    List<LeadReferral> selectUserReferrals(@Param("userId") Integer userId);

    /**
     * 根据推荐码查询
     */
    LeadReferral selectByCode(@Param("referralCode") String referralCode);

    /**
     * 统计推荐人的推荐数量
     */
    Integer countUserReferrals(@Param("userId") Integer userId, @Param("status") Integer status);

    /**
     * 统计推荐人待结算金额
     */
    java.math.BigDecimal sumPendingFee(@Param("userId") Integer userId);
}
