package com.storlead.sales.mapper;

import com.storlead.framework.mybatis.mapper.MyBaseMapper;
import com.storlead.sales.pojo.vo.report.BroadcastDataVO;

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

/**
 * 分公司/部门/个人播报数据统计 Mapper。
 * 说明：保持方法命名与 XML 中的 ID 一致，便于维护。
 */
public interface BroadcastDataMapper extends MyBaseMapper {

    List<com.storlead.user.pojo.entity.SubCompanyEntity> subCompanyList();

    List<BroadcastDataVO> customerListBySubCompany(Long subCompanyId, String startDate, String endDate);

    List<BroadcastDataVO> businessListBySubCompany(Long subCompanyId, String startDate, String endDate);

    List<BroadcastDataVO> orderListBySubCompany(Long subCompanyId, String startDate, String endDate);

    List<BroadcastDataVO> orderAmountListBySubCompany(Long subCompanyId, String startDate, String endDate);

    List<BroadcastDataVO> customerList(String startDate,String endDate);

    List<BroadcastDataVO> busssniessList(String startDate,String endDate);

    List<BroadcastDataVO> orderList(String startDate,String endDate);

    List<BroadcastDataVO> orderAmountList(String startDate,String endDate);

    // 集团级：线索/跟进/邮件 按分公司聚合的记录列表
    List<BroadcastDataVO> leadList(String startDate, String endDate);
    List<BroadcastDataVO> followList(String startDate, String endDate);
    List<BroadcastDataVO> mailList(String startDate, String endDate);

    // 个人维度：获取周期内新增客户的归属人集合
    List<Long> personUserIds(String startDate, String endDate);

    // 个人维度：客户/线索数量
    Long personCustomerCount(List<Long> userIds, String startDate, String endDate, Integer customerForm);

    // 个人维度：商机数量
    Long personBusinessCount(List<Long> userIds, String startDate, String endDate);

    // 个人维度：订单数量
    Long personOrderCount(List<Long> userIds, String startDate, String endDate);

    // 个人维度：订单金额
    BigDecimal personOrderAmount(List<Long> userIds, String startDate, String endDate);

    // 个人维度：跟进数量
    Long personFollowCount(List<Long> userIds, String startDate, String endDate);

    // 个人维度：邮件数量（folder='SENT'）
    Long personEmailCount(List<Long> userIds, String startDate, String endDate);


    // 分公司维度：线索/跟进/邮件计数（按分公司）
    Long leadCountBySubCompany(Long subCompanyId, String startDate, String endDate);
    Long followCountBySubCompany(Long subCompanyId, String startDate, String endDate);
    Long mailCountBySubCompany(Long subCompanyId, String startDate, String endDate);

    // 部门维度：根据部门ID获取部门所有成员ID集合
    List<Long> deptMemberIdsByDeptId(Long deptId);

    // 部门维度：获取单个部门领导对应成员（含领导本人）ID 集合
    List<Long> deptMemberIdsByManager(Long managerId);

    // 分公司级：线索/跟进/邮件 按部门聚合的记录列表
    List<BroadcastDataVO> leadListBySubCompany(Long subCompanyId, String startDate, String endDate);
    List<BroadcastDataVO> followListBySubCompany(Long subCompanyId, String startDate, String endDate);
    List<BroadcastDataVO> mailListBySubCompany(Long subCompanyId, String startDate, String endDate);

    // 部门级：按人员分组的记录列表
    List<BroadcastDataVO> customerListByDeptMembers(List<Long> userIds, String startDate, String endDate);
    List<BroadcastDataVO> businessListByDeptMembers(List<Long> userIds, String startDate, String endDate);
    List<BroadcastDataVO> orderListByDeptMembers(List<Long> userIds, String startDate, String endDate);
    List<BroadcastDataVO> orderAmountListByDeptMembers(List<Long> userIds, String startDate, String endDate);
    List<BroadcastDataVO> leadListByDeptMembers(List<Long> userIds, String startDate, String endDate);
    List<BroadcastDataVO> followListByDeptMembers(List<Long> userIds, String startDate, String endDate);
    List<BroadcastDataVO> mailListByDeptMembers(List<Long> userIds, String startDate, String endDate);

}
