import http from '@/services/http'
import tradeServer from '@/services/socket/trade'

/**
 * 履约违约申请
 */
export function performanceContractedApply(params: Proto.PerformanceContractedApplyReq) {
    return tradeServer.sendMessage<Proto.PerformanceContractedApplyRsp>({
        params,
        reqName: 'PerformanceContractedApplyReq',
        rspName: 'PerformanceContractedApplyRsp'
    })
}

/**
 * 履约延期申请
 */
export function performanceDelayApply(params: Partial<Proto.PerformanceDelayApplyReq>) {
    return tradeServer.sendMessage<Proto.PerformanceDelayApplyRsp>({
        params,
        reqName: 'PerformanceDelayApplyReq',
        rspName: 'PerformanceDelayApplyRsp'
    })
}

/**
 * 履约手动申请
 */
export function performanceManualConfirm(params: Partial<Proto.PerformanceManualConfirmReq>) {
    return tradeServer.sendMessage<Proto.PerformanceManualConfirmRsp>({
        params,
        reqName: 'PerformanceManualConfirmReq',
        rspName: 'PerformanceManualConfirmRsp'
    })
}

/**
 * 履约修改联络信息
 */
export function performanceModifyContact(params: Proto.PerformanceModifyContactReq) {
    return tradeServer.sendMessage<Proto.PerformanceModifyContactRsp>({
        params,
        reqName: 'PerformanceModifyContactReq',
        rspName: 'PerformanceModifyContactRsp'
    })
}

/**
 * 查询我的履约
 */
export function queryMyPerformance(params: Ermcp.MyPerformancReq) {
    return http.commonRequest<Ermcp.MyPerformancRsp[]>({
        url: '/Guangzuan/QueryMyPerformanc',
        params,
    })
}

/**
 * 查询履约模板
 */
export function queryPermancePlanTmp(params?: Ermcp.PermancePlanTmpReq) {
    return http.commonRequest<Ermcp.PermancePlanTmpRsp[]>({
        url: '/WrTrade2/QueryPermancePlanTmp',
        params,
    })
}

/**
 * 查询履约步骤枚举
 */
export function queryWrPerformanceStepType() {
    return http.commonRequest<Ermcp.WrPerformanceStepTypeRsp[]>({
        url: '/WrTrade2/QueryWrPerformanceStepType',
    })
}

/**
 * 查询履约信息详情
 */
export function queryWrPerformancePlanStep(params: Ermcp.WrPerformancePlanStepReq) {
    return http.commonRequest<Ermcp.WrPerformancePlanStepRsp[]>({
        url: '/WrTrade2/QueryWrPerformancePlanStep',
        params,
    })
}