/** ================================= 仓库信息 ================================**/
import { getUserId } from '@/services/bus/account';
import { commonSearch_go } from '@/services/go';
import {
    Ermcp3AreaStock,
    Ermcp3AreaStockApplySum,
    ErmcpWareHouseInfo
} from '@/services/go/ermcp/warehouse-info/interface';

/**
 * 查询仓库信息 /Ermcp/QueryWarehouseInfo
 * @param status 仓库状态(可多项,逗号隔开) 1:正常 2:注销 3:待审核 4:审核拒绝
 * @constructor
 */
export function QueryWareHouse(status: string): Promise<ErmcpWareHouseInfo[]> {
    const userid = getUserId()
    return commonSearch_go('/Ermcp/QueryWarehouseInfo', { userid, status }).catch((err) => {
        throw new Error(`查询仓库信息: ${err}`);
    });
}

/**
 * 查询机构库存(库存管理/当前库存)
 * @param userid 用户id
 * @constructor
 */
export function QueryAreaStock(userid: number): Promise<Ermcp3AreaStock[]> {
    return commonSearch_go('/Ermcp3/QueryAreaStock', { userid }).catch((err) => {
        throw new Error(`查询机构库存(库存管理/当前库存): ${err}`);
    });
}

/**
 * 查询已登记出入库信息(入库登记/已入库信息 | 出库登记/已出库信息) /Ermcp3/QueryAreaStockApplySum
 * @param spotcontractid 合同ID
 * @constructor
 */
export function QueryAreaStockApply(spotcontractid: string): Promise<Ermcp3AreaStockApplySum[]> {
    return commonSearch_go('/Ermcp3/QueryAreaStockApplySum', { spotcontractid }).catch((err) => {
        throw new Error(`查询已登记出入库信息(入库登记/已入库信息): ${err}`);
    });
}
