优惠券-创建

接口信息

  • 接口地址: {your-site-url}/api/skill/coupon/create
  • 基础 URL: {your-site-url} 需替换为你自己的独立站 URL 地址,如 https://your-domain.com/apimanager666
  • 请求方式: POST
  • 说明: 此接口用于创建一张新的优惠券。

认证

请求头中需要携带 skill-access-token

Header
skill-access-token {your-skill-access-token} (请替换为你自己的 token)

请求参数 (JSON Body)

基本信息

字段 类型 必填 说明
title string 优惠券标题
code string 优惠券码
status int 状态。1 = 激活,2 = 关闭
is_campaign int 是否与其他活动优惠叠加使用。1 = 是,2 = 否
starts_at string 生效时间,格式 YYYY-MM-DD HH:mm:ss
ends_at string 结束时间,格式 YYYY-MM-DD HH:mm:ss。空字符串或 0 表示不限时

折扣设置

字段 类型 必填 说明
value_type int 折扣类型。1 = 固定金额(fixed_amount),2 = 百分比(percentage)
value number 折扣值。value_type=1 时为固定金额,value_type=2 时为百分比数值
usage_limit int 优惠券可被使用的总次数。0 表示无限制
usage_count_per_customer int 每个顾客使用该优惠券的最大次数。0 表示无限制

适用商品

字段 类型 必填 说明
product_selection_type int 适用商品选择类型。1 = 全部商品,2 = 指定商品,3 = 指定商品专辑(collection)
entitled_product_ids Array[Object] 适用商品列表,product_selection_type=2 时有效。每项包含 product_idvariant_idsvariant_ids 有值代表该商品下的指定变体,为空数组则代表该商品的所有变体
entitled_collection_ids Array 适用商品专辑 ID 列表,product_selection_type=3 时有效

最低使用条件

字段 类型 必填 说明
minimum_requirements_type int 最低要求类型。1 = 无限制,2 = 最低购买金额,3 = 最低购买数量
prerequisite_subtotal number/string 最低购买金额,minimum_requirements_type=2 时有效。类型为 float,订单商品小计金额必须 ≥ 此值
prerequisite_quantity int/string 最低购买数量,minimum_requirements_type=3 时有效。类型为 int,订单商品总数量必须 ≥ 此值

展示设置

字段 类型 必填 说明
product_sort int 商品排序。1 = A-Z,2 = Z-A,3 = 价格从低到高,4 = 价格从高到低,5 = 按销量从高到低,6 = 按实际销量从高到低
banner_image string Banner 图片路径(相对路径)
banner_show_type int Banner 展示类型。1 = 铺满全屏,2 = 两边留白
is_product_page_show int 是否在产品页面展示。1 = 展示,2 = 不展示
product_image_height_type string 产品图片高度。auto = 自适应,big = 大,medium = 中,small = 小

copywriting - 文案/UI配色

字段 类型 说明
copywriting.color string 配色方案名,如 blue
copywriting.timeType int 时间显示类型
copywriting.backgroundLeft string 背景色左(rgba)
copywriting.backgroundRight string 背景色右(rgba)
copywriting.fontTip string 提示文字颜色(rgba)
copywriting.timeBg string 时间背景色(rgba)
copywriting.timeFont string 时间文字颜色(rgba)
copywriting.couponBg string 优惠券背景色(rgba)
copywriting.couponFont string 优惠券文字颜色(rgba)
copywriting.couponBtLeft string 按钮左渐变色(rgba)
copywriting.couponBtRight string 按钮右渐变色(rgba)
copywriting.couponBtFont string 按钮文字颜色(rgba)
copywriting.copyColor string 复制按钮颜色(rgba)

请求示例

cURL

curl --location --request POST '{your-site-url}/api/skill/coupon/create' \
--header 'skill-access-token: {your-skill-access-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "is_campaign": 1,
    "status": 1,
    "title": "terry coupon",
    "code": "LX4ABQ14",
    "value_type": 1,
    "value": 10,
    "usage_count_per_customer": 0,
    "usage_limit": 0,
    "starts_at": "2026-06-03 20:50:03",
    "ends_at": "",
    "product_selection_type": 2,
    "entitled_product_ids": [
        {"product_id": 7042, "variant_ids": []},
        {"product_id": 7041, "variant_ids": []}
    ],
    "entitled_collection_ids": [],
    "minimum_requirements_type": 2,
    "prerequisite_subtotal": 50,
    "prerequisite_quantity": "",
    "product_sort": 1,
    "banner_image": "/product/15/image/2026/05/29/430015af6d7473355e7180b97741e443.png",
    "banner_show_type": 1,
    "is_product_page_show": 1,
    "product_image_height_type": "auto",
    "copywriting": {
        "color": "blue",
        "timeType": 1,
        "backgroundLeft": "rgba(255,72,72,100)",
        "backgroundRight": "rgba(255,13,125,100)",
        "fontTip": "rgba(255,255,255,100)",
        "timeBg": "rgba(255,243,203,100)",
        "timeFont": "rgba(0,0,0,100)",
        "couponBg": "rgba(255,248,227,100)",
        "couponFont": "rgba(233,5,73,100)",
        "couponBtLeft": "rgba(255,139,2,100)",
        "couponBtRight": "rgba(255,109,4,100)",
        "couponBtFont": "rgba(255,255,255,100)",
        "copyColor": "rgba(255,109,4,100)"
    }
}'

返回结果

code200 表示调用成功;code 不为 200 表示调用失败。

成功响应

{
    "code": 200,
    "data": {
        "shop_id": 15,
        "status": 1,
        "title": "terry coupon",
        "code": "LX4ABQ14",
        "value_type": 1,
        "value": 10,
        "product_image_height_type": "auto",
        "usage_count_per_customer": 0,
        "starts_at": "2026-06-03 20:50:03",
        "ends_at": 0,
        "product_selection_type": 2,
        "is_campaign": 1,
        "product_sort": 1,
        "banner_image": "/product/15/image/2026/05/29/430015af6d7473355e7180b97741e443.png",
        "banner_show_type": 1,
        "copywriting": { ... },
        "is_product_page_show": 1,
        "usage_limit": 0,
        "entitled_product_ids": [
            {"product_id": 7042, "variant_ids": []},
            {"product_id": 7041, "variant_ids": []}
        ],
        "entitled_collection_ids": [],
        "minimum_requirements_type": 2,
        "prerequisite_subtotal": 50,
        "prerequisite_quantity": 0,
        "created_at": "2026-06-03 20:51:44",
        "updated_at": "2026-06-03 20:51:44",
        "id": 70
    },
    "message": "success"
}

返回字段说明

字段 类型 说明
code Number 状态码,200 表示成功
message String 执行结果的文字描述
data Object 创建的优惠券完整信息,字段与请求参数对应
data.id int 新创建的优惠券 ID
data.created_at string 创建时间
data.updated_at string 更新时间

注意事项

  1. banner_image 完整图片url,或者相对路径。如果是相对路径,需要先通过 得到网站基础URL 获取 attachment_url,然后拼接得到完整 URL:attachment_url + banner_image
  2. ends_at 为空字符串时表示不限时,返回时值为 0
  3. entitled_product_idsvariant_ids 为空数组时表示该商品的全部变体适用
  4. copywriting 为前台 UI 配色配置,可根据主题自定义颜色值
Copyright © fecify.com 2025 all right reserved,powered by Gitbook该文件修订时间: 2026-06-03 21:46:53

results matching ""

    No results matching ""