商品目录
默认(主)店铺的商品目录;除 shop/save 外均为只读接口。价格优先取共享规则引擎/变体结果,缺失时回退 sale_price(原始价格列仅作回退)。合作商自有店铺的商品挂单与维护见 店铺与购物车草稿。
认证与通用约定
所有 /channel/api/v1/* 端点由 ChannelPartnerAuthMiddleware 统一鉴权:可携带 request-token,或携带 Authorization: Bearer <token>(用户会话令牌或开发者密令)。
| 请求头 | 必填 | 说明 |
|---|---|---|
request-token | 二选一 | 渠道伙伴应用令牌 |
Authorization | 二选一 | Bearer <token>,用户会话令牌或开发者密令 |
Content-Type | 是 | application/json |
所需能力: 无。product/* 路径不在能力映射表中,仅需有效的渠道伙伴身份(见 app/channel/middleware/ChannelPartnerAuthMiddleware.php:39-46)。
通用错误码:
| code | 含义 |
|---|---|
| 909 | 令牌缺失/无效,或不属于渠道伙伴 |
| 400 | 参数或业务校验失败 |
| 404 | 资源不存在或不在当前合作商范围 |
| 500 | 服务端异常 |
分页约定:page 从 1 开始,pageSize 默认 20、最大 100(min(100, max(1, pageSize)))。
商品列表
/channel/api/v1/product/listAuth: request-token (channel_partner)
返回默认(主)店铺的分页商品列表。只返回 in_stock = 1 的商品及其变体,按变体 ID 倒序。每一行是一个变体:id / variant_id 为变体 ID,item_id 为商品 ID。
所需能力: 无
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
page | integer | 否 | 页码,从 1 开始。默认 1 |
pageSize | integer | 否 | 每页条数,最大 100。默认 20 |
keyword | string | 否 | 模糊搜索:变体 shop_sku / sku / ean,商品 title / mpn |
响应
{
"code": 200,
"msg": "success",
"data": {
"data": [
{
"id": 4001,
"variant_id": 4001,
"item_id": 501,
"sku": "E2C-BAT-100",
"name": "10 kWh Battery Module",
"mpn": "BAT-10K",
"item_type": "Battery",
"catalog": "12",
"price": 1299.00,
"cover": "https://cdn.example.com/items/501/1.jpg",
"variant_options": [{ "key": "capacity", "value": "10kWh" }],
"weight": 48.5,
"weight_unit": "kg",
"length": 60,
"width": 40,
"height": 25,
"length_unit": "cm",
"stock_status": "in_stock",
"vip_price_rule": "Partner Tier A"
}
],
"total": 1,
"per_page": 20,
"current_page": 1
}
}| 字段 | 类型 | 说明 |
|---|---|---|
data[].id / data[].variant_id | integer | 变体 ID(两者相同) |
data[].item_id | integer | 商品(t_item)ID |
data[].sku | string | 变体 sku,缺失时回退 shop_sku |
data[].name | string | 商品标题 |
data[].mpn | string | 商品 MPN |
data[].item_type | string | 商品类型名称 |
data[].catalog | string | 目录 ID(字符串形式) |
data[].price | number | 规则引擎最终价,保留 2 位小数;规则引擎未返回该变体时回退变体 sale_price |
data[].cover | string | 商品首张图片 URL |
data[].variant_options | array | 变体 standard 解析结果,[{key, value}],排除 id |
data[].weight / weight_unit | number / string | 变体重量与单位 |
data[].length / width / height / length_unit | number / string | 变体尺寸与单位 |
data[].stock_status | string | 固定为 in_stock(查询已过滤 in_stock = 1,不会返回 out_of_stock) |
data[].vip_price_rule | string | 命中的规则名称,多个以 + 连接;未命中为空串 |
total | integer | 当前页返回条数,不是匹配总数(实现现状,见 Product.php:183) |
per_page | integer | 请求的 pageSize |
current_page | integer | 请求的 page |
错误码
| code | 含义 |
|---|---|
| 909 | 令牌缺失/无效,或不属于渠道伙伴 |
| 500 | 服务端异常 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/product/list' \
-H 'request-token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"page": 1,
"pageSize": 20,
"keyword": "battery"
}'行政区域
/channel/api/v1/product/regionsAuth: request-token (channel_partner)
国家/省/市三级联动的行政区域查询,数据来自网关行政区划接口。
所需能力: 无
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
type | string | 否 | country(默认)/ state / province(等同 state)/ city |
parent | string | 条件 | 父级 code,通常用于省/市;只要非空就会透传给行政区划接口,对所有 type 均不保证忽略 |
响应
{
"code": 200,
"msg": "success",
"data": [
{ "id": 81, "name": "Germany", "code": "DE" }
]
}| 字段 | 类型 | 说明 |
|---|---|---|
id | integer | 行政区划 ID |
name | string | 名称 |
code | string | 行政区划编码 |
错误码
| code | 含义 |
|---|---|
| 909 | 令牌缺失/无效,或不属于渠道伙伴 |
| 400 | 行政区划接口调用失败(failed to fetch regions) |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/product/regions' \
-H 'request-token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"type": "country"
}'国家列表
/channel/api/v1/product/countriesAuth: request-token (channel_partner)
返回启用(state = 1)的国家列表,供地址表单下拉选择,按名称升序。
所需能力: 无
请求体
无。
响应
{
"code": 200,
"msg": "success",
"data": [
{
"id": 81,
"name": "Germany",
"iso_code": "DE",
"country_code": "DE"
}
]
}| 字段 | 类型 | 说明 |
|---|---|---|
id | integer | 国家记录 ID |
name | string | 国家名称 |
iso_code | string | 2 位 ISO 代码(code 列) |
country_code | string | 国家代码,缺失时回退 iso_code |
错误码
| code | 含义 |
|---|---|
| 909 | 令牌缺失/无效,或不属于渠道伙伴 |
| 500 | 服务端异常 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/product/countries' \
-H 'request-token: YOUR_TOKEN' \
-H 'Content-Type: application/json'可用配送方式
/channel/api/v1/product/delivery-listAuth: request-token (channel_partner)
按收货地址与购物车商品计算可用配送方式。结果按 delivery_standard 聚合,同一标准取最高运费,对外只暴露配送标准,不暴露承运商细节。
所需能力: 无
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
cart_list | array | 是 | 购物车明细;为空时直接返回空列表 |
cart_list[].sku_id | integer | 是 | 变体 ID |
cart_list[].quantity | integer | 否 | 数量,默认 1 |
cart_list[].weight / weight_unit | number / string | 否 | 重量与单位,默认 0 / kg |
cart_list[].length / width / height / length_unit | number / string | 否 | 尺寸与单位,默认 0 / cm |
shipping_address | object | string | 是 | 收货地址;可为 JSON 字符串 |
shipping_address.country_code | string | 是 | 2 位国家代码,用于匹配配送区域 |
shipping_address.province | string | 否 | 省/州 |
shipping_address.city | string | 否 | 城市 |
shipping_address.suburbs | string | 否 | 区/街道,缺失时回退 address2 |
shipping_address.postcode | string | 否 | 邮编,缺失时回退 zip_code |
warehouse_id | integer | 否 | 指定仓库;<= 0 时使用系统默认仓库 |
说明:仅填国家、未填省市时,后端用国家代码兜底填充 province / city,以便匹配配送区域。cart_list 为空时返回 200、msg = cart_list is empty、delivery_list = [];shipping_address 为空时返回 400(shipping_address is required)。
响应
{
"code": 200,
"msg": "success",
"data": {
"delivery_list": [
{
"id": "EXW",
"name": "EXW",
"brief": "Ex Works",
"description": "Pickup at the e2c warehouse",
"shipping_fee": 0
}
]
}
}| 字段 | 类型 | 说明 |
|---|---|---|
delivery_list[].id | string | 配送标准名称(实现现状:与 name 相同,不是数字 ID) |
delivery_list[].name | string | 配送标准名称 |
delivery_list[].brief | string | 简称 |
delivery_list[].description | string | 描述 |
delivery_list[].shipping_fee | number | 运费(scale_freight_money + 附加费),保留 2 位小数;同标准取最高值 |
错误码
| code | 含义 |
|---|---|
| 909 | 令牌缺失/无效,或不属于渠道伙伴 |
| 400 | shipping_address 缺失(shipping_address is required) |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/product/delivery-list' \
-H 'request-token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"cart_list": [
{
"sku_id": 4001,
"quantity": 1,
"weight": 48.5,
"weight_unit": "kg",
"length": 60,
"width": 40,
"height": 25,
"length_unit": "cm"
}
],
"shipping_address": {
"country_code": "DE",
"province": "Hamburg",
"city": "Hamburg",
"postcode": "20457"
}
}'税额预览
/channel/api/v1/product/calculate-taxAuth: request-token (channel_partner)
根据收货地址与购物车预览税额。地址可传已有 address_id,也可内联地址字段;内联地址会先尝试创建/查找地址,失败时用原始数据兜底。
所需能力: 无
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
cart_list | array | 是 | 购物车明细;为空时返回 taxAmount = 0 |
cart_list[].sku_id | integer | 是 | 变体 ID |
cart_list[].price | number | 是 | 单价 |
cart_list[].quantity | integer | 否 | 数量,默认 1 |
shipping_address | object | string | 是 | 收货地址;可为 JSON 字符串 |
shipping_address.address_id | integer | 否 | 已有地址 ID,优先使用 |
shipping_address.full_name | string | 否 | 收件人 |
shipping_address.country_code | string | 否 | 2 位国家代码 |
shipping_address.province / city | string | 否 | 省/市 |
shipping_address.address1 / address2 | string | 否 | 地址行 |
shipping_address.postcode | string | 否 | 邮编 |
shipping_address.tel / email / company | string | 否 | 电话 / 邮箱 / 公司 |
响应
{
"code": 200,
"msg": "success",
"data": {
"taxAmount": 246.81,
"taxList": [
{ "sku_id": 4001, "tax_amount": 246.81, "tax_rate": 19 }
]
}
}| 字段 | 类型 | 说明 |
|---|---|---|
taxAmount | number | 税额合计,保留 2 位小数 |
taxList[].sku_id | integer | 变体 ID |
taxList[].tax_amount | number | 该行税额 |
taxList[].tax_rate | number | 税率(百分数) |
错误码
| code | 含义 |
|---|---|
| 909 | 令牌缺失/无效,或不属于渠道伙伴 |
说明:cart_list 或 shipping_address 为空时返回 200 且 msg = empty input;getBossTax 抛出的异常会被捕获并返回 200、taxAmount = 0、msg = tax calculation failed: ...(不抛业务错误码);除此之外未被捕获的异常返回 500。
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/product/calculate-tax' \
-H 'request-token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"cart_list": [
{
"sku_id": 4001,
"price": 1299,
"quantity": 1
}
],
"shipping_address": {
"full_name": "Anna Schmidt",
"country_code": "DE",
"province": "Hamburg",
"city": "Hamburg",
"address1": "Hafenstrasse 1",
"postcode": "20457"
}
}'商品详情
/channel/api/v1/product/detailAuth: request-token (channel_partner)
返回默认(主)店铺单个商品的详情。id 为商品(t_item)ID;价格取该商品第一个变体(ID 升序)的规则引擎结果。
所需能力: 无
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | integer | 是 | 商品(t_item)ID |
响应
{
"code": 200,
"msg": "success",
"data": {
"id": 501,
"sku": "E2C-BAT-100",
"name": "10 kWh Battery Module",
"mpn": "BAT-10K",
"item_type": "Battery",
"catalog": "12",
"attribute": { "capacity": "10kWh" },
"price": 1299.00,
"stock_status": "in_stock",
"vip_price_rule": "Partner Tier A",
"cover": "https://cdn.example.com/items/501/1.jpg",
"description": "Modular LFP battery module",
"sale_price": 1299.00,
"weight": 48.5,
"weight_unit": "kg",
"images": { "id": ["https://cdn.example.com/items/501/1.jpg"] },
"primary_image_key": "id",
"variant": {
"shop_sku": "E2C-BAT-100",
"standard": { "capacity": "10kWh" },
"sale_price": 1299.00,
"weight": 48.5,
"weight_unit": "kg"
}
}
}| 字段 | 类型 | 说明 |
|---|---|---|
id | integer | 商品 ID |
sku | string | 商品 shop_sku |
name / description | string | 标题 / 描述 |
mpn / item_type / catalog | string | MPN / 类型名称 / 目录 ID |
attribute | object | null | 商品属性 JSON |
price / sale_price | number | null | 规则引擎最终价;无变体或规则引擎无结果时为 null(未被捕获的异常返回 500) |
stock_status | string | in_stock / out_of_stock |
vip_price_rule | string | 命中规则名称,未命中为空串 |
cover | string | 首张图片 URL |
weight / weight_unit | number / string | 变体重量优先,其次商品重量;单位缺失回退 kg |
images | object | 归一化的图片映射 {optionValue: [url, ...]};扁平数组包装在 id 键下 |
primary_image_key | string | 主图键,缺失时回退 id |
variant.shop_sku | string | 变体 shop_sku,缺失时回退商品 shop_sku |
variant.standard | object | 变体规格,缺失时回退 {"id": shop_sku} |
variant.sale_price / weight / weight_unit | number / string | 与顶层快照一致 |
错误码
| code | 含义 |
|---|---|
| 909 | 令牌缺失/无效,或不属于渠道伙伴 |
| 400 | id 缺失或非正(id is required) |
| 404 | 商品不存在、不属于主店铺或已下架(product not found) |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/product/detail' \
-H 'request-token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"id": 501
}'保存店铺商品
/channel/api/v1/product/shop/saveAuth: request-token (channel_partner)
合作商编辑自有店铺的商品。仅允许更新 shop_id 已绑定到当前合作商、且不是主店铺的商品行;主店铺是系统主目录,任何情况下都不可通过此接口修改。
所需能力: 无
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | integer | 是 | 商品(t_item)ID |
data | object | 是 | 待更新字段,仅下列字段生效 |
data.title | string | 否 | 标题 |
data.description | string | 否 | 描述 |
data.images | object | array | 否 | 图片映射 |
data.weight / weight_unit | number / string | 否 | 重量与单位 |
data.length / width / height / length_unit | number / string | 否 | 尺寸与单位 |
data.mpn / ean | string | 否 | MPN / EAN |
data.highlights | string | array | 否 | 卖点 |
data.video | string | 否 | 视频地址 |
说明:价格、成本等平台字段不可编辑;data 中非白名单字段会被静默忽略;白名单字段全部缺失时返回 400。
响应
{
"code": 200,
"msg": "success",
"data": null
}错误码
| code | 含义 |
|---|---|
| 909 | 令牌缺失/无效,或不属于渠道伙伴 |
| 400 | id / data 缺失(id and data are required),或没有可编辑字段(no editable field provided) |
| 404 | 商品不存在、不在本合作商店铺范围,或属于主店铺(product not found or not in your shop scope) |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/product/shop/save' \
-H 'request-token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"id": 1501,
"data": {
"title": "10 kWh Battery Module (Partner)",
"weight": 49,
"weight_unit": "kg"
}
}'商品图片打包
/channel/api/v1/product/images/zipAuth: request-token (channel_partner)
把主店铺商品的图片打包为 zip。仅主店铺且 in_stock = 1 的商品在范围内(与商品列表一致)。打包结果上传为 24 小时有效的临时对象并返回 URL;上传失败时直接以 application/zip 流式返回文件。
所需能力: 无
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
item_ids | array | 是 | 商品(t_item)ID 数组;去重后 1–50 个,非数字或非正值忽略 |
说明:单个包的总下载预算为 200MB;重复 URL 只打包一次;压缩包内文件名为 {shop_sku}/{optionKey}_{序号}.{ext},无 shop_sku 时目录回退 item-{id}。无法打包的商品不会让整个请求失败,而是记入 skipped[]。
响应
{
"code": 200,
"msg": "images zip succeed",
"data": {
"url": "https://cdn.example.com/tmp/product-image-zip/20261111/abc.zip",
"file_count": 12,
"skipped": [
{ "item_id": 502, "reason": "product has no image to download" }
]
}
}| 字段 | 类型 | 说明 |
|---|---|---|
url | string | 临时 zip 下载地址,24 小时有效 |
file_count | integer | 成功打包的图片数 |
skipped[].item_id | integer | 未打包的商品 ID |
skipped[].reason | string | 跳过原因:product not found in the master catalog / product has no image to download / image pack size limit reached / image download failed |
错误码
| code | 含义 |
|---|---|
| 909 | 令牌缺失/无效,或不属于渠道伙伴 |
| 400 | item_ids 为空或超过 50 个(item_ids must be an array of at most 50 unique ids),或临时目录/zip 创建失败,或清理后 zip 丢失(ZIP file lost after cleanup) |
| 404 | 范围内商品均无可下载图片(no attachable product images found / no product image could be downloaded) |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/product/images/zip' \
-H 'request-token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"item_ids": [
501,
502
]
}'