// 套保计划
import APP from "@/services";
import { getSelectedAccountId, getUserId } from "@/services/bus/account";
import {ErmcpHedgePlanReq, HedgePlanOperateReq} from "@/services/proto/hedgeplan/interface";
import {buildProtoReq50, parseProtoRsp50, protoMiddleware} from "@/services/socket/protobuf/buildReq";
import { Callback } from "@/utils/websocket";
import moment from "moment";
import { v4 as uuidv4 } from "uuid";
import {GldErmcpSpotContractOperateReq} from "@/services/proto/spotcontract/interface";

/**
 * 套保计划操作请求
 * @param param.hedgePlanID Long 套保计划id
 * @param param.OperateType Int 操作类型-1:保存草稿2:提交申请3:删除4审核通过5审核拒绝
 */
export const hedgePlanReq = (param: ErmcpHedgePlanReq): Promise<any> => {
    param.ApplySrc = 2; // 申请来源 - 1:管理端 2:终端
    param.TradeDate = moment().format("YYMMDD");
    return protoMiddleware<ErmcpHedgePlanReq>(param, 'ErmcpHedgePlanReq', 'ErmcpHedgePlanRsp', 2)
}

/**
 * 老的计划操作接口 我只负责撤销 传5则进行撤销 !!!!! 注意
 * @param param
 */
export const oldHedgePlanReq = (param: HedgePlanOperateReq): Promise<any> => {
    param.OperateSrc = 2; // 操作来源-1:管理端2:终端
    param.ClientTicket = uuidv4(); // 流水号
    param.Remark = ''
    param.UserID = getUserId()
    return protoMiddleware<HedgePlanOperateReq>(param, 'HedgePlanOperateReq', 'HedgePlanOperateRsp', 2)
}
