import {getUserId} from "@/services/bus/account";
import {GldErmcpSpotContractOperateReq, SpotContractOperateReq} from "@/services/proto/spotcontract/interface";
import {protoMiddleware} from "@/services/socket/protobuf/buildReq";
import {v4 as uuidv4} from 'uuid';
import {getLongTypeLoginID} from "@/services/bus/login";

/**（重点提醒 这里属于管理端接口，仅用于新增）以上来自android代码  回头需要确认
 * 新增 / 修改采购合同报文 (很多修改合同操作也在这)
 * @param param 1:保存草稿2:提交申请3:删除4:审核通过
 */
export const orderContract = (param: GldErmcpSpotContractOperateReq): Promise<any> => {
    const OperateSrc = 2; // uint32 操作来源-1:管理端2:终端
    const ClientTicket: string = uuidv4();  // 客户端流水号
    const UserID: number = getUserId(); // 用户id
    const reqParams = {
        ...param, OperateSrc, ClientTicket, UserID
    }
    return protoMiddleware<GldErmcpSpotContractOperateReq>(reqParams, 'GldErmcpSpotContractOperateReq', 'GldErmcpSpotContractOperateRsp', 2)
}

/**
 *现货合同操作请求
 * @param param 2 操作类型-1:保存草稿2:提交申请3:审核通过4:审核拒绝5:撤回6:正常完结7:异常终止
 */
export const spotContractStatus = (param: SpotContractOperateReq): Promise<any> => {
    const OperateSrc = 2; // uint32 操作来源-1:管理端2:终端
    const ClientTicket: string = uuidv4();  // 客户端流水号
    const OperatorID: number = Number(getLongTypeLoginID()); // 用户id
    const reqParams = {
        ...param, OperateSrc, ClientTicket, OperatorID
    }
    return protoMiddleware<SpotContractOperateReq>(reqParams, 'SpotContractOperateReq', 'SpotContractOperateRsp', 2)
}