import { getLongTypeLoginID } from "@/services/bus/login";
import { ContractOperateApplyReq, ErmcpContractOperateApplyReq } from "@/services/proto/contract/interface";
import { protoMiddleware } from "@/services/socket/protobuf/buildReq";
import { getUUID } from "@/utils/qt/common";
import { getTimeValue } from "@/utils/time";
import {getUserId} from "@/services/bus/account";

/**
 * 合同
 * @param param
 */
export const operationContractReq = (param: ErmcpContractOperateApplyReq): Promise<any> => {
    const obj = {
        OperateSrc: 2,
        ClientTicket: getUUID(),
        OperateApplyID: getTimeValue(),
        UserID: getLongTypeLoginID()?.toNumber()
    }
    Object.assign(param, obj)
    return protoMiddleware<ErmcpContractOperateApplyReq>(param, 'ErmcpContractOperateApplyReq', 'ErmcpContractOperateApplyRsp', 2)
}

/**
 * 合同操作 以前管理端的一些功能使用这个接口
 * @param param 2、通过 3、拒绝 4、撤销
 */
export const contractOperateApply = (param: ContractOperateApplyReq): Promise<any> => {
    const obj = {
        OperateSrc: 2,
        OperatorID: Number(getLongTypeLoginID()),
    }
    Object.assign(param, obj)
    return protoMiddleware<ContractOperateApplyReq>(param, 'ContractOperateApplyReq', 'ContractOperateApplyRsp', 2)
}