import httpClient from '@/services/http'
import { CommonFetchOptions } from '@/services/http/types'
import { useUserStore } from '@/stores'

const userStore = useUserStore()

/**
 * 获取签名sign
 */
export function getCheckSign(options: CommonFetchOptions<{ response: string; }> = {}) {
    return httpClient.commonRequest('/common/getCheckSign', 'get', options)
}

/**
 * 机构下拉查询加载 会员、经纪人
 */
export function queryOrganSelect(options: CommonFetchOptions<{ request: Model.OrganSelectReq; response: Model.OrganSelectRsp[]; }>) {
    return httpClient.commonRequest('/common/queryOrganSelect', 'get', options)
}

/**
 * 子机构管理-->获取机构及所有子机构
 */
export function queryOrganSelect2And3(options: CommonFetchOptions<{ request: Partial<Model.OrganSelect2And3Req>; response: Model.OrganSelect2And3Rsp[]; }>) {
    return httpClient.commonRequest('/common/queryOrganSelect2And3', 'get', options)
}

/**
 * 子机构开户下拉查询推荐人
 */
export function queryInvestorSelect(options: CommonFetchOptions<{ request: Model.InvestorSelectReq; response: Model.InvestorSelectRsp[]; }> = {}) {
    options.data = {
        orgzTypes: userStore.userInfo.orgztypes,
        ...options.data
    }
    return httpClient.commonRequest('/common/queryInvestorSelect', 'get', options)
}

/**
 * 获取省、市、县信息
 */
export function getProvince(options: CommonFetchOptions<{ request: Model.ProvinceReq; response: Model.ProvinceRsp[]; }>) {
    return httpClient.commonRequest('/common/getProvince', 'get', options)
}

/**
 * 获取枚举信息
 */
export function enumType(options: CommonFetchOptions<{ request: Model.EnumTypeReq; response: Model.EnumTypeRsp[]; }>) {
    return httpClient.commonRequest('/common/enumType', 'get', options)
}

/**
 * 获取市场下拉列表
 */
export function orderListAll(options: CommonFetchOptions<{ request: Model.OrderListAllReq; response: Model.OrderListAllRsp[]; }> = {}) {
    options.data = {
        orgztypes: userStore.userInfo.orgztypes
    }
    return httpClient.commonRequest('/common/orderListAll', 'get', options)
}

/**
 * 商品查询下拉框
 */
export function queryGoodsSelect(options: CommonFetchOptions<{ request: Model.GoodsSelectReq; response: Model.GoodsSelectRsp[]; }>) {
    return httpClient.commonRequest('/common/queryGoodsSelect', 'get', options)
}

/**
 * 资金账户下拉框 平台查所有，经纪会员/子机构查自己及下级，其它角色查自己
 */
export function queryTAAccountChildren(options: CommonFetchOptions<{ request: Model.TAAccountChildrenReq; response: Model.TAAccountChildrenRsp[]; }>) {
    return httpClient.commonRequest('/common/queryTAAccountChildren', 'get', options)
}

/**
 * 递归查询机构，用于交 易所子机构管理中添加子机构和经纪人
 */
export function queryExchSonOrgin(options: CommonFetchOptions<{ request: Model.ExchSonOrginReq; response: Model.ExchSonOrginRsp[]; }>) {
    return httpClient.commonRequest('/common/queryExchSonOrgin', 'get', options)
}

/**
 * 获取用户信息
 */
export function queryUserinfoByUserId(options: CommonFetchOptions<{ request: Model.UserinfoByUserIdReq; response: Model.UserinfoByUserIdRsp; }>) {
    return httpClient.commonRequest('/common/queryUserinfoByUserId', 'get', options)
}

export function queryConfig(options: CommonFetchOptions<{ request: Model.ConfigReq; response: Model.ConfigRsp; }>) {
    return httpClient.commonRequest('/common/queryConfig', 'get', options)
}

/**
 * queryTAAccountList
 */
export function queryTAAccountList(options: CommonFetchOptions<{ request: Model.TAAccountListReq; response: Model.TAAccountListRsp[]; }>) {
    return httpClient.commonRequest('/common/queryTAAccountList', 'get', options)
}

/**
 * 获取资金账户信息
 */
export function queryAccountId(options: CommonFetchOptions<{ request: Model.AccountIdReq; response: Model.AccountIdRsp; }>) {
    return httpClient.commonRequest('/common/queryAccountId', 'get', options)
}

/**
 * 做市会员获取资金账户信息
 */
export function queryAccountIdForMarket(options: CommonFetchOptions<{ request: Model.AccountIdReq; response: Model.AccountIdRsp; }>) {
    return httpClient.commonRequest('/common/queryAccountIdForMarket', 'get', options)
}