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


export interface GetLicenseAppListProps {
    pageNum: number,
    pageSize: number,
    corpName?: string,
    expiredStart?: string,
    expiredEnd?: string,
    licenseCheckStart?: string,
    licenseCheckEnd?: string
    sortFiled?: string
    sortAsc?: boolean
    bugStatus?: 0 | 1
}

/**
 * 企业许可列表
 * @returns 
 */
export function getLicenseAppListApi(data: GetLicenseAppListProps) {
    return request({
        url: api + `/corpOperation/license/app/listOfPage`,
        method: 'POST',
        data
    })
}


/**
 * 应用信息同步更新 
 * @param params 
 * @returns 
 */
export function syncByCorpAppApi(params: { corpId: string }) {
    return request({
        url: api + `/corpOperation/license/app/syncByCorpId`,
        method: 'PATCH',
        params
    })
}


/**
 * 修改应用信息更新通知人员
 * @param data 
 * @returns 
 */
export function updateCallUserAppApi(data: { corpIdList: string[], userIdList: number[] }) {
    return request({
        url: api + `/corpOperation/license/app/updateCallUserIds`,
        method: 'POST',
        data
    })
}


export interface GetLicenseOrderListProps {
    pageNum: number,
    pageSize: number,
    corpName?: string,
    orderId?: string,
    orderType?: number,
    orderStatus?: number
}
/**
 * 企业订单列表
 * @returns 
 */
export function getLicenseOrderListApi(data: GetLicenseOrderListProps) {
    return request({
        url: api + `/corpOperation/license/order/listOfPage`,
        method: 'POST',
        data
    })
}

export interface GetLicenseCodeListProps {
    pageNum: number,
    pageSize: number,
    corpName?: string,
    activeCode?: string,
    status?: number
}
/**
 * 席位详情列表
 * @returns 
 */
export function getLicenseCodeListApi(data: GetLicenseCodeListProps) {
    return request({
        url: api + `/corpOperation/license/code/listOfPage`,
        method: 'POST',
        data
    })
}

export interface ActiveCodeProps {
    corpId: string,
    activeParam: {
        active_code: string,
        userid: string
    }[]
}


/**
 * 激活
 * @param data 
 * @returns 
 */
export function activeCodeApi(data: ActiveCodeProps) {
    return request({
        url: api + `/corpOperation/license/code/batch/active`,
        method: 'POST',
        data
    })
}


export interface TransferCodeProps {
    corpId: string,
    transferParam: {
        handover_userid: string,
        takeover_userid: string
    }[]
}

/**
 * 继承
 * @param data 
 * @returns 
 */
export function transferCodeApi(data: TransferCodeProps) {
    return request({
        url: api + `/corpOperation/license/code/batch/transfer`,
        method: 'POST',
        data
    })
}