import request from "@/utils/request";
const { api } = process.env.CONFIG;

/**
 * 群聊创建
 * @param data 
 * @returns 
 */
export async function addPullGroupTaskApi(data: GROUP_CHAT_API.AddPullGroupTaskProps) {
    return request({
        url: api + `/corpOperation/corp/pullGroup/project/task/add`,
        method: 'POST',
        data
    });
}

/**
 * 计划修改
 * @param param0 
 * @returns 
 */
export async function updateGroupTaskApi({ projectId, ...data }: GROUP_CHAT_API.AddPullGroupTaskProps) {
    return request({
        url: api + `/corpOperation/corp/pullGroup/project/task/edit/${projectId}`,
        method: 'POST',
        data
    });
}

/**
 * 详情
 * @param data 
 * @returns 
 */
export async function getCreateDetailsApi(projectId: number) {
    return request({
        url: api + `/corpOperation/corp/pullGroup/project/selectById/${projectId}`,
        method: 'POST'
    });
}


/**
 * 计划列表
 * @param data 
 * @returns 
 */
export async function getProjectListApi(data: GROUP_CHAT_API.GetProjectListProps) {
    return request({
        url: api + `/corpOperation/corp/pullGroup/project/listOfPage`,
        method: 'POST',
        data
    });
}

/**
 * 计划列表
 * @param projectId 
 * @returns 
 */
export async function getProjectLogListApi(projectId: number) {
    return request({
        url: api + `/corpOperation/corp/pullGroup/project/getDetail/${projectId}`,
        method: 'GET'
    });
}


/**
 * 任务日志列表
 * @param data 
 * @returns 
 */
export async function getProjectTaskLogListApi(data: { pageNum: number, pageSize: number, taskId: number }) {
    return request({
        url: api + `/corpOperation/corp/pullGroup/project/logListOfPage`,
        method: 'POST',
        data
    });
}

/**
 * 总数
 * @param taskId 
 * @returns 
 */
export async function getProjectTaskLogCountApi(taskId: number) {
    return request({
        url: api + `/corpOperation/corp/pullGroup/project/count/${taskId}`,
        method: 'POST'
    });
}

/**
 * 任务日志详情列表
 * @param data 
 * @returns 
 */
export async function getProjectLogDetailsListApi(taskLogId: number) {
    return request({
        url: api + `/corpOperation/corp/pullGroup/project/logChatList/${taskLogId}`,
        method: 'GET'
    });
}

/**
 * 客服号详情
 * @param taskLogId 
 * @returns 
 */
export async function getProjectKfhDetailsListApi(taskLogId: number) {
    return request({
        url: api + `/corpOperation/corp/pullGroup/project/logChat/corpUserInfoList/${taskLogId}`,
        method: 'GET'
    });
}

export interface GetLogChatUserInfoListProps {
    id: number,
    pageNum: number,
    pageSize: number,
    status?: 1 | 3 | 4 | 5 | null
}

/**
 * 客户详情
 * @param data 
 * @returns 
 */
export async function getLogChatUserInfoListApi(data: GetLogChatUserInfoListProps) {
    return request({
        url: api + `/corpOperation/corp/pullGroup/project/logChat/userInfoList`,
        method: 'POST',
        data
    });
}


/**
 * 删除计划
 * @param params 
 * @returns 
 */
export async function delProjectApi(data: { projectIds: number[] }) {
    return request({
        url: api + `/corpOperation/corp/pullGroup/project/batchDelByIds`,
        method: 'POST',
        data: data.projectIds
    });
}


/**
 * 计划添加至项目组
 * @param param0 
 * @returns 
 */
export async function addProjectToGroupPullApi({ groupId, projectIds }: { groupId: number, projectIds: number[] }) {
    return request({
        url: api + `/corpOperation/corp/pullGroup/project/addProjectToGroup/${groupId}`,
        method: 'POST',
        data: projectIds
    });
}

/**
 * 停止计划
 * @param data 
 * @returns 
 */
export async function cancelProjectApi(data: { projectIds: number[], pause: boolean }) {
    return request({
        url: api + `/corpOperation/corp/pullGroup/project/cancel/${data.pause}`,
        method: 'POST',
        data: data.projectIds
    });
}

/**
 * 获取计划详情
 * @param projectId
 * @returns
 */
// export async function getCreateDetailsApi(projectId: string) {
//     return request({
//         url: api + `/corpOperation/corp/create/project/selectById/${projectId}`,
//         method: 'POST',
//     });
// }

/**
 * 获取拉群预估人数
 * */ 

export async function getPullGroupEstimateNumApi(data: any) {
    return request({
        url: api + `/corpOperation/corpPullGroupTask/task/create/predictUser/count`,
        method: 'POST',
        data
    });
}