import http from "../utils/http";
import config from "../config/config";

/**
 * 获取省市区
 * @author Seven
 * @data 2025-2-29
 * @returns { list [] }
 * @see https://mall.gpxscs.cn/mobile/shop/shop-base-district/getAppDistrict
 */

export function GetAppDistrict() {
  return http({
    url: "/shop/shop-base-district/getAppDistrict",
    method: "get",
  });
}

/**
 * 店铺主营分类（类目）
 * @author Seven
 * @data 2025-3-5
 * @returns { list [] }
 * @see https://mall.gpxscs.cn/api/admin/shop/shop-base-store-category/categoryTree
 */

export function GetMeritoCategory() {
  return http({
    url: "/shop/shop-base-product-category/listCategory",
    method: "get",
  });
}

/**
 * 店铺主营分类（类目）二级分类
 * @author Seven
 * @data 2025-3-5
 * @param { category_parent_id }
 * @returns { list [] }
 * @see https://mall.gpxscs.cn/mobile/shop/shop-base-product-category/treeCategory
 */

export function GetTreeCategory() {
  return http({
    url: "/shop/shop-base-product-category/treeCategory",
    method: "get",
  });
}

/**
 * 获取百度地图输入点提示词
 * @author Seven
 * @data 2025-3-5
 * @param {
 *    query: value,              //关键词
 *    region: this.citys[0],     //城市名
 *    city_limit: true,          //指定的区域的返回结果
 *    ret_coordtype: "gcj02ll",  //坐标类型 1（WGS84ll即GPS经纬度）2（GCJ02ll即国测局经纬度坐标） 3（BD09ll即百度经纬度坐标） 4（BD09mc即百度米制坐标）
 *}
 * @returns { query,region }
 * @see https://mall.gpxscs.cn/mobile/shop/merch/baidu/place/v2/suggestion
 */

export function GetBaiduSuggestion(params = {}) {
  params.isFilter = true;
  return new Promise((resolve, reject) => {
    http({
      url: "/shop/merch/baidu/place/v2/suggestion",
      method: "get",
      params,
    })
      .then((res) => {
        resolve(res);
      })
      .catch((e) => reject(console.warn(e)));
  });
}

/**
 * 获取入驻审核状态
 * @author Seven
 * @data 2025-3-5
 * @param { "mobile": "13128997057" }
 * @returns { approval_invalid_col:[] ,approval_status":4, approval_remark:'', id:'' }
 * approval_invalid_col 重新审核 映射需要用到 由B段admin 传过来
 * approval_status 1-已通过；2-未通过；3-待审核；4 -未申请 ；5 提交到拉卡拉 ； 21 拉卡拉审核失败
 * approval_remark 驳回备注
 * @see https://mall.gpxscs.cn/mobile/shop/merch/fresh/approval/status
 */

export function GetAuditStatus(params = {}) {
  return new Promise((resolve, reject) => {
    http({
      url: "/shop/merch/fresh/approval/status",
      method: "post",
      data: params,
    })
      .then((res) => {
        if (res && res.status == 200) {
          uni.setStorageSync("approvalStatus", res.data.approval_status);
        }
        resolve(res);
      })
      .catch((e) => reject(console.warn(e)));
  });
}

/**
 * 获取申请信息详情
 * @author Seven
 * @data 2025-3-4
 * @param {  }
 * @returns { mobile:13199998888  }
 * @see https://mall.gpxscs.cn/mobile/shop/merch/detail
 */

export function GetAuditInfo(params) {
  return new Promise((resolve, reject) => {
    http({
      url: "/shop/merch/detail",
      method: "post",
      data: params,
    })
      .then((res) => {
        if (res && res.data && res.status == 200) {
          uni.setStorageSync("approvalStatus", res.data.approval_status);
        }
        resolve(res);
      })
      .catch((e) => reject(console.warn(e)));
  });
}

/**
 * 获取银行列表
 * @author Seven
 * @data 2025-3-4
 * @returns {  }
 * @see https://mall.gpxscs.cn/mobile/shop/global/banks/list
 */

export function GetBankList() {
  return http({
    url: "/shop/global/banks/list",
    method: "post",
  });
}

/**
 * 提交审核
 * @author Seven
 * @data 2025-3-4
 * @param  {
 *  "login_mobile": "13128997057", // 商家注册手机号 必填项
 *  "store_name": "家乐福超市", // 超市名称 必填项
 *  "sales_info": "商家经营范围内容" //从 ocr 中获取 可选项
 *  "contact_name": "张三", // 商家联系人，可与法人同人 必填项
 *  "biz_category": 12, // 超市一级分类，影响分账比例，必填项
 *  "biz_second_category": 12001, // 超市二级分类，可选项
 *  "store_longitude": "112.987876", // 店铺经纬度，必填项
 *  "store_latitude": "21.2323", // 店铺经纬度，必填项
 *  "province_id": "0001", // 省份code，必填项
 *  "city_id": "000110001", // 城市code，必填项
 *  "county_id": "0001100010000123", // 县乡镇区code，必填项
 *  "store_area": "广东省/深圳市/福田区" // 店铺区域，必填项
 *  "store_address": "广东省深圳市福田区深南大道11023号", // 带省市区店铺的详细地址，必填项
 *  "store_logo": "https://163.com/abc/abc.png", // 店铺LOGO，可选项
 *  "front_facade_image": "https://163.com/abc/abc.png", // 店铺门店照片，必填项
 *  "environment_image": "https://163.com/abc/abc.png", // 店铺室内环境照片，必填项
 *  "entity_type": 1, // 入驻主体类型：1-企业；2-个人； 必填项
 *  "biz_license_image": "https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/mediad236132.png",营业执照图片，企业必填项
 *  "biz_license_number": "91450881MA5P8MWX69", // 营业执照编号，ocr 中获取，企业必填项
 *  "biz_license_company": "桂平厚德贸易有限公司", // 企业名，ocr 中获取，企业必填项
 *  "legal_person_id_images": "https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/mediad940a32.png", // 法人身份证正面，企业必填
 *  "legal_person_id_images2": "https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/medi5a32.png",// 法人身份证正面，企业必填
 *  "legal_person_name": "张三", // 法人真实姓名，企业必填
 *  "legal_person_mobile": "13128997057",// 法人手机号，，企业必填
 *  "legal_person_id_number": "371321199004209551",// 法人身份证号码，ocr 中获取，企业必填
 *  "legal_person_id_addr": "广东省深圳市福田区上梅林恒大居委会10023号",// 法人身份证详细地址，ocr 中获取，企业必填
 *  "legal_person_id_period_begin": "2000-01-12",// 法人身份证开始有效日期，ocr 中获取，，企业必填
 *  "legal_person_id_period_end": "9999-12-31",// 法人身份证截止有效日期，ocr 中获取，长期填：9999-12-31，企业必填
 *  "legal_person_mobile": "13128997057",// 法人手机号，企业必填
 *  "individual_id_images": "https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/mediad9225a32.png", // 个人身份证正面，个人小微必填
 *  "individual_id_images2": "https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/mediad245a32.png",// 个人身份证正面，个人小微必填
 *  "individual_id_name": "张三", // 真实姓名，ocr 中获取，个人小微必填
 *  "individual_id_number": "371321199004209551",// 个人身份证号码，ocr 中获取，个人小微必填
 *  "individual_id_addr": "广东省深圳市福田区上梅林恒大居委会10023号",// 个人身份证详细地址，ocr 中获取，个人小微必填
 *  "individual_id_period_begin": "2000-01-12",// 个人身份证开始有效日期，ocr 中获取，个人小微必填
 *  "individual_id_period_end": "9999-12-31",// 个人身份证截止有效日期，ocr 中获取，长期填：9999-12-31，个人小微必填
 *  "other_license_list":"[{'type':1,'number':'91450881MA5P8MWX69','img':'https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/1.png'}]", //营业执照以外的许可证信息列表JSON格式 [{'type':1,'number':'91450881MA5P8MWX69','img':'https://media-mall-prod-1259811287.cos.ap-guangzhou.myqcloud.com/1.png'}]，type:1-许可证；2-特许证件，3-其他证件
 *  "bank_district": "11000/11100/11101", //结算账号省市区code 省code/市code/区code，必填项
 *  "bank_area": "广西壮族自治区/贵港市/桂平市", //结算账号省市区 省/市/区，必填项
 *  "bank_name": "桂平市农业银行西山支行", // 银行名称
 *  "openning_bank_code": "102641000266", //结算账户⾏号，必填项
 *  "clearing_bank_code": "102641000266", //结算账户清算⾏号，必填项
 *  "account_type": "57", // 结算账号类型：57-对公 58-对私，必填项
 *  "account_number": "6217007200087742238", //结算银行卡号，必填项
 *  "account_holder_name": "桂平厚德贸易有限公司" //结算银行账户名，必填项
 }
 * @returns {  }
 * @see https://mall.gpxscs.cn/mobile/shop/merch/apply
 */

export function GetMerchApply(params) {
  return http({
    url: "/shop/merch/apply",
    method: "post",
    data: params,
  });
}

/**
 * 重新提交审核
 * @author Seven
 * @data 2025-3-4
 * @param { auditId , ...form字段 }
 * @see https://mall.gpxscs.cn/mobile/shop/merch/re-apply
 */

export function GetRestartMerchApply(params) {
  return http({
    url: "/shop/merch/re-apply",
    method: "post",
    data: params,
  });
}

/**
 * 获取店铺分类（类目）
 * @author Seven
 * @data 2025-3-4
 * @returns {  }
 * @see https://mall.gpxscs.cn/api/mobile/shop/shop-base-store-category/list
 */

export function GetBizCategoryList(params) {
  return http({
    url: "/shop/shop-base-store-category/list",
    method: "post",
    data: params,
    baseURL: config.apiMobile,
  });
}

/**
 * 搜索银行（支行）分页列表
 * @author Seven
 * @data 2025-5-13
 * @returns {  }
 * @see https://mall.gpxscs.cn/mobile/shop/lakala/tk/bank/search
 */

export function branchBankSearchApi(params) {
  return http({
    url: "/shop/lakala/tk/bank/search",
    method: "post",
    data: params,
  });
}

/** 检查店铺名是否可以使用?
 *
 * @author Seven
 * @data 2025-5-13
 * @returns { storeName }
 * @see https://mall.gpxscs.cn/mobile/shop/lakala/tk/bank/search
 */

export function CheckShopName(params) {
  return http({
    url: "/shop/store/check-store-name-exists",
    method: "post",
    data: params,
    baseURL: config.apiMobile,
  });
}
