import { httpRequest } from '@/services/http'
import { tradeServerRequest } from '@/services/socket/trade'
import { TradeParams } from '@/services/socket/trade/interface'
import { loginStore } from '@/stores'

const { userId } = loginStore.$mapGetters()

/**
 * 查询收货地址信息
 */
export function queryUserReceiveInfo(params: Model.UserReceiveInfoReq) {
    params.userid = userId.value
    return httpRequest<Model.UserReceiveInfoRsp[]>('/Qhj/QueryUserReceiveInfo', 'get', params);
}

/**
 * 查询发票信息
 */
export function queryWrUserReceiptInfo(params: Model.WrUserReceiptInfoReq) {
    return httpRequest<Model.WrUserReceiptInfoRsp[]>('/WrTrade2/QueryWrUserReceiptInfo', 'get', params);
}

/**
 * 新增修改收货地址
 */
export function userReceiveInfo(params: TradeParams<Proto.UserReceiveInfoReq, Proto.UserReceiveInfoRsp>) {
    return tradeServerRequest('UserReceiveInfoReq', 'UserReceiveInfoRsp', params);
}

/**
 * 删除收货地址
 */
export function delUserReceiveInfo(params: TradeParams<Proto.DelUserReceiveInfoReq, Proto.DelUserReceiveInfoRsp>) {
    return tradeServerRequest('DelUserReceiveInfoReq', 'DelUserReceiveInfoRsp', params);
}

/**
 * 设置默认收货地址
 */
export function userReceiveIsDefault(params: TradeParams<Proto.UserReceiveIsDefaultReq, Proto.UserReceiveIsDefaultRsp>) {
    return tradeServerRequest('UserReceiveIsDefaultReq', 'UserReceiveIsDefaultRsp', params);
}

/**
 * 新增修改用户发票信息
 */
export function userReceiptInfo(params: TradeParams<Proto.UserReceiptInfoReq, Proto.UserReceiptInfoRsp>) {
    return tradeServerRequest('UserReceiptInfoReq', 'UserReceiptInfoRsp', params);
}

/**
 * 删除用户发票信息
 */
export function delUserReceiptInfo(params: TradeParams<Proto.DelUserReceiptInfoReq, Proto.DelUserReceiptInfoRsp>) {
    return tradeServerRequest('DelUserReceiptInfoReq', 'DelUserReceiptInfoRsp', params);
}

/**
 * 交易商头像
 */
export function dealerHead(params: TradeParams<Proto.DealerHeadReq, Proto.DealerHeadRsp>) {
    return tradeServerRequest('DealerHeadReq', 'DealerHeadRsp', params);
}

/**
 * 更新用户头像
 */
export function updateUserHeadUrl(params: Model.UserHeadUrlReq) {
    return httpRequest('/User/UpdateUserHeadUrl', 'post', params);
}