@optima-chat/commerce-cli 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/commerce-i18n/SKILL.md +256 -0
- package/.claude/skills/commerce-inventory/SKILL.md +164 -0
- package/.claude/skills/commerce-order/SKILL.md +192 -0
- package/.claude/skills/commerce-product/SKILL.md +164 -0
- package/.claude/skills/commerce-storefront/SKILL.md +198 -0
- package/README.md +15 -4
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +123 -30
- package/dist/commands/init.js.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/.claude/CLAUDE.md +0 -101
- package/.claude/skills/commerce-cli/SKILL.md +0 -177
- package/dist/commands/cleanup.d.ts +0 -3
- package/dist/commands/cleanup.d.ts.map +0 -1
- package/dist/commands/cleanup.js +0 -100
- package/dist/commands/cleanup.js.map +0 -1
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: commerce-i18n
|
|
3
|
+
description: Internationalization and translation management. Add multilingual translations for products, variants, collections, merchant info, homepage sections. Use when user needs to translate content, manage multiple languages, or configure i18n settings.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Commerce CLI - Internationalization
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
国际化模块,用于管理商品、变体、集合、商户和首页的多语言翻译。
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
|
|
14
|
+
### 自然语言映射
|
|
15
|
+
|
|
16
|
+
当用户说:
|
|
17
|
+
- "给商品添加中文翻译" → `commerce i18n product create --product-id XX --lang zh-CN`
|
|
18
|
+
- "翻译商品变体" → `commerce i18n variant create --variant-id XX --lang YY`
|
|
19
|
+
- "翻译集合信息" → `commerce i18n collection create --collection-id XX --lang YY`
|
|
20
|
+
- "设置商户多语言信息" → `commerce i18n merchant create --lang XX`
|
|
21
|
+
- "翻译首页区块" → `commerce i18n homepage set --section-id XX --lang YY`
|
|
22
|
+
|
|
23
|
+
### 核心功能
|
|
24
|
+
|
|
25
|
+
**商品翻译**:
|
|
26
|
+
- `commerce i18n product create` - 创建商品翻译
|
|
27
|
+
- `commerce i18n product list` - 查看商品翻译列表
|
|
28
|
+
- `commerce i18n product get` - 查看单个翻译
|
|
29
|
+
- `commerce i18n product update` - 更新翻译
|
|
30
|
+
- `commerce i18n product delete` - 删除翻译
|
|
31
|
+
|
|
32
|
+
**变体翻译**:
|
|
33
|
+
- `commerce i18n variant create` - 创建变体翻译
|
|
34
|
+
- `commerce i18n variant list` - 查看变体翻译
|
|
35
|
+
- `commerce i18n variant update` - 更新变体翻译
|
|
36
|
+
- `commerce i18n variant delete` - 删除变体翻译
|
|
37
|
+
|
|
38
|
+
**集合翻译**:
|
|
39
|
+
- `commerce i18n collection create` - 创建集合翻译
|
|
40
|
+
- `commerce i18n collection list` - 查看集合翻译
|
|
41
|
+
- `commerce i18n collection update` - 更新集合翻译
|
|
42
|
+
- `commerce i18n collection delete` - 删除集合翻译
|
|
43
|
+
|
|
44
|
+
**商户翻译**:
|
|
45
|
+
- `commerce i18n merchant create` - 创建商户翻译
|
|
46
|
+
- `commerce i18n merchant list` - 查看商户翻译
|
|
47
|
+
- `commerce i18n merchant update` - 更新商户翻译
|
|
48
|
+
- `commerce i18n merchant delete` - 删除商户翻译
|
|
49
|
+
|
|
50
|
+
**首页翻译**:
|
|
51
|
+
- `commerce i18n homepage set` - 设置首页区块翻译
|
|
52
|
+
- `commerce i18n homepage list` - 查看首页翻译
|
|
53
|
+
- `commerce i18n homepage delete` - 删除首页翻译
|
|
54
|
+
|
|
55
|
+
## Examples
|
|
56
|
+
|
|
57
|
+
### 商品翻译
|
|
58
|
+
```bash
|
|
59
|
+
# 用户说:"给商品prod_123添加中文翻译"
|
|
60
|
+
commerce i18n product create \
|
|
61
|
+
--product-id prod_123 \
|
|
62
|
+
--lang zh-CN \
|
|
63
|
+
--name "手工陶瓷杯" \
|
|
64
|
+
--description "精美的手工制作陶瓷杯,适合日常使用"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 变体翻译
|
|
68
|
+
```bash
|
|
69
|
+
# 用户说:"给变体var_456添加日语翻译,包括规格翻译"
|
|
70
|
+
commerce i18n variant create \
|
|
71
|
+
--variant-id var_456 \
|
|
72
|
+
--lang ja-JP \
|
|
73
|
+
--name "セラミックマグ(赤・小)" \
|
|
74
|
+
--variant-attributes-translations '{
|
|
75
|
+
"颜色": {
|
|
76
|
+
"key_translation": "色",
|
|
77
|
+
"value_translation": {"红色": "赤"}
|
|
78
|
+
},
|
|
79
|
+
"尺寸": {
|
|
80
|
+
"key_translation": "サイズ",
|
|
81
|
+
"value_translation": {"S": "小"}
|
|
82
|
+
}
|
|
83
|
+
}'
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 集合翻译
|
|
87
|
+
```bash
|
|
88
|
+
# 用户说:"给summer-sale集合添加西班牙语翻译"
|
|
89
|
+
commerce i18n collection create \
|
|
90
|
+
--collection-id coll_789 \
|
|
91
|
+
--lang es-ES \
|
|
92
|
+
--name "Promoción de Verano" \
|
|
93
|
+
--description "Grandes ofertas para el verano"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 商户翻译
|
|
97
|
+
```bash
|
|
98
|
+
# 用户说:"添加商户的英文翻译"
|
|
99
|
+
commerce i18n merchant create \
|
|
100
|
+
--lang en-US \
|
|
101
|
+
--name "Fashion Store" \
|
|
102
|
+
--description "Your premium fashion destination"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 首页区块翻译
|
|
106
|
+
```bash
|
|
107
|
+
# 用户说:"给首页精选区块添加中英文标题"
|
|
108
|
+
# 中文
|
|
109
|
+
commerce i18n homepage set \
|
|
110
|
+
--section-id section_123 \
|
|
111
|
+
--lang zh-CN \
|
|
112
|
+
--title "精选商品" \
|
|
113
|
+
--description "查看我们最受欢迎的产品"
|
|
114
|
+
|
|
115
|
+
# 英文
|
|
116
|
+
commerce i18n homepage set \
|
|
117
|
+
--section-id section_123 \
|
|
118
|
+
--lang en-US \
|
|
119
|
+
--title "Featured Products" \
|
|
120
|
+
--description "Discover our most popular items"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 批量翻译
|
|
124
|
+
```bash
|
|
125
|
+
# 用户说:"把所有商品翻译成日语"
|
|
126
|
+
# 1. 获取商品列表
|
|
127
|
+
commerce product list --limit 100
|
|
128
|
+
|
|
129
|
+
# 2. 逐个添加翻译
|
|
130
|
+
commerce i18n product create --product-id prod_1 --lang ja-JP --name "..."
|
|
131
|
+
commerce i18n product create --product-id prod_2 --lang ja-JP --name "..."
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## 卓越标准
|
|
135
|
+
|
|
136
|
+
### 翻译质量维度
|
|
137
|
+
- **翻译完整性**: 核心字段100%翻译(商品名、描述、规格)
|
|
138
|
+
- **语言准确性**: 使用母语审校,避免机翻错误
|
|
139
|
+
- **本地化适配**: 考虑文化差异,调整表达方式(如日期格式、货币符号)
|
|
140
|
+
- **SEO优化**: 标题包含目标语言关键词,长度符合搜索引擎要求
|
|
141
|
+
- **更新及时性**: 原文变更后24小时内同步更新翻译
|
|
142
|
+
|
|
143
|
+
### 翻译管理原则
|
|
144
|
+
- **语言代码规范**: 使用BCP 47格式(en-US, zh-CN),不用短代码(en, zh)
|
|
145
|
+
- **优先级排序**: 先翻译商品和集合,再翻译变体细节
|
|
146
|
+
- **一致性检查**: 同一术语在不同场景保持一致(如"Size"统一译为"サイズ")
|
|
147
|
+
- **变体规格翻译**: 先翻译规格键(如"颜色"→"Color"),再翻译规格值(如"红色"→"Red")
|
|
148
|
+
- **占位符策略**: 未翻译的内容回退到默认语言,不显示空白
|
|
149
|
+
|
|
150
|
+
## 工作流推荐
|
|
151
|
+
|
|
152
|
+
### 新语言启用流程
|
|
153
|
+
1. **翻译商户信息** - `commerce i18n merchant create --lang XX` 设置店铺名称、描述
|
|
154
|
+
2. **翻译核心集合** - 翻译首页展示的3-5个主要集合
|
|
155
|
+
3. **翻译热门商品** - 优先翻译销量前20的商品
|
|
156
|
+
4. **翻译首页区块** - 翻译轮播图标题、精选区块标题
|
|
157
|
+
5. **翻译变体规格** - 为有变体的商品添加规格翻译
|
|
158
|
+
6. **批量翻译其他商品** - 逐步补充完整商品库翻译
|
|
159
|
+
7. **验证完整性** - 检查关键页面是否所有内容已翻译
|
|
160
|
+
|
|
161
|
+
### 批量翻译最佳实践
|
|
162
|
+
|
|
163
|
+
**❌ 低效做法**:
|
|
164
|
+
```bash
|
|
165
|
+
# 不规划优先级,随机翻译
|
|
166
|
+
for product_id in $(commerce product list --json | jq -r '.[].id'); do
|
|
167
|
+
commerce i18n product create --product-id $product_id --lang ja-JP --name "..."
|
|
168
|
+
done
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**✅ 高效做法**:
|
|
172
|
+
```bash
|
|
173
|
+
# 1. 先翻译商户信息
|
|
174
|
+
commerce i18n merchant create --lang ja-JP --name "ファッションストア" --description "..."
|
|
175
|
+
|
|
176
|
+
# 2. 获取热门商品列表(按销量排序)
|
|
177
|
+
commerce product list --sort-by sales --limit 20
|
|
178
|
+
|
|
179
|
+
# 3. 优先翻译热门商品
|
|
180
|
+
commerce i18n product create --product-id prod_hot_1 --lang ja-JP --name "..." --description "..."
|
|
181
|
+
commerce i18n product create --product-id prod_hot_2 --lang ja-JP --name "..." --description "..."
|
|
182
|
+
|
|
183
|
+
# 4. 翻译核心集合
|
|
184
|
+
commerce i18n collection create --collection-id coll_featured --lang ja-JP --name "おすすめ商品"
|
|
185
|
+
|
|
186
|
+
# 5. 最后批量翻译其他商品
|
|
187
|
+
for product_id in $(commerce product list --json | jq -r '.[].id'); do
|
|
188
|
+
commerce i18n product create --product-id $product_id --lang ja-JP --name "..."
|
|
189
|
+
done
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### 变体规格翻译技巧
|
|
193
|
+
|
|
194
|
+
**关键点**:主商品的 `variant_attributes_translations` 会自动从变体聚合,只需翻译变体即可。
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# 1. 创建主商品(不需要翻译variant_attributes_translations)
|
|
198
|
+
commerce i18n product create --product-id prod_123 --lang en-US --name "T-Shirt"
|
|
199
|
+
|
|
200
|
+
# 2. 翻译所有变体(包括规格)
|
|
201
|
+
commerce i18n variant create --variant-id var_1 --lang en-US \
|
|
202
|
+
--name "Red T-Shirt (Small)" \
|
|
203
|
+
--variant-attributes-translations '{
|
|
204
|
+
"颜色": {"key_translation": "Color", "value_translation": {"红色": "Red"}},
|
|
205
|
+
"尺寸": {"key_translation": "Size", "value_translation": {"S": "Small"}}
|
|
206
|
+
}'
|
|
207
|
+
|
|
208
|
+
# 3. 主商品会自动聚合变体的规格翻译
|
|
209
|
+
commerce i18n product get --product-id prod_123 --lang en-US
|
|
210
|
+
# 返回聚合后的 variant_attributes_translations
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### 常见场景决策
|
|
214
|
+
|
|
215
|
+
| 用户需求 | 推荐命令 | 关键注意点 |
|
|
216
|
+
|---------|---------|-----------|
|
|
217
|
+
| 新增语言 | `i18n merchant create` → 集合 → 商品 | 按优先级翻译,先商户、集合、热门商品 |
|
|
218
|
+
| 翻译商品 | `i18n product create` | 名称和描述必填,SEO关键词要本地化 |
|
|
219
|
+
| 翻译变体 | `i18n variant create` | 使用variant-id(不是product-id),包含规格翻译 |
|
|
220
|
+
| 翻译集合 | `i18n collection create` | 名称要简洁,描述突出价值 |
|
|
221
|
+
| 翻译首页区块 | `i18n homepage set` | 用于前端展示,标题≤30字,描述≤100字 |
|
|
222
|
+
| 更新翻译 | `i18n * update` | 原文变更后及时同步更新 |
|
|
223
|
+
|
|
224
|
+
### 语言选择策略
|
|
225
|
+
|
|
226
|
+
**目标市场推荐**:
|
|
227
|
+
- **北美市场** - en-US(必须)
|
|
228
|
+
- **欧洲市场** - es-ES(西班牙语覆盖拉美)
|
|
229
|
+
- **亚洲市场** - ja-JP(日本), vi-VN(越南), zh-CN(中国大陆)
|
|
230
|
+
- **全球电商** - en-US + es-ES + zh-CN(覆盖70%全球用户)
|
|
231
|
+
|
|
232
|
+
**翻译投入建议**:
|
|
233
|
+
- 小店铺:先支持1-2种主要语言
|
|
234
|
+
- 中型店铺:支持3-5种语言,覆盖核心市场
|
|
235
|
+
- 大型店铺:支持5种以上语言,专人维护翻译质量
|
|
236
|
+
|
|
237
|
+
### 翻译质量检查清单
|
|
238
|
+
|
|
239
|
+
**上线前必查**:
|
|
240
|
+
- [ ] 商户信息已翻译(名称、描述)
|
|
241
|
+
- [ ] 首页所有区块标题已翻译
|
|
242
|
+
- [ ] 核心集合已翻译(至少5个)
|
|
243
|
+
- [ ] 热门商品已翻译(至少20个)
|
|
244
|
+
- [ ] 变体规格翻译格式正确
|
|
245
|
+
- [ ] 无机翻痕迹(如直译、语序错误)
|
|
246
|
+
- [ ] 术语一致性(如Size统一译法)
|
|
247
|
+
- [ ] 移动端显示正常(无溢出、截断)
|
|
248
|
+
|
|
249
|
+
## Notes
|
|
250
|
+
|
|
251
|
+
- 支持的语言:en-US, es-ES, ja-JP, vi-VN, zh-CN
|
|
252
|
+
- 变体翻译的 `variant-attributes-translations` 格式复杂,需要同时翻译规格键和值
|
|
253
|
+
- 商户翻译是单例,不需要指定 ID
|
|
254
|
+
- 首页区块翻译用于前端展示的多语言标题和描述
|
|
255
|
+
- 主商品的 variant_attributes_translations 会自动从变体聚合
|
|
256
|
+
- 使用 `--help` 查看命令详细参数
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: commerce-inventory
|
|
3
|
+
description: Inventory management and stock monitoring. Track stock levels, update inventory, check low stock alerts, view inventory history, reserve stock. Use when user needs to check stock, replenish inventory, monitor low stock warnings, or manage stock reservations.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Commerce CLI - Inventory Management
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
库存管理模块,用于监控库存水平、补货、预留和历史跟踪。
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
|
|
14
|
+
### 自然语言映射
|
|
15
|
+
|
|
16
|
+
当用户说:
|
|
17
|
+
- "查看库存低于10的商品" → `commerce inventory low-stock --threshold 10`
|
|
18
|
+
- "商品XX补货50个" → `commerce inventory update --id XX --quantity 50 --reason "补货"`
|
|
19
|
+
- "预留库存" → `commerce inventory reserve --product-id XX --quantity YY`
|
|
20
|
+
- "查看库存历史" → `commerce inventory history --product-id XX`
|
|
21
|
+
- "查看所有商品库存" → `commerce inventory list`
|
|
22
|
+
|
|
23
|
+
### 核心功能
|
|
24
|
+
|
|
25
|
+
**库存查询**:
|
|
26
|
+
- `commerce inventory list` - 查看所有商品库存
|
|
27
|
+
- `commerce inventory get` - 查看单个商品库存
|
|
28
|
+
- `commerce inventory low-stock` - 查看低库存商品
|
|
29
|
+
- `commerce inventory history` - 查看库存变更历史
|
|
30
|
+
|
|
31
|
+
**库存更新**:
|
|
32
|
+
- `commerce inventory update` - 更新库存数量
|
|
33
|
+
- `commerce inventory reserve` - 预留库存
|
|
34
|
+
- `commerce inventory release` - 释放预留库存
|
|
35
|
+
|
|
36
|
+
## Examples
|
|
37
|
+
|
|
38
|
+
### 查看低库存预警
|
|
39
|
+
```bash
|
|
40
|
+
# 用户说:"查看库存低于5的商品"
|
|
41
|
+
commerce inventory low-stock --threshold 5
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 补货操作
|
|
45
|
+
```bash
|
|
46
|
+
# 用户说:"商品prod_123补货100个"
|
|
47
|
+
commerce inventory update \
|
|
48
|
+
--id prod_123 \
|
|
49
|
+
--quantity 100 \
|
|
50
|
+
--reason "定期补货"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 预留库存
|
|
54
|
+
```bash
|
|
55
|
+
# 用户说:"为订单预留5个商品"
|
|
56
|
+
commerce inventory reserve \
|
|
57
|
+
--product-id prod_123 \
|
|
58
|
+
--quantity 5 \
|
|
59
|
+
--order-id order_456
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 查看库存历史
|
|
63
|
+
```bash
|
|
64
|
+
# 用户说:"查看商品prod_123的库存变更记录"
|
|
65
|
+
commerce inventory history \
|
|
66
|
+
--product-id prod_123 \
|
|
67
|
+
--limit 20
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 批量查看库存
|
|
71
|
+
```bash
|
|
72
|
+
# 用户说:"查看所有商品的库存情况"
|
|
73
|
+
commerce inventory list --limit 100
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 卓越标准
|
|
77
|
+
|
|
78
|
+
### 库存管理质量指标
|
|
79
|
+
- **库存准确率**: 账实相符率 ≥ 98%,定期盘点验证
|
|
80
|
+
- **低库存预警响应**: 检测到低库存后24小时内补货
|
|
81
|
+
- **缺货率**: < 2%,避免影响客户体验和转化率
|
|
82
|
+
- **超卖率**: 0%,通过预留机制和实时同步防止超卖
|
|
83
|
+
- **库存周转率**: 根据品类优化,畅销品 > 6次/年,滞销品及时清理
|
|
84
|
+
|
|
85
|
+
### 库存管理原则
|
|
86
|
+
- **实时同步**: 订单创建时立即预留库存,发货后扣减,取消后释放
|
|
87
|
+
- **安全库存**: 设置合理的低库存阈值(畅销品 > 30天销量,滞销品 > 7天销量)
|
|
88
|
+
- **先进先出**: 先入库的商品优先出库,减少积压和过期
|
|
89
|
+
- **定期盘点**: 每月盘点核对账实差异,及时调整
|
|
90
|
+
- **历史追踪**: 所有库存变更必须记录原因,便于审计
|
|
91
|
+
|
|
92
|
+
## 工作流推荐
|
|
93
|
+
|
|
94
|
+
### 日常库存监控流程
|
|
95
|
+
1. **查看低库存** - 每日 `commerce inventory low-stock --threshold 10`
|
|
96
|
+
2. **分析销售趋势** - 结合订单数据判断补货优先级
|
|
97
|
+
3. **制定补货计划** - 畅销品加大补货量,滞销品谨慎补货
|
|
98
|
+
4. **执行补货** - `commerce inventory update --id XX --quantity YY --reason "补货"`
|
|
99
|
+
5. **验证更新** - `commerce inventory get --id XX` 确认库存正确
|
|
100
|
+
6. **定期盘点** - 每月实地盘点,调整账面库存
|
|
101
|
+
|
|
102
|
+
### 批量补货最佳实践
|
|
103
|
+
|
|
104
|
+
**❌ 危险做法**:
|
|
105
|
+
```bash
|
|
106
|
+
# 不分析就盲目补货,可能造成库存积压
|
|
107
|
+
for product_id in $(commerce inventory low-stock --json | jq -r '.[].id'); do
|
|
108
|
+
commerce inventory update --id $product_id --quantity 100 --reason "批量补货"
|
|
109
|
+
done
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**✅ 科学做法**:
|
|
113
|
+
```bash
|
|
114
|
+
# 先分析低库存商品,按销售速度分级补货
|
|
115
|
+
commerce inventory low-stock --threshold 10
|
|
116
|
+
|
|
117
|
+
# 根据销售数据决定补货量
|
|
118
|
+
commerce inventory update --id prod_hot --quantity 500 --reason "畅销品大量补货"
|
|
119
|
+
commerce inventory update --id prod_normal --quantity 100 --reason "常规补货"
|
|
120
|
+
commerce inventory update --id prod_slow --quantity 20 --reason "滞销品少量补货"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 库存预留机制
|
|
124
|
+
- **订单创建时预留** - 避免超卖,保证订单可履行
|
|
125
|
+
- **支付超时释放** - 未支付订单15分钟后自动释放预留
|
|
126
|
+
- **取消订单释放** - 订单取消后立即释放预留
|
|
127
|
+
- **发货后扣减** - 商品发货后从可用库存扣减
|
|
128
|
+
|
|
129
|
+
### 常见场景决策
|
|
130
|
+
|
|
131
|
+
| 用户需求 | 推荐命令 | 关键注意点 |
|
|
132
|
+
|---------|---------|-----------|
|
|
133
|
+
| 查看低库存 | `inventory low-stock --threshold 10` | 阈值根据品类和销售速度设定 |
|
|
134
|
+
| 补货操作 | `inventory update --quantity XX --reason` | 必须填写原因,便于追踪 |
|
|
135
|
+
| 预留库存 | `inventory reserve --order-id XX` | 订单创建时立即预留,避免超卖 |
|
|
136
|
+
| 释放预留 | `inventory release --order-id XX` | 订单取消或支付超时时释放 |
|
|
137
|
+
| 查看历史 | `inventory history --product-id XX` | 分析库存变化趋势,优化补货策略 |
|
|
138
|
+
| 盘点调整 | `inventory update --reason "盘点调整"` | 账实不符时手动调整,记录差异原因 |
|
|
139
|
+
|
|
140
|
+
### 库存异常处理
|
|
141
|
+
|
|
142
|
+
**超卖场景**:
|
|
143
|
+
- 预防措施:订单创建时立即预留库存
|
|
144
|
+
- 发生后:优先处理早期订单,联系后续客户协商延期或退款
|
|
145
|
+
- 长期优化:检查库存同步机制,修复bug
|
|
146
|
+
|
|
147
|
+
**库存差异场景**:
|
|
148
|
+
- 定期盘点发现差异 → 核实实际库存,调整账面库存
|
|
149
|
+
- 记录差异原因(损耗、盗窃、系统错误等)
|
|
150
|
+
- 差异率 > 5%需要深入调查
|
|
151
|
+
|
|
152
|
+
**滞销商品场景**:
|
|
153
|
+
- 库存周转率低 → 降价促销、捆绑销售
|
|
154
|
+
- 3个月未动销 → 考虑清仓处理
|
|
155
|
+
- 6个月未动销 → 下架并清理库存
|
|
156
|
+
|
|
157
|
+
## Notes
|
|
158
|
+
|
|
159
|
+
- 库存变更会自动记录历史
|
|
160
|
+
- 预留库存不会减少可用库存数量
|
|
161
|
+
- 更新库存时建议添加 `--reason` 说明原因
|
|
162
|
+
- 低库存阈值可以自定义
|
|
163
|
+
- 支持批量库存更新(通过脚本循环调用)
|
|
164
|
+
- 使用 `--help` 查看命令详细参数
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: commerce-order
|
|
3
|
+
description: Order fulfillment and shipping management. Process orders, ship packages, handle cancellations, manage refunds, track shipments. Use when user needs to fulfill orders, ship products, cancel orders, process refunds, or check shipping status.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Commerce CLI - Order Fulfillment
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
订单履行模块,用于处理订单、发货、售后和物流跟踪。
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
|
|
14
|
+
### 自然语言映射
|
|
15
|
+
|
|
16
|
+
当用户说:
|
|
17
|
+
- "查看待发货订单" → `commerce order list --status paid`
|
|
18
|
+
- "订单XX发货" → `commerce order ship --id XX --tracking YY --carrier ZZ`
|
|
19
|
+
- "取消订单XX" → `commerce order cancel --id XX --yes`
|
|
20
|
+
- "标记订单已送达" → `commerce order mark-delivered --id XX`
|
|
21
|
+
- "查询运费" → `commerce shipping calculate --country XX --weight YY`
|
|
22
|
+
- "处理退款" → `commerce refund create --order-id XX --amount YY`
|
|
23
|
+
|
|
24
|
+
### 核心功能
|
|
25
|
+
|
|
26
|
+
**订单管理**:
|
|
27
|
+
- `commerce order list` - 查看订单列表
|
|
28
|
+
- `commerce order get` - 查看订单详情
|
|
29
|
+
- `commerce order ship` - 标记订单发货
|
|
30
|
+
- `commerce order cancel` - 取消订单
|
|
31
|
+
- `commerce order complete` - 完成订单
|
|
32
|
+
- `commerce order mark-delivered` - 标记已送达
|
|
33
|
+
|
|
34
|
+
**退款管理**:
|
|
35
|
+
- `commerce refund create` - 创建退款
|
|
36
|
+
- `commerce refund list` - 查看退款列表
|
|
37
|
+
- `commerce refund get` - 查看退款详情
|
|
38
|
+
- `commerce refund approve` - 批准退款
|
|
39
|
+
- `commerce refund reject` - 拒绝退款
|
|
40
|
+
|
|
41
|
+
**物流管理**:
|
|
42
|
+
- `commerce shipping calculate` - 计算运费
|
|
43
|
+
- `commerce shipping track` - 物流追踪
|
|
44
|
+
- `commerce shipping update-status` - 更新物流状态
|
|
45
|
+
|
|
46
|
+
## Examples
|
|
47
|
+
|
|
48
|
+
### 查看待处理订单
|
|
49
|
+
```bash
|
|
50
|
+
# 用户说:"查看今天待发货的订单"
|
|
51
|
+
commerce order list --status paid --limit 50
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 订单发货
|
|
55
|
+
```bash
|
|
56
|
+
# 用户说:"订单order_123发货,快递单号DHL123456,承运商DHL"
|
|
57
|
+
commerce order ship \
|
|
58
|
+
--id order_123 \
|
|
59
|
+
--tracking DHL123456 \
|
|
60
|
+
--carrier DHL
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 取消订单
|
|
64
|
+
```bash
|
|
65
|
+
# 用户说:"取消订单order_456,原因是客户要求"
|
|
66
|
+
commerce order cancel \
|
|
67
|
+
--id order_456 \
|
|
68
|
+
--reason "客户要求取消" \
|
|
69
|
+
--yes
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 标记订单完成
|
|
73
|
+
```bash
|
|
74
|
+
# 用户说:"标记订单order_789已送达"
|
|
75
|
+
commerce order mark-delivered --id order_789
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 计算运费
|
|
79
|
+
```bash
|
|
80
|
+
# 用户说:"计算寄到美国纽约10001的运费,重量0.5kg"
|
|
81
|
+
commerce shipping calculate \
|
|
82
|
+
--country US \
|
|
83
|
+
--postal-code 10001 \
|
|
84
|
+
--weight 0.5
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 处理退款
|
|
88
|
+
```bash
|
|
89
|
+
# 用户说:"订单order_123要退款150美元"
|
|
90
|
+
commerce refund create \
|
|
91
|
+
--order-id order_123 \
|
|
92
|
+
--amount 150 \
|
|
93
|
+
--reason "商品有瑕疵"
|
|
94
|
+
|
|
95
|
+
# 批准退款
|
|
96
|
+
commerce refund approve --id refund_456
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 物流追踪
|
|
100
|
+
```bash
|
|
101
|
+
# 用户说:"查询快递单号DHL123456的物流信息"
|
|
102
|
+
commerce shipping track --tracking-number DHL123456
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## 卓越标准
|
|
106
|
+
|
|
107
|
+
### 订单处理质量指标
|
|
108
|
+
- **发货及时性**: 付款后24小时内发货(标品),48小时内发货(定制品)
|
|
109
|
+
- **物流信息准确性**: 100%订单有tracking number,无虚假单号
|
|
110
|
+
- **客户满意度**: 退款率 < 5%,客服投诉响应 < 2小时
|
|
111
|
+
- **订单完成率**: 取消率 < 3%,拒收率 < 2%
|
|
112
|
+
|
|
113
|
+
### 订单状态管理原则
|
|
114
|
+
- **3-5-7原则**: 3分钟确认订单,5小时内完成打包,7天内跟踪售后
|
|
115
|
+
- **自动化优先**: 批量处理相同状态订单,优先处理付款时间早的订单
|
|
116
|
+
- **数据完整性**: 发货前验证库存、收货地址、物流商可达性
|
|
117
|
+
- **客户沟通**: 关键状态变更后及时通知(发货、延迟、退款、取消)
|
|
118
|
+
- **审计留痕**: 所有操作记录原因和操作人,便于问题追溯
|
|
119
|
+
|
|
120
|
+
## 工作流推荐
|
|
121
|
+
|
|
122
|
+
### 标准订单履行流程
|
|
123
|
+
1. **查看待发货** - `commerce order list --status paid` 按时间升序
|
|
124
|
+
2. **验证订单** - 检查库存、地址、特殊要求
|
|
125
|
+
3. **批量打包** - 准备商品、包装材料、打印面单
|
|
126
|
+
4. **标记发货** - 循环 `commerce order ship --id XX --tracking YY --carrier ZZ`
|
|
127
|
+
5. **物流跟踪** - 定期 `commerce shipping track` 监控异常
|
|
128
|
+
6. **确认送达** - 签收后 `commerce order mark-delivered --id XX`
|
|
129
|
+
|
|
130
|
+
### 批量发货最佳实践
|
|
131
|
+
|
|
132
|
+
**❌ 危险做法**:
|
|
133
|
+
```bash
|
|
134
|
+
# 不验证就批量发货,可能发错货或虚假发货
|
|
135
|
+
for order_id in $(commerce order list --status paid --json | jq -r '.[].id'); do
|
|
136
|
+
commerce order ship --id $order_id --tracking FAKE123 --carrier DHL
|
|
137
|
+
done
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**✅ 安全做法**:
|
|
141
|
+
```bash
|
|
142
|
+
# 先人工验证,准备好真实tracking号,再批量发货
|
|
143
|
+
commerce order list --status paid # 先查看订单列表
|
|
144
|
+
|
|
145
|
+
# 准备好所有tracking号后,逐个发货
|
|
146
|
+
commerce order ship --id order_123 --tracking DHL123456 --carrier DHL
|
|
147
|
+
commerce order ship --id order_456 --tracking DHL123457 --carrier DHL
|
|
148
|
+
commerce order ship --id order_789 --tracking DHL123458 --carrier DHL
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 退款处理最佳实践
|
|
152
|
+
1. **创建退款** - `commerce refund create` 填写详细原因
|
|
153
|
+
2. **审核评估** - 检查商品状态、退货凭证、历史记录
|
|
154
|
+
3. **批准/拒绝** - `commerce refund approve/reject` 并通知客户
|
|
155
|
+
4. **跟踪反馈** - 记录退款原因,优化产品和服务
|
|
156
|
+
|
|
157
|
+
### 常见场景决策
|
|
158
|
+
|
|
159
|
+
| 用户需求 | 推荐命令 | 关键注意点 |
|
|
160
|
+
|---------|---------|-----------|
|
|
161
|
+
| 查看待发货订单 | `order list --status paid` | 按付款时间升序,优先处理早期订单 |
|
|
162
|
+
| 批量发货 | 循环 `order ship` | 必须有真实tracking号,避免虚假发货 |
|
|
163
|
+
| 取消订单 | `order cancel --yes` | 检查是否已发货,避免错误取消 |
|
|
164
|
+
| 处理退款 | `refund create` → `refund approve` | 先创建后审批,保留审计记录 |
|
|
165
|
+
| 运费查询 | `shipping calculate` | 提供准确重量和邮编,避免运费纠纷 |
|
|
166
|
+
| 物流异常 | `shipping track` → `shipping update-status` | 主动更新状态,及时通知客户 |
|
|
167
|
+
|
|
168
|
+
### 异常处理指南
|
|
169
|
+
|
|
170
|
+
**订单取消场景**:
|
|
171
|
+
- 客户主动取消 → 检查是否已发货,未发货立即取消
|
|
172
|
+
- 地址错误无法送达 → 联系客户更新地址或取消退款
|
|
173
|
+
- 库存不足 → 立即通知客户,协商补货或退款
|
|
174
|
+
|
|
175
|
+
**退款场景**:
|
|
176
|
+
- 商品质量问题 → 无需退货,直接全额退款
|
|
177
|
+
- 客户不满意 → 要求退货,收到货后退款
|
|
178
|
+
- 物流丢失 → 联系物流商理赔,先行退款给客户
|
|
179
|
+
|
|
180
|
+
**物流延迟场景**:
|
|
181
|
+
- 国内延迟 > 3天 → 主动联系客户说明情况
|
|
182
|
+
- 国际延迟 > 7天 → 提供物流追踪链接,协商解决方案
|
|
183
|
+
- 物流丢失 → 联系物流商查询,必要时补发或退款
|
|
184
|
+
|
|
185
|
+
## Notes
|
|
186
|
+
|
|
187
|
+
- 订单状态流转:pending → paid → shipped → delivered → completed
|
|
188
|
+
- 取消和删除操作需要 `--yes` 确认
|
|
189
|
+
- 发货后订单状态自动变为 shipped
|
|
190
|
+
- 退款需要先创建,然后批准才会实际退款
|
|
191
|
+
- 支持的物流商:DHL, FedEx, UPS, USPS, SF Express, 顺丰
|
|
192
|
+
- 使用 `--help` 查看命令详细参数
|