import { request } from 'umi';

/**
 * 积分规则关联设备
 */

 export async function addintegral(data) {
  return request(`/kitchen/api/integral/add`, {
    method: 'POST',
    data: data,
  });
}
/** 修改积分规则类型 */

export async function editintegral(data) {
  return request(`/kitchen/api/integral/edit`, {
    method: 'POST',
    data: data,
  });
}

/** 查询积分规则类型分页 */
export async function getintegral(data) {
  return request(`/kitchen/api/integral/getpage`, {
    method: 'POST',
    data: data,
  });
}



/**
 * 积分规则类型
 */

/** 添加积分规则类型 */
export async function addintegraltype(data) {
  return request(`/kitchen/api/integraltype/add`, {
    method: 'POST',
    data: data,
  });
}
/** 修改积分规则类型 */

export async function editintegraltype(data) {
  return request(`/kitchen/api/integraltype/edit`, {
    method: 'POST',
    data: data,
  });
}

/** 查询积分规则类型分页 */
export async function getintegraltype(data) {
  return request(`/kitchen/api/integraltype/getpage`, {
    method: 'POST',
    data: data,
  });
}


/**
 * 积分规则
 */
/** 添加积分规则类型 */
export async function addintegralrule(data) {
  return request(`/kitchen/api/integralrule/add`, {
    method: 'POST',
    data: data,
  });
}
/** 修改积分规则类型 */

export async function editintegralrule(data) {
  return request(`/kitchen/api/integralrule/edit`, {
    method: 'POST',
    data: data,
  });
}

export async function editIntegralRuleStatus(data) {
  return request(`/kitchen/api/integralrule/edit`, {
    method: 'POST',
    data: data,
  });
}



/** 查询积分规则类型分页 */
export async function getintegralrule(data) {
  return request(`/kitchen/api/integralrule/getpage`, {
    method: 'POST',
    data: data,
  });
}


/**
 * 商品类别
 */

/** 获取商品小类  sdsa GET /kitchen/api/rule */
export async function smallgoodstype(data) {
  return request(`/kitchen/api/goods-type/goods-types`, {
    method: 'POST',
    data: data,
  });
}

/** 获取商品大类  sdsa GET /kitchen/api/rule */
export async function biggoodstype(data) {
  return request(`/kitchen/api/goods-type/big-goods-types`, {
    method: 'POST',
    data: data,
  });
}

/**
 * 获取设备信息
 */
 export async function getdevicetree(params) {
  return request('/kitchen/api/Device/StoreDeviceTree', {
    data: {
      ...params,
    },
  });
}
/**
 * 获取店铺列表
 */
 export async function getStoreList(params) {
  return request('/kitchen/api/Device/StoreList', {
    data: {
      ...params,
    },
  });
}

export async function testaddinteg(){
  return request('/kitchen/api/integralrule/addinteg', {

  });

}


export async function getallrule(){
  return request('/kitchen/api/integralrule/getall', {

  });

}

function GetNameStr(type) {
  var typeName = "";
  switch (type) {
    case 1:
      typeName = "priceIds";
      break;
    case 2:
      typeName = "bigIds";
      break;
    case 3:
      typeName = "smallIds";
      break;
    case 4:
      typeName = "countIds";
      break;
    case 5:
      typeName = "personsIds";
      break;
    case 6:
      typeName = "numberIds";
      break;
    default:
      break;
  }
  return typeName;
}

function GetTypeName(type) {
  var typeName = "未定义规则";
  switch (type) {
    case 1:
      typeName = "按消费金额积分规则";
      break;
    case 2:
      typeName = "按大类积分规则";
      break;
    case 3:
      typeName = "按小类积分规则";
      break;
    case 4:
      typeName = "按消费次数积分规则";
      break;
    case 5:
      typeName = "按消费人数积分规则";
      break;
    case 6:
      typeName = "按出品数量积分规则";
      break;
    default:
      break;
  }
  return typeName;
}
