import request from '@/utils/request'
import query from "@/views/ecw/customer/query";
import * as url from "url";

// 创建客户
export function createCustomer(data) {
  return request({
    url: '/ecw/customer/create',
    method: 'post',
    data: data
  })
}
//完善客户
export function fillupCustomeInfo(data){
  return request({
    url:'/ecw/customer/fillup-customer-info',
    method:'put',
    data
  })
}
// 更新客户
export function updateCustomer(data) {
  return request({
    url: '/ecw/customer/update',
    method: 'put',
    data: data
  })
}

// 删除客户
export function deleteCustomer(id) {
  return request({
    url: '/ecw/customer/delete?id=' + id,
    method: 'delete'
  })
}

// 获得客户
export function getCustomer(id) {
  return request({
    url: '/ecw/customer/get?id=' + id,
    method: 'get'
  })
}

// 获得客户分页
export function getCustomerPage(query) {
  return request({
    url: '/ecw/customer/page',
    method: 'get',
    params: query
  })
}

// 获得客户下拉
export function getCustomerSelect(query) {
  return request({
    url: '/ecw/customer/select',
    method: 'get',
    params: query
  })
}

// 根据客户id集合获得客户详情列表
export function getCustomerList(query) {
  return request({
    url: '/ecw/customer/list',
    method: 'get',
    params: query
  })
}

// 导出客户 Excel
export function exportCustomerExcel(query) {
  return request({
    url: '/ecw/customer/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// 待接收客户列表
export function getWaitForConfirmList(query) {
  return request({
    url: '/ecw/customer/get-wait-for-confirm',
    method: 'get',
    params: query
  })
}

// 确认
export function confirm(data) {
  return request({
    url: '/ecw/customer/confirm',
    method: 'put',
    data: data
  })
}

// 待分配客户
export function getWaitForDistributionList(query) {
  return request({
    url: '/ecw/customer/get-wait-for-distribution',
    method: 'get',
    params: query
  })
}

// 移交
export function handOverCustomer(data) {
  return request({
    url: '/ecw/customer/handOver',
    method: 'put',
    data: data,
    })
}

// 公海池客户
export function getPublicList(query) {
  return request({
    url: '/ecw/customer/get-public',
    method: 'get',
    params: query
  })
}

//捞取
export function setFishing(query){
  return request({
    url:'/ecw/customer/catch-open-sea-customer',
    method:'put',
    params:query,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
    }
  })
}
//待分配 客户列表
export function getCustomerToBeAssigned(query){
  return request(
    {
      url:'ecw/customer/get-wait-for-distribution',
      method: 'get',
      params: query

    }
  )
}
//我的客户列表
export function getMyCustomerService(query){
  return request({
    url:'/ecw/customer/get-mine',
    method:'get',
    params:query,
  })
}
//获取会员列表
export  function userMemberUserList(params){
  return request({
    url:'/member/user/member-user-list',
    method:'get',
    params
  })
}
export function memberUserList(params){
  return request({
    url:'/member/user/list',
    method:'get',
    params
  })
}
//查看某客户授权的品牌
export function getBrankByCustomer(data){
  return request({
    url:'/ecw/product-brank/getBrankByCustomer',
    method:'post',
    data,
  })
}
//
export function levelLogPage(params){
  return request({
    url:'/customer/detail/infoList/levelLogPage',
    method:'get',
    params
  })
}
//获取信用等级日志列表
export function customerCreditLogPage(params){
  return  request({
    url:'/customer/detail/infoList/creditLogPage',
    method:'get',
    params
  })
}
//客户详情订单分页
export function infoListOrderPage(params){
  return request({
    url:'/customer/detail/infoList/orderPage',
    method:'get',
    params
  })
}
//客户详情 --- 报价
export  function infoListOfferPage(params){
  return request({
    url:'/customer/detail/infoList/offerPage',
    method:'get',
    params
  })
}
//客户数据
export function orderStatistics(params){
  return request({
    url:'/customer/detail/infoList/orderStatistics',
    method:'get',
    params
  })
}
//创建客户信用日志
export function creditLogCreate(data){
  return request({
    url:'/customer/credit-log/create',
    method:'post',
    data
  })
}
//获得客户统计
export function creditScoreStatistic(params){
  return request({
    url:'/customer/detail/infoList/creditScoreStatistic',
    method:'get',
    params
  })
}
//获取账单数据
export function infoListReceiptPage(params){
  return request({
    url:'/customer/detail/infoList/receiptPage',
    method:'get',
    params
  })
}

// 获取用户
export function getMember(id){
  return request({
    url: "/member/user/get",
    params: {id}
  })
}

// 获得客户路线
export function getCustomerLines(customerId){
  return request({
    url: '/ecw/customer-line/get-by-customer',
    params: {customerId}
  })
}

