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

/** 添加商品和编辑商品
 *
 * @author Seven
 * @data 2025-7-22
 * @params {
 *    productObj{},
 *    productItems:{}
 *  }
 * @see https://mall.gpxscs.cn/api/admin/shop/shop-product-base/saveProduct
 */

export function UpdateCommodityInfo(data) {
  return http({
    url: "/shop/shop-product-base/saveProduct",
    method: "post",
    baseURL: config.adminApi,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
    },
    data,
  });
}

/** 添加商品和编辑商品
 *
 * @author Seven
 * @data 2025-7-22
 * @params {
 *    product_id : 33002
      item_id : 66419
      item_unit_price :10
      item_quantity :20
 *  }
 * @see https://mall.gpxscs.cn/api/admin/shop/shop-product-item/editQuantity
 */

export function UpdateCommodityPriceAndQuantity(params) {
  return http({
    url: "/shop/shop-product-item/editQuantity",
    method: "post",
    baseURL: config.adminApi,
    data: params,
  });
}

/** 获取分类详情
 *
 * @author Seven
 * @data 2025-7-22
 * @params { category_id }
 * @see https://mall.gpxscs.cn/api/admin/shop/shop-base-product-category/get
 */

export function GetClassifyInfo(params) {
  return http({
    url: "/shop/shop-base-product-category/get",
    method: "get",
    baseURL: config.adminApi,
    params,
  });
}

/** 获取商品base详情
 *
 * @author Seven
 * @data 2025-7-22
 * @params { product_id : number }
 * @see https://mall.gpxscs.cn/api/admin/shop/shop-product-info/productInfoByPid
 */

export function GetCommodityBaseInfo(params) {
  return http({
    url: "/shop/shop-product-info/productInfoByPid",
    method: "get",
    baseURL: config.adminApi,
    params,
  });
}

/** 获取商品规格 库存 和 价格
 *
 * @author Seven
 * @data 2025-7-6
 * @param { product_id }
 * @returns {  }
 * @see https://mall.gpxscs.cn/api/admin/shop/shop-product-item/items?product_id=23591&source_lang=zh_CN
 */

export function GetCommoditSpecification(params) {
  return http({
    url: "/shop/shop-product-item/items",
    method: "get",
    params,
    baseURL: config.adminApi,
  });
}

/** 获取商品规格 品牌 信息
 *
 * @author Seven
 * @data 2025-7-22
 * @param { spec_id }
 * @returns {  }
 * @see https://mall.gpxscs.cn/api/admin/shop/shop-base-product-type/get
 */

export function GetCommoditSpecificationBaseInfo(params) {
  return http({
    url: "/shop/shop-base-product-type/get",
    method: "get",
    params,
    baseURL: config.adminApi,
  });
}

/** 添加商品规格
 *
 * @author Seven
 * @data 2025-7-22
 * @param { spec_id : number , spec_item_name : 10 }
 * @returns {   }
 * @see https://mall.gpxscs.cn/api/admin/shop/shop-product-spec-item/edit
 */

export function UpdateCommoditSpecification(params) {
  return http({
    url: "/shop/shop-product-spec-item/edit",
    method: "post",
    params,
    baseURL: config.adminApi,
  });
}

/** 删除商品规格
 *
 * @author Seven
 * @data 2025-7-22
 * @param { spec_item_id : number }
 * @returns {   }
 * @see https://mall.gpxscs.cn/api/admin/shop/shop-product-spec-item/delete
 */

export function DelectCommoditSpecification(params) {
  return http({
    url: "/shop/shop-product-spec-item/delete",
    method: "post",
    params,
    baseURL: config.adminApi,
  });
}

/** 获取当前分类规格列表
 *
 * @author Seven
 * @data 2025-7-22
 * @param { spec_item_id : number }
 * @returns {   }
 * @see https://mall.gpxscs.cn/api/admin/shop/shop-product-spec-item/specItems
 */

export function GetClassifySpecificationList(params) {
  return http({
    url: "/shop/shop-product-spec-item/specItems",
    method: "get",
    params,
    baseURL: config.adminApi,
  });
}
