import request from '@/utils/request'

/**
 * 获取挂账人列表
 * @returns
 */
export function getCreditBuyerList(params) {
  return request({
    url: '/api/credit/buyer/page',
    method: 'get',
    params: {
      ...params
    }
  })
}

/**
 * 获取挂账人详情
 * @returns
 */
export function getCreditBuyerInfo(id) {
  return request({
    url: '/api/credit/buyer/' + id,
    method: 'get',
    params: {}
  })
}

/**
 * 增加挂账人
 * @returns
 */
export function addCreditBuyer(data) {
  return request({
    url: '/api/credit/buyer',
    method: 'post',
    data
  })
}

/**
 * 编辑挂账人
 * @returns
 */
export function editCreditBuyer(data) {
  return request({
    url: '/api/credit/buyer',
    method: 'put',
    data
  })
}

/**
 * 还款
 * @returns
 */
export function creditRePayment(data) {
  return request({
    url: '/api/credit/buyer/repayment',
    method: 'post',
    data
  })
}

/**
 * 获取还款记录
 * @returns
 */
export function creditRePaymentRecord(params) {
  return request({
    url: '/api/credit/payment-record/page',
    method: 'get',
    params
  })
}

/**
 * 删除挂账人
 * @returns
 */
export function delCreditBuyer(id) {
  return request({
    url: `/api/credit/buyer/${id}`,
    method: 'delete'
  })
}

/**
 * 挂账人-查看明细
 * @returns
 */
export function creditBuyerOrderList(params) {
  return request({
    url: '/api/credit/buyer-order/page',
    method: 'get',
    params
  })
}

/**
 * 挂账人-查看明细-统计
 * @returns
 */
export function creditBuyerOrderSummary(params) {
  return request({
    url: '/api/credit/buyer-order/summary',
    method: 'get',
    params
  })
}

/**
 * 挂账人-查看明细-付款
 * @returns
 */
export function creditPayment(data) {
  return request({
    url: '/api/credit/buyer-order/pay',
    method: 'post',
    data
  })
}
