优惠券-更新
优惠券 - 更新优惠券
接口信息
- 接口地址:
{your-site-url}/api/skill/coupon/update
- 基础 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)
基本信息
| 字段 |
类型 |
必填 |
说明 |
id |
int |
是 |
优惠券 ID |
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。空字符串表示不限时 |
折扣设置
| 字段 |
类型 |
必填 |
说明 |
value_type |
int |
是 |
折扣类型。1 = 固定金额,2 = 百分比 |
value |
number/string |
是 |
折扣值。value_type=1 时为固定金额,value_type=2 时为百分比数值 |
usage_limit |
int |
是 |
优惠券可被使用的总次数。0 表示无限制 |
usage_count_per_customer |
int |
是 |
每个顾客使用该优惠券的最大次数。0 表示无限制 |
适用商品
| 字段 |
类型 |
必填 |
说明 |
product_selection_type |
int |
是 |
适用商品选择类型。1 = 全部商品,2 = 指定商品,3 = 指定商品专辑 |
entitled_product_ids |
Array[Object] |
否 |
适用商品列表,product_selection_type=2 时有效。每项包含 product_id 和 variant_ids。variant_ids 有值代表该商品下的指定变体,为空数组则代表该商品的所有变体 |
entitled_collection_ids |
Array |
否 |
适用商品专辑 ID 列表,product_selection_type=3 时有效 |
最低使用条件
| 字段 |
类型 |
必填 |
说明 |
minimum_requirements_type |
int |
是 |
最低要求类型。1 = 无限制,2 = 最低购买金额,3 = 最低购买数量 |
prerequisite_subtotal |
float/string |
否 |
最低购买金额,类型为 float,minimum_requirements_type=2 时有效 |
prerequisite_quantity |
int |
否 |
最低购买数量,类型为 int,minimum_requirements_type=3 时有效 |
展示设置
| 字段 |
类型 |
必填 |
说明 |
product_sort |
int |
是 |
商品排序。1 = A-Z,2 = Z-A,3 = 价格从低到高,4 = 价格从高到低,5 = 按销量从高到低,6 = 按实际销量从高到低 |
banner_image |
string |
否 |
Banner 图片路径(完整图片url,或者相对路径)。相对路径的完整 URL 需通过 得到网站基础URL 获取 attachment_url 后拼接 |
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 |
配色方案名 |
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/update' \
--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.00",
"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.00",
"prerequisite_quantity": 0,
"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": { ... },
"id": "69"
}'
返回结果
code 为 200 表示调用成功;code 不为 200 表示调用失败。
成功响应
{
"code": 200,
"data": {
"id": 69,
"shop_id": 15,
"status": 1,
"title": "terry coupon",
"code": "LX4ABQ14",
"is_campaign": 1,
"usage_count": 0,
"value_type": 1,
"value": "10.00",
"usage_count_per_customer": 0,
"usage_limit": 0,
"starts_at": "2026-06-03 20:50:03",
"ends_at": 0,
"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.00",
"prerequisite_quantity": 0,
"product_sort": 1,
"banner_image": "/product/15/image/2026/05/29/430015af6d7473355e7180b97741e443.png",
"banner_show_type": 1,
"copywriting": { ... },
"is_product_page_show": 1,
"product_image_height_type": "auto",
"created_at": "2026-06-03 20:51:33",
"updated_at": "2026-06-03 20:51:33"
},
"message": "success"
}
返回字段说明
| 字段 |
类型 |
说明 |
code |
Number |
状态码,200 表示成功 |
message |
String |
执行结果的文字描述 |
data |
Object |
更新后的优惠券完整信息,字段与请求参数对应 |
data.created_at |
string |
创建时间 |
data.updated_at |
string |
最后更新时间 |
操作流程
此为全量更新接口,建议按以下步骤操作:
- 调用 优惠券-详细 获取当前优惠券完整数据
- 在获取到的数据基础上修改需要变更的字段
- 将完整数据提交到本接口
注意事项
- 此接口为全量更新,需提交优惠券的全部字段,未传入的字段可能被清空
id 为必填,指定要更新的优惠券
- 字段说明同 优惠券-创建