HC小区接口文档

商品管理接口文档

一、添加商品接口

1. 接口名称

添加商品

2. 接口描述

用于商家添加新商品到系统中,包括商品基本信息、规格、图片等内容。

3. 接口路径

http://ip:port/app/product.saveProduct

4. 请求方法

POST

5. 请求头

参数名称 必填 类型 描述
Authorization String 用户认证token
store-id String 商户ID
user-id String 操作人ID

6. 请求参数

6.1 请求体参数

必填参数:

参数名称 必填 类型 描述
prodName String 商品名称
keyword String 商品关键词,多个用分号(;)分隔
categoryId String 商品分类ID
unitName String 商品单位
sort Integer 排序值
isPostage String 是否包邮(T/F)
coverPhoto String 商品封面图片URL
content String 商品详情描述
carouselFigurePhoto JSONArray 商品轮播图URL数组
productSpecs JSONArray 商品规格数组

可选参数:

参数名称 必填 类型 描述
shopId String 店铺ID
hktIds JSONArray 家政服务类型ID数组

6.2 商品规格参数(productSpecs数组中的对象)

参数名称 必填 类型 描述
specName String 规格名称
costPrice String 成本价
originalPrice String 原价
price String 售价
stock String 库存数量
isDefault String 是否默认规格(T/F)
deduction String 抵扣金额,默认0.00

7. 返回值

7.1 返回值结构

参数名称 类型 描述
code String 返回码(0成功)
msg String 返回信息
data Object 返回数据

8. 示例请求

{
  "prodName": "测试商品",
  "keyword": "测试;商品",
  "categoryId": "123456",
  "unitName": "件",
  "sort": 1,
  "isPostage": "T",
  "coverPhoto": "http://example.com/cover.jpg",
  "content": "商品详细描述内容",
  "carouselFigurePhoto": [
    "http://example.com/image1.jpg",
    "http://example.com/image2.jpg"
  ],
  "productSpecs": [
    {
      "specName": "规格1",
      "costPrice": "10.00",
      "originalPrice": "20.00",
      "price": "15.00",
      "stock": "100",
      "isDefault": "T",
      "deduction": "0.00"
    },
    {
      "specName": "规格2",
      "costPrice": "15.00",
      "originalPrice": "25.00",
      "price": "20.00",
      "stock": "50",
      "isDefault": "F"
    }
  ],
  "shopId": "1001",
  "hktIds": ["2001", "2002"]
}

9. 示例响应

{
  "code": "0",
  "msg": "保存成功",
  "data": null
}

10. 错误码

错误码 描述
0 成功
非0 失败,具体错误信息见msg字段

11. 业务逻辑说明

  1. 验证请求参数完整性
  2. 验证店铺是否审核通过
  3. 保存商品基本信息
  4. 处理商品关键词
  5. 保存商品图片(封面和轮播图)
  6. 保存商品规格信息
  7. 保存商品详情
  8. 如果有初始库存,生成入库单
  9. 处理家政服务类型关联(如果有)
  10. 返回操作结果

12. 数据库操作

  1. 插入商品基本信息(product表)
  2. 插入商品关键词(product_serv_keyword表)
  3. 插入商品图片关联(file_rel表)
  4. 插入商品规格(product_spec_value表)
  5. 插入商品详情(product_detail表)
  6. 插入入库单(inout_order表)
  7. 插入入库单明细(inout_order_product表)
  8. 插入家政服务类型关联(product_h5_menu表)