package com.ruoyi.ibs.cmpm.mapper;

import com.ruoyi.ibs.cmpm.domain.dto.CustLevelDTO;
import com.ruoyi.ibs.cmpm.domain.dto.CustManagerDTO;
import com.ruoyi.ibs.cmpm.domain.dto.GridCmpmListDTO;
import com.ruoyi.ibs.cmpm.domain.dto.GridCmpmUpdateDTO;
import com.ruoyi.ibs.cmpm.domain.entity.GridCmpm;
import com.ruoyi.ibs.cmpm.domain.vo.DwbRetailCustLevelManagerDetailVO;
import com.ruoyi.ibs.cmpm.domain.vo.DwbRetailResultVO;
import com.ruoyi.ibs.cmpm.domain.vo.GridCmpmClaimVO;
import com.ruoyi.ibs.cmpm.domain.vo.GridCmpmVO;
import com.ruoyi.ibs.customerselect.domain.CustBaseInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.cursor.Cursor;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;
import java.util.Map;

/**
 * @Author 吴凯程
 * @Date 2025/5/26
 **/
@Mapper
public interface GridCmpmMapper {

    List<GridCmpm> selectManageList(GridCmpmListDTO gridCmpmListDTO);

    List<GridCmpm> selectCommonList(GridCmpmListDTO gridCmpmListDTO);

    GridCmpm getGridCmpmByCustKey(@Param("custId") String custId, @Param("accountNo") String accountNo, @Param("userName") String userName,
                                  @Param("gridType") String gridType, @Param("deptCode") String deptCode);

    List<GridCmpm> getGridCmpmByUserName(@Param("userName") String userName, @Param("deptCode") String deptCode, @Param("gridType") String gridType);

    List<GridCmpm> queryGridCmpmByCustKey( @Param("deptCode") String deptCode, @Param("gridType") String gridType,
                                           @Param("custIds") List<String> custIds, @Param("accountNos") List<String> accountNos );

    Long updateGridCmpm(GridCmpmUpdateDTO gridCmpmUpdateDTO);

    List<String> getAllCustLevel(@Param("gridType") String gridType);

    String getCustLevel(CustLevelDTO custLevelDTO);

    List<GridCmpmClaimVO> queryClaimList(@Param("deptCode") String deptCode, @Param("gridType") String gridType, @Param("custKey") String custKey);

    List<DwbRetailCustLevelManagerDetailVO> getCustManagerList(CustManagerDTO custManagerDTO);

    int getCustLevelCount(CustManagerDTO custManagerDTO);

    List<CustBaseInfo> selectCustInfoFromGridCmpm(CustBaseInfo custBaseInfo);

    List<CustBaseInfo> queryCustInfoFromGridCmpm(CustBaseInfo custBaseInfo);


    DwbRetailResultVO getCustManagerResult(CustManagerDTO custManagerDTO);

    List<String> getCustLevelList();

    int getCustCountByLevel(@Param("dto") CustManagerDTO custManagerDTO, @Param("time") String time);

    List<String> selectDeptListByRole(@Param("role") String role);

    List<String> selectManagerList();

    /**
     * 根据网格类型和总行ID查询客户经理列表
     * @param gridType 网格类型（零售retail、对公corporate、对公账户corporate_account）
     * @param headId 总行ID
     * @return 客户经理列表（user_name, nick_name）
     */
    List<Map<String, String>> getManagerListByGridType(@Param("gridType") String gridType, @Param("headId") String headId);

    /**
     * 根据网格类型、总行ID和客户经理查询客户列表（分表查询，适用于客群导入）
     * @param gridType 网格类型
     * @param userName 客户经理柜员号
     * @param headId 总行ID
     * @return 客户列表
     */
    List<GridCmpmVO> getCustomerListForImport(@Param("gridType") String gridType, @Param("userName") String userName, @Param("headId") String headId);

    /**
     * 根据网格类型、总行ID和客户经理流式查询客户列表（使用Cursor，适用于大数据量场景）
     * @param gridType 网格类型
     * @param userName 客户经理柜员号
     * @param headId 总行ID
     * @return 客户列表游标
     */
    Cursor<GridCmpmVO> getCustomerListForImportCursor(@Param("gridType") String gridType, @Param("userName") String userName, @Param("headId") String headId);


//    List<CustBaseInfo> selectCustInfoRetailFromGridCmpm(CustBaseInfo custBaseInfo);
//
//    List<CustBaseInfo> selectCustInfoMerchantFromGridCmpm(CustBaseInfo custBaseInfo);
//
//    List<CustBaseInfo> selectCustInfoBusinessFromGridCmpm(CustBaseInfo custBaseInfo);

}
