/** ================================= 现货报表 ================================**/
import { getUsrId } from '@/services/bus/user';
import { commonSearch_go } from '@/services/go/index';
import * as type from './interface';
import { QuerySpotDayReportDetailReq, QuerySpotMonthReportDetailReq, QuerySpotPLReportReq } from './interface';
/**
 * 查询现货损益报表
 * @param queryInfo 查询条件
 * @returns 现货损益报表
 */
export async function QuerySpotPLReport(queryInfo: QuerySpotPLReportReq): Promise<type.QuerySpotPLReportRsp[]> {
    return commonSearch_go('/Ermcp3/QryReportAreaSpotPL', queryInfo).catch(err => {
        throw new Error(`查询现货损益报表: ${err}`);
    });

}

/**
 * 查询现货报表
 * @param tradedate 交易日(格式:yyyyMMdd)
 * @returns 现货报表
 */
export async function QuerySpotDayReport(tradedate: string): Promise<type.QuerySpotDayReportRsp[]> {
    const userid = getUsrId()
    return commonSearch_go('/Ermcp3/QryReportDaySpot', { tradedate, userid }).catch(err => {
        throw new Error(`查询现货报表: ${err}`);
    });

}

/**
 * 查询现货明细报表
 * @param queryInfo 查询信息
 * @returns 现货明细报表
 */
export async function QuerySpotDayReportDetail(queryInfo: QuerySpotDayReportDetailReq): Promise<type.QuerySpotDayReportDetailRsp[]> {
    return commonSearch_go('/Ermcp3/QryReportDaySpotDetail', queryInfo).catch(err => {
        throw new Error(`查询现货明细报表: ${err}`);
    });
}

/**
 * 查询现货月报表
 * @param tradedate 交易日(格式:yyyyMMdd)
 * @returns 现货月报表数据
 */
export async function QuerySpotMonthReport(tradedate: string): Promise<type.QuerySpotMonthReportRsp[]> {
    const userid = getUsrId()
    return commonSearch_go('/Ermcp3/QryReportMonthSpot', { tradedate, userid }).catch(err => {
        throw new Error(`查询现货月报表: ${err}`);
    });
}

/**
 * 查询现货月报表明细
 * @param queryInfo 查询信息
 * @returns 现货月报表明细
 */
export async function QuerySpotMonthReportDetail(queryInfo: QuerySpotMonthReportDetailReq): Promise<type.QuerySpotMonthReportDetailRsp[]> {
    return commonSearch_go('/Ermcp3/QryReportMonthSpotDetail', { queryInfo }).catch(err => {
        throw new Error(`查询现货月报表明细: ${err}`);
    });
}
