import request from '@/utils/request'

// 查询商户列表
export function listMerchant(query) {
  return request({
    url: '/agri/merchant/list',
    method: 'get',
    params: query
  })
}

// 查询商户详情
export function getMerchant(merchantId) {
  return request({
    url: '/agri/merchant/' + merchantId,
    method: 'get'
  })
}

// 新增商户
export function addMerchant(data) {
  return request({
    url: '/agri/merchant',
    method: 'post',
    data: data
  })
}

// 修改商户
export function updateMerchant(data) {
  return request({
    url: '/agri/merchant',
    method: 'put',
    data: data
  })
}

// 修改认证状态
export function updateMerchantCertStatus(merchantId, data) {
  return request({
    url: '/agri/merchant/' + merchantId + '/certStatus',
    method: 'put',
    data: data
  })
}

// 删除预检
export function deleteMerchantCheck(merchantId) {
  return request({
    url: '/agri/merchant/' + merchantId + '/deleteCheck',
    method: 'get'
  })
}

// 删除商户
export function delMerchant(merchantIds) {
  return request({
    url: '/agri/merchant/' + merchantIds,
    method: 'delete'
  })
}

// 开店可选商户列表
export function selectMerchantList() {
  return request({
    url: '/agri/merchant/selectList',
    method: 'get'
  })
}

// 商户是否可开店（与 POST /agri/shop 同一套校验）
export function openShopCheck(merchantId) {
  return request({
    url: '/agri/merchant/' + merchantId + '/openShopCheck',
    method: 'get'
  })
}

// 入驻可选平台管理员
export function adminUserOptions(keyword) {
  return request({
    url: '/agri/merchant/adminUserOptions',
    method: 'get',
    params: { keyword: keyword }
  })
}

// 入驻可选会员
export function memberOptions(keyword) {
  return request({
    url: '/agri/merchant/memberOptions',
    method: 'get',
    params: { keyword: keyword }
  })
}
