/**
 * 供需接口
 */
import request from '@/utils/request'
import { getSignTimeStamp } from '@/utils/mathUtils'
import Vue from 'vue'

// 各地区供需数据
export function getAreaNeedSupply(params) {
  return request({
    url: 'http://rest.apizza.net/mock/cfbb939c147bb6d68372de83af189fee/areaNeedSupply',
    method: 'get',
    params
  })
}
// 各地区供给
export function getAreaSupply() {
  const baseConfig = Vue.prototype.baseConfig
  const { sign, username, timestamp } = getSignTimeStamp()
  return request({
    url: baseConfig.biUrl + '/factdata/index/getData',
    method: 'post',
    data: {
      'showField': 'WD01_03,WD03_04,DL01',
      'indexId': 'E84C7DDEC62842CDAB9309D64239E4E9',
      'distinct': true,
      'type': 0,
      'pageNo': null,
      'pageSize': null,
      'sign': sign,
      'name': username,
      'time': timestamp
    }
  })
}
// 各地区供给-旧
export function getAreaSupplyOld(date) {
  const baseConfig = Vue.prototype.baseConfig
  const { sign, username, timestamp } = getSignTimeStamp()
  return request({
    url: baseConfig.biUrl + '/factdata/index/getData',
    method: 'post',
    data: {
      'showField': 'WD01_03,WD03_04,DL01',
      'indexId': '8C2A9E095D0849EAAF54FFDAF832FDC3',
      'distinct': true,
      'type': 0,
      'pageNo': null,
      'pageSize': null,
      'sign': sign,
      'name': username,
      'time': timestamp
    }
  })
}
// 各用户供需数据
export function getUserNeedSupply(params) {
  return request({
    url: 'http://rest.apizza.net/mock/cfbb939c147bb6d68372de83af189fee/userNeedSupply',
    method: 'get',
    params
  })
}

// 各用户供需数据
export function getUserSupply(date) {
  const baseConfig = Vue.prototype.baseConfig
  const { sign, username, timestamp } = getSignTimeStamp()
  return request({
    url: baseConfig.biUrl + '/factdata/index/getData',
    method: 'post',
    data: {
      'showField': 'WD01_03,WD02_03,WD02_04,WD02_05,DL01',
      'indexId': '8C2A9E095D0849EAAF54FFDAF832FDC3',
      'distinct': true,
      'type': 0,
      'conditionList': [],
      'pageNo': null,
      'pageSize': null,
      'sign': sign,
      'name': username,
      'time': timestamp
    }
  })
}

// 各用户供需数据-old
export function getUserSupplyOld(date) {
  const baseConfig = Vue.prototype.baseConfig
  const { sign, username, timestamp } = getSignTimeStamp()
  return request({
    url: baseConfig.biUrl + '/factdata/index/getData',
    method: 'post',
    data: {
      'showField': 'WD01_01,WD_01_03,WD02_01,WD02_03,WD02_04,WD02_05,WD_06,DL02,DL03',
      'indexId': '56680A347AF44DAEB1286A7C69D97A2F',
      'type': 0,
      'conditionList': [
        [
          {
            'condition': '1',
            'dimId': 'YEAR8MONTH8DAY66PACKINGDATA99DAY',
            'key': 'WD01_03',
            'value': [date]
          }
        ]
      ],
      'pageNo': null,
      'pageSize': null,
      'sign': sign,
      'name': username,
      'time': timestamp
    }
  })
}
