import { ResPage, StoreUser } from "@/api/interface/index";
import { PORT_NONE } from "@/api/config/servicePort";
import http from "@/api";
import http_store from "@/api/indexStore";
import httpApi from "@/api/indexApi";
import { uploadFormDataToOss } from "@/api/upload.js";

// 获取营业执照
export const getBusinessLicense = params => {
  return http.get(PORT_NONE + `/license/querybusinessLicenseList`, params);
};

// 获取食品经营许可证
export const getFoodBusinessLicense = params => {
  return http.get(PORT_NONE + `/license/queryFoodLicenceList`, params);
};

// 获取其他资质证明
export const getEntertainmentBusinessLicense = params => {
  return http.get(PORT_NONE + `/license/queryEntertainmentLicenseList`, params);
};

// 获取合同图片列表
export const getContractImages = params => {
  return http.get(PORT_NONE + `/license/queryContractList`, params);
};

// 获取合同变更记录
export const queryContractByStatusList = params => {
  return http.get(PORT_NONE + `/license/queryContractByStatusList`, params);
};

// 获取食品经营许可证变更记录
export const getChangeRecords = params => {
  return http.get(PORT_NONE + `/info/getOtherQualificationHistory`, params);
};

// 获取营业执照变更记录
export const getBusinessLicenseChangeRecords = params => {
  return http.get(PORT_NONE + `/license/queryBusinessLicenseByStatusList`, params);
};

// 获取其他资质证明变更记录
export const getEntertainmentChangeRecords = params => {
  return httpApi.get(`/alienStore/store/info/getOtherQualificationHistory`, params);
};
// 获取合同审核状态
export const getStoreContractStatus = params => {
  return http.get(PORT_NONE + `/license/getStoreContractStatus`, params);
};

// 获取营业执照审核状态
export const getStoreBusinessLicenseStatus = params => {
  return http.get(PORT_NONE + `/license/getStoreBusinessLicenseStatus`, params);
};

// 获取食品经营许可证审核状态
export const getStoreFoodLicenceStatus = params => {
  return http.get(PORT_NONE + `/license/getStoreFoodLicenceStatus`, params);
};

// 获取其他资质证明审核状态
export const getStoreEntertainmentLicenceStatus = params => {
  return http.get(PORT_NONE + `/license/queryStoreEntertainmentStatus`, params);
};

// 提交营业执照审核
export const submitBusinessLicenseReview = params => {
  return http.post(PORT_NONE + `/license/uploadBusinessLicense`, params);
};

// 提交食品经营许可证审核
export const submitFoodLicenseReview = params => {
  return http.post(PORT_NONE + `/license/uploadfoodLicence`, params);
};

// 提交其他资质证明审核
export const submitEntertainmentLicenseReview = params => {
  return http.post(PORT_NONE + `/license/uploadEntertainmentLicence`, params);
};

// 提交合同审核
export const submitContractReview = params => {
  return http.post(PORT_NONE + `/license/uploadRenewalContract`, params);
};

// 上传合同图片（统一走 @/api/upload.js；兼容旧逻辑 result.data[0] 为 URL）
export const uploadContractImage = async (formData: FormData, onProgress?: (progress: number) => void) => {
  void onProgress;
  const { data } = await uploadFormDataToOss(formData, "image");
  const url = data.fileUrl;
  return {
    code: 200,
    msg: "success",
    data: [url] as unknown as string[]
  };
};

// OCR 二次校验接口
export const ocrRequestUrl = params => {
  return httpApi.post(PORT_NONE + `/alienStore/ali/ocrRequestUrl`, params);
};
