/** ================================= 期货订单 ================================**/
import { commonSearch_go } from '@/services/go/index';
import { QueryErmcpTradePositionReq, QueryErmcpTradePositionRsp, QueryErmcpOrderDetailsReq, QueryErmcpOrderDetailsRsp, QueryErmcpTradeDetailsReq, QueryErmcpTradeDetailsRsp } from './interface';
import { getSelectedAccountId } from '@/services/bus/account';

/**
 * 获取企业风管期货持仓头寸信息
 */
export async function queryErmcpTradePosition(params?: QueryErmcpTradePositionReq): Promise<QueryErmcpTradePositionRsp[]> {
    try {
        const accountID = getSelectedAccountId();
        if (accountID) {
            return commonSearch_go('/Ermcp/QueryErmcpTradePosition', {
                accountID: getSelectedAccountId(),
                ...params
            });
        }
        return []
    } catch (err) {
        throw new Error(`获取企业风管期货持仓头寸信息: ${err}`);
    }
}

/**
 * 获取企业风管期货委托单信息
 */
export async function queryErmcpOrderDetails(params?: QueryErmcpOrderDetailsReq): Promise<QueryErmcpOrderDetailsRsp[]> {
    try {
        const accountID = getSelectedAccountId();
        if (accountID) {
            return commonSearch_go('/Ermcp/QueryErmcpOrderDetails', {
                accountID: getSelectedAccountId(),
                ...params
            });
        }
        return []
    } catch (err) {
        throw new Error(`获取企业风管期货成交单信息: ${err}`);
    }
}

/**
 * 获取企业风管期货成交单信息
 */
export async function queryErmcpTradeDetails(params?: QueryErmcpTradeDetailsReq): Promise<QueryErmcpTradeDetailsRsp[]> {
    try {
        const accountID = getSelectedAccountId();
        if (accountID) {
            return commonSearch_go('/Ermcp/QueryErmcpTradeDetails', {
                accountID: getSelectedAccountId(),
                ...params
            });
        }
        return []
    } catch (err) {
        throw new Error(`获取企业风管期货成交单信息: ${err}`);
    }
}
