/**
 * api
 * 礼品管理
 */
import getFetch from './get-fetch.js';
import config, { welfarePrefix, commonPrefix } from '@/config';


// 礼品相关接口
let realGift = {
  getGiftId: '/gift/get-gift-id', // 随机返回一个Id
  giftGet: '/gift/get', // 新建/编辑礼品时获取数据
  giftSave: {
    // 新增礼品
    url: '/gift/save',
    method: 'post'
  },
  giftUpdate: {
    // 编辑礼品
    url: '/gift/update',
    method: 'post'
  },
  giftPage: {
    // 礼品列表
    url: '/gift/page',
    method: 'post'
  },
  giftStockRecord: '/gift/stock-record', // 库存记录
  giftStockLog: '/gift/stock-record-log', // 库存操作记录
  giftActivity: '/gift/activity-statistics', // 活动统计
  giftTemplateDownload: {
    url: '/gift/vir-gift-template-download',
    useFormData: true,
    method: 'post'
  }, // 下载虚拟礼品模板
  giftTemplateUpload: '/gift/template-upload', // 上传模板
  giftBatchUpdate: {
    // 礼品批量操作
    url: '/gift/batch-update',
    method: 'post'
  },
  giftStandardNew: '/gift/spec-save', // 规格新建
  giftStandardList: '/gift/spec-list', // 规格查询
  giftStandardValueNew: '/gift/spec-value-save', // 规格值新建
  giftStandardValueList: '/gift/spec-value-list', // 规格值查询
  virtualCardList: '/gift/vir-card-page', // 虚拟礼品卡券卡密列表

  batchUpdate: {
    url: '/gift/batch-update',
    method: 'post'
  }, // 批量操作
  realCostUpdate: {
    url: '/gift/real-cost-update',
    method: 'post'
  }, // 实物礼品调整成本
  realStockUpdate: {
    url: '/gift/real-stock-update',
    method: 'post'
  }, // 实物礼品调整库存
  getPickupList: '/pickup/get-pickup-list', // 获取自提点列表
  getGiftShopList: '/gift/get-gift-shop-list', // 获取当前礼品的自提点
  updateName: '/gift/update-name', // 修改礼品名称
  virtualGiftUpload: {
    url: '/gift/vir-gift-upload',
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data;' },
    file: true
  }, // 虚拟礼品卡密卡号上传
  operatorSave: {
    url: '/auth/operator-save',
    method: 'post'
  }, // 保存操作人权限数据
  getOperatorList: '/auth/operator-list', // 查询操作人权限回显数据
  virtualCostUpdate: '/gift/vir-cost-update', // 虚拟礼品调整库存
};

// 通用配置
let setting = {
  updateConfig: {
    url: '/config/update-config',
    method: 'post',
    headers: { 'Content-Type': 'application/json' }
  },
  getConfigDetail: '/config/get-config-detail',
  getAddressList: '/address/get-address-list',
  getAddressDetails: 'address/get-address-details',
  delAddress: '/address/del-address',
  insertOrUpdateAddress: { // 新增或修改退货地址
    url: '/address/insert-or-update-address',
    method: 'post',
    headers: { 'Content-Type': 'application/json' }
  },
  pickupList: '/pickup/get-pickup-list',
  getPickupDetails: '/pickup/get-pickup-details',
  delPickup: {
    url: '/pickup/del-pickup',
    useFormData: true,
    method: 'post',
  },
  insertPickupStore: { // 新增自提点
    url: '/pickup/insert-pickup-store',
    method: 'post',
    headers: { 'Content-Type': 'application/json' }
  },
  updatePickupStore: { // 更新单个或多个自提点
    url: '/pickup/update-pickup-setting',
    method: 'post',
    headers: { 'Content-Type': 'application/json' }
  },
};
realGift = getFetch(realGift, welfarePrefix);
setting = getFetch(setting, welfarePrefix);

export default { ...realGift, ...setting };

export const getGiftLoginUser = config.api + commonPrefix + '/user/get-login-user'; // 获取商户名称
export const exportPickupStoreExcel = config.api + welfarePrefix + '/export-pickup-store-excel'; // 导出自提点