import { request } from 'umi';
import { api } from '../api';
import { Paging, SortProps } from './rankingList';
let wapi = api + '/gameData'

export interface RoleRechargeRankingProps extends Paging, SortProps {
    createRoleBeginDate?: string,  // 角色创建时间（开始）
    createRoleEndDate?: string,
    rechargeBeginDate?: string,    // 充值开始时间
    rechargeEndDate?: string,

    customerServerId?: number,  // 客服ID
    operatorId?: number         // 运营ID
    gsId?: number               // GS_ID
    serverIds?: number[]        // 区服ID（列表）

    gameId?: number,            // 子游戏ID
    parentGameId?: number,      // 父游戏ID
    isChange?: number,          // 是否转端: 1 -> 转端 ； 0 -> 不转端
    isSendMail?: number         // 邮件是否发送: 1 -> 发送 ； 0 -> 不发送
    phone?: number              // 客户手机号
    pitcherId?: number          // 投手ID
    roleName?: string,          // 角色名
    roleId?: string,            // 角色ID
    vipLevel?: number           // 角色VIP等级
    weChat?: string,            // 客户微信号
    weChatCompany?: string,     // 企业微信号
}
/**
 * 角色充值排行榜
 * @param data 
 * @returns 
 */
export async function getRoleRechargeRankingListApi(data: RoleRechargeRankingProps) {
    return request(wapi + `/role/rechargeRanking`, {
        method: 'POST',
        data
    });
}


/**
 * 礼包记录新增或者更新
 * @param data 
 * @returns 
 */
export async function addOrUpdateGiftApi(data: { giftId: number, ids?: number[], roleInfoList: any[], sendTime: string }) {
    return request(api + `/manage/role/gift/record/add/or/update`, {
        method: 'POST',
        data
    });
}

/**
 * 删除礼包记录
 * @param ids 
 * @returns 
 */
export async function delSendGiftLogApi(ids: string) {
    return request(api + `/manage/role/gift/record/delete/${ids}`, {
        method: 'DELETE'
    });
}

export interface getSendGiftLogProps extends Paging {
    startDateTime?: string,
    endDateTime?: string,
    giftName?: string,
    gameId?: number,
    roleId?: number,
    serverId?: number
    userId?: number
}
/**
 * 发送礼包记录接口
 * @param data 
 * @returns 
 */
export async function getSendGiftLogListApi(data: getSendGiftLogProps) {
    return request(api + `/manage/role/gift/record/list`, {
        method: 'POST',
        data
    });
}


export interface getSendEmailLogProps extends Paging {
    startDateTime?: string,
    endDateTime?: string,

    gameId?: number,
    roleId?: number,
    serverId?: number
    userId?: number
}
/**
 * 发送邮件记录接口
 * @param data 
 * @returns 
 */
export async function getSendEmailListApi(data: getSendEmailLogProps) {
    return request(api + `/manage/role/mail/record/list`, {
        method: 'POST',
        data
    });
}


/**
 * 删除邮件记录
 * @param ids 
 * @returns 
 */
export async function delSendEmailLogApi(ids: string) {
    return request(api + `/manage/role/mail/record/delete/${ids}`, {
        method: 'DELETE'
    });
}


/**
 * 邮件记录新增或者更新
 * @param data 
 * @returns 
 */
export async function addOrUpdateEmailApi(data: { ids?: number[], roleInfoList: any[], sendTime: string }) {
    return request(api + `/manage/role/mail/record/add/or/update`, {
        method: 'POST',
        data
    });
}


export interface modifyRoleProps {
    addCorpUserId?: string // 企微号
    isAddCorpWechat?: string
    isChangeGameType?: string
    isRemoveGame?: string
    isWakeUp?: string
    putUserId?: number
    remark?: string
    roleInfoList?: any
    userPhone?: string
    userWechat?: string
}
/**
 * 角色信息管理
 * @param data 
 * @returns 
 */
export async function modifyRoleDataApi(data: modifyRoleProps) {
    return request(api + `/manage/role/operate/modify`, {
        method: 'POST',
        data
    });
}


export interface AssignUserProps {
    startTime: string,
    customerServiceId?: number,
    gsId?: number,
    operUserId?: number,
    remark?: string,
    roleInfoAndAgentParamList: any
}
/**
 * 指派
 * @param data 
 * @returns 
 */
export async function addAssignUserApi(data: AssignUserProps) {
    return request(api + `/manage/role/assign/record/config/sysUser`, {
        method: 'POST',
        data
    });
}

/**
 * 删除
 * @param ids 
 * @returns 
 */
export async function delAssignUserApi(ids: string) {
    return request(api + `/manage/role/assign/record/delete/${ids}`, {
        method: 'DELETE'
    });
}


export interface GetAssignUser extends Paging {
    customerServiceId?: number,
    gameId?: number,
    gsId?: number,
    operUserId?: number,
    regAgentId?: number,
    remark?: string,
    roleId?: number,
    serverId?: number,
    userId?: number
}
/**
 * 
 * @param data 
 * @returns 
 */
export async function getAssignUserApi(data: GetAssignUser) {
    return request(api + `/manage/role/assign/record/list`, {
        method: 'POST',
        data
    });
}

/**
 * 修改
 * @param data 
 * @returns 
 */
export async function editAssignUserApi(data: AssignUserProps) {
    return request(api + `/manage/role/assign/record/modify`, {
        method: 'POST',
        data
    });
}

export interface GetCombatRankingProps extends Paging, SortProps {
    beginDate?: string,  // 开服时间（开始）
    endDate?: string,
    gameId?: number,        // 游戏ID
    parentGameId?: number   // 主游戏ID
    rankingNum?: number     // 排名的范围
    serverIds?: number[],   // 区服
}

export async function getCombatRankingListApi(data: GetCombatRankingProps) {
    return request(wapi + `/role/combatRanking`, {
        method: 'POST',
        data
    });
}
