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);

    List<DwbRetailCustLevelManagerDetailVO> getCustManagerListByPage(@Param("dto") CustManagerDTO custManagerDTO,
                                                                     @Param("headId") String headId,
                                                                     @Param("offset") Integer offset,
                                                                     @Param("pageSize") Integer pageSize);

    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();

    /**
     * 全量查询绩效网格客户列表（用于客群管户关系匹配，不按客户经理过滤）
     * @param gridType 网格类型
     * @param headId 总行ID
     * @return 客户列表（包含管户关系信息）
     */
    List<GridCmpmVO> getAllCustomerListForImport(@Param("gridType") String gridType, @Param("headId") String headId);

    /**
     * 根据客户ID和类型列表查询管户关系（用于动态客群更新管户关系）
     * @param gridType 网格类型（retail/corporate）
     * @param headId 总行ID
     * @param custInfoList 客户信息列表（包含custId和custType）
     * @return 客户管户关系列表
     */
    List<GridCmpmVO> getRelationshipsByCustList(@Param("gridType") String gridType, @Param("headId") String headId, @Param("custInfoList") List<Map<String, String>> custInfoList);


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

}
