cbs-4px-merchant-cli 0.0.11 → 0.0.13
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/dist/cli.js +135 -12
- package/dist/cli.js.map +1 -1
- package/dist/commands/config.js +145 -8
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/custody.d.ts +49 -0
- package/dist/commands/custody.js +245 -0
- package/dist/commands/custody.js.map +1 -1
- package/dist/commands/onboarding.d.ts +5 -0
- package/dist/commands/onboarding.js +22 -0
- package/dist/commands/onboarding.js.map +1 -1
- package/dist/commands/order.d.ts +15 -0
- package/dist/commands/order.js +194 -8
- package/dist/commands/order.js.map +1 -1
- package/dist/commands/platform.d.ts +42 -0
- package/dist/commands/platform.js +98 -5
- package/dist/commands/platform.js.map +1 -1
- package/dist/commands/update.js +124 -3
- package/dist/commands/update.js.map +1 -1
- package/dist/errors.d.ts +29 -1
- package/dist/errors.js +11 -1
- package/dist/errors.js.map +1 -1
- package/dist/services/api-client.d.ts +37 -2
- package/dist/services/api-client.js +70 -4
- package/dist/services/api-client.js.map +1 -1
- package/dist/services/binary-source.d.ts +30 -0
- package/dist/services/binary-source.js +88 -0
- package/dist/services/binary-source.js.map +1 -0
- package/dist/services/binary-update.d.ts +62 -0
- package/dist/services/binary-update.js +179 -0
- package/dist/services/binary-update.js.map +1 -0
- package/dist/services/install-detector.d.ts +13 -1
- package/dist/services/install-detector.js +20 -1
- package/dist/services/install-detector.js.map +1 -1
- package/dist/types/index.d.ts +137 -1
- package/package.json +7 -1
- package/skill/SKILL.md +11 -4
- package/skill/package.json +1 -1
- package/skill/reference/custody.md +217 -4
- package/skill/reference/index.md +9 -3
- package/skill/reference/onboarding.md +42 -0
- package/skill/reference/order.md +134 -4
- package/skill/reference/platform.md +84 -1
package/skill/reference/order.md
CHANGED
|
@@ -268,6 +268,102 @@ fmc order country 日本 --output json
|
|
|
268
268
|
|
|
269
269
|
---
|
|
270
270
|
|
|
271
|
+
### `fmc order field-rules`
|
|
272
|
+
|
|
273
|
+
| Field | Value |
|
|
274
|
+
| --- | --- |
|
|
275
|
+
| **Name** | `order field-rules` |
|
|
276
|
+
| **Description** | 查询下单字段规则:哪些字段必填、填写规范、校验提示、跨字段联动约束 |
|
|
277
|
+
| **Usage** | `fmc order field-rules --product-code <code> --country <cc> [flags]` |
|
|
278
|
+
|
|
279
|
+
需要 API Key 认证。**建单/改单前应先调本命令**。
|
|
280
|
+
|
|
281
|
+
字段必填性由后端规则库按 (产品, 目的国, 客户) 配置,三级降级取值(产品规则 → 产品组规则 → 默认规则),**同一字段在不同产品下结论可能相反**。所以不要凭经验或文档假定必填项,查这里。
|
|
282
|
+
|
|
283
|
+
#### Options
|
|
284
|
+
|
|
285
|
+
| Flag | Type | Required | Description |
|
|
286
|
+
| --- | --- | --- | --- |
|
|
287
|
+
| `--product-code <code>` | string | yes | 物流产品代码,从 `product recommend` / `product search` 获取 |
|
|
288
|
+
| `--country <code>` | string | yes | 目的国家二字码,从 `order country` 获取 |
|
|
289
|
+
| `--required-only` | boolean | no | 只返回必填字段 |
|
|
290
|
+
| `--field <name>` | string | no | 只看指定字段(字段名或中文标签)。仅过滤展示,不改变查询范围 |
|
|
291
|
+
|
|
292
|
+
支持全局选项: `--output`, `--verbose`, `--dry-run`
|
|
293
|
+
|
|
294
|
+
#### Examples
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
# 建单前查该产品+目的国的必填项
|
|
298
|
+
fmc order field-rules --product-code A65 --country US --required-only
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
# 查单个字段的填写规范(如邮编格式)
|
|
303
|
+
fmc order field-rules --product-code A65 --country US --field consigneePostcode
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
# 给 Agent 消费
|
|
308
|
+
fmc order field-rules --product-code A65 --country DE --output json
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
#### Output (text mode)
|
|
312
|
+
|
|
313
|
+
```
|
|
314
|
+
下单字段规则
|
|
315
|
+
────────────────────────────────────────────────────────────
|
|
316
|
+
产品 A65
|
|
317
|
+
目的国家 US
|
|
318
|
+
|
|
319
|
+
必填字段(3)
|
|
320
|
+
──────────────────────────────────────────────────
|
|
321
|
+
* consigneeName 收件人姓名
|
|
322
|
+
规则 nullValue=Y, maxLength=35
|
|
323
|
+
提示 收件人姓名:不能为空
|
|
324
|
+
* consigneePostcode 收件人邮编
|
|
325
|
+
规则 nullValue=Y, regex
|
|
326
|
+
填写规范 5 位数字,如 97201
|
|
327
|
+
* customerWeight 重量
|
|
328
|
+
规则 nullValue=Y
|
|
329
|
+
|
|
330
|
+
非必填字段(1)
|
|
331
|
+
──────────────────────────────────────────────────
|
|
332
|
+
iossNo IOSS税号
|
|
333
|
+
规则 maxLength=12
|
|
334
|
+
|
|
335
|
+
跨字段联动约束
|
|
336
|
+
──────────────────────────────────────────────────
|
|
337
|
+
· iossNo 与 consigneeVatNo 二选一必填(两者皆空才报错)
|
|
338
|
+
· 填写 iossNo 时,每个申报品的 hscode 必填
|
|
339
|
+
· 全单币种须一致:运费、申报保险费、各申报品币种不可混用
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
#### 字段名与 JSON 路径的对应
|
|
343
|
+
|
|
344
|
+
返回的 `field` 是**后端订单字段名**(`consigneeName` / `customerWeight` / `pcs`),而 `order create` 的 JSON 是嵌套结构(`receiver.name` / `parcel.weight` / `declareItems[].qty`)。两者**不是驼峰转换关系**,不要自己推。
|
|
345
|
+
|
|
346
|
+
**每个字段都带 `requestPath`,直接用它**:
|
|
347
|
+
|
|
348
|
+
```json
|
|
349
|
+
{"field":"consigneeName","requestPath":"receiver.name","required":true,"fieldLabel":"收件人姓名"}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
`requestPath` 为 `null` 表示该字段不能通过建单/改单接口设置(只能在界面或由后端计算)。
|
|
353
|
+
|
|
354
|
+
几个**靠猜必然错**的例子:
|
|
355
|
+
|
|
356
|
+
| 后端字段名 | JSON 路径 | 容易猜错成 |
|
|
357
|
+
| --- | --- | --- |
|
|
358
|
+
| `consigneeMail` | `receiver.email` | ~~`consigneeEmail`~~ |
|
|
359
|
+
| `customerWeight` | `parcel.weight` | ~~`customerWeight`~~ |
|
|
360
|
+
| `pcs` | `declareItems[].qty` | ~~`pcs`~~ |
|
|
361
|
+
| `brandExport` | `declareItems[].brand` | ~~`brandExport`~~ |
|
|
362
|
+
| `hscode` | `declareItems[].hsCode` | 大小写不同 |
|
|
363
|
+
| `consigneeTelephone` | `receiver.phone` | ~~`receiver.telephone`~~ |
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
271
367
|
## 下单与订单写操作
|
|
272
368
|
|
|
273
369
|
### 状态模型
|
|
@@ -291,14 +387,14 @@ fmc order country 日本 --output json
|
|
|
291
387
|
| `productCode` | string | **yes** | 物流产品代码;先用 `product recommend/search` 选 |
|
|
292
388
|
| `destinationCountry` | string | **yes** | 目的国 ISO2,如 `US` |
|
|
293
389
|
| `originCountry` | string | no | 始发国 ISO2,如 `CN` |
|
|
294
|
-
| `status` | string | no | `P`
|
|
390
|
+
| `status` | string | no | **不必写**。草稿/预报由 `--draft` 控制。仅为兼容保留(`P` 预报、`D` 草稿),写了也会被 CLI 归一成布尔发出 |
|
|
295
391
|
| `customerOrderNo` | string | no | 客户参考号,建议传店铺订单号 |
|
|
296
392
|
| `pieces` | number | no | 件数,默认 1 |
|
|
297
393
|
| `hasBattery` | string | no | 是否带电 `Y`/`N`;为 `Y` 时 `parcel.batteryType` 必填 |
|
|
298
394
|
| `buyerId` | string | no | 电商平台买家 ID |
|
|
299
395
|
| `sender` | object | no | `name` `company` `phone` `mobile` `email` `address` `address2` `country` `postcode` `city` `province` |
|
|
300
396
|
| `receiver` | object | no | `name` `company` `phone` `mobile` `firstName` `lastName` `address` `address2` `street` `doorNo` `city` `province` `postcode` `country` `email` `idCode` `vatNo` |
|
|
301
|
-
| `parcel` | object | no | `weight`(kg) `length` `width` `height`(cm) `dutyPayMode` `batteryType` `iossNo` `orderNote` `salesPlatform` `warehouseCode` `codPrice` `codCurrency` |
|
|
397
|
+
| `parcel` | object | no | `weight`(kg) `length` `width` `height`(cm) `dutyPayMode` `batteryType` `iossNo` `eoriNo`(EORI,欧盟进口商登记号) `orderNote` `salesPlatform` `warehouseCode` `codPrice` `codCurrency` |
|
|
302
398
|
| `declareItems` | array | no | 每项含 `ename` `cname` `qty` `unitPrice` `currency` `weight`(kg) `hsCode` `material` `uses` `url` `brand` |
|
|
303
399
|
|
|
304
400
|
完整示例 `order.json`:
|
|
@@ -361,7 +457,11 @@ fmc order country 日本 --output json
|
|
|
361
457
|
}
|
|
362
458
|
```
|
|
363
459
|
|
|
364
|
-
|
|
460
|
+
**上表的"必填"只描述 `create` 接口自身的入参约束,不等于业务必填。**真正哪些字段必填由后端规则库按 (产品, 目的国, 客户) 配置,**不同产品结论不同**,因此建单前先用 `order field-rules --product-code <code> --country <cc>` 查一次,按返回的 `required` 补齐——不要凭本文档或经验假定。
|
|
461
|
+
|
|
462
|
+
`create` 本身只硬拦 `productCode` 和 `destinationCountry`(它们是查规则的入参,缺了连规则都查不到)。CLI 另有一份本地启发式告警(收件人姓名/地址/国家/邮编/电话、发件人、重量、申报品英文名/数量/单价,以及 `hasBattery=Y` 却缺 `parcel.batteryType`),打印为 `⚠`。这份清单是固定的、对所有产品一视同仁,**只作兜底**:以 `field-rules` 的结果为准,两者冲突时听 `field-rules`。有告警先补齐,不要直接提交。
|
|
463
|
+
|
|
464
|
+
`field-rules` 还会返回单字段必填表达不了的联动约束:IOSS 与收件人 VAT 二选一、填了 IOSS 则每个申报品 `hsCode` 必填、全单币种须一致等。欧美目的国建议拆填 `receiver.firstName`/`lastName` 和 `address2`。
|
|
365
465
|
|
|
366
466
|
### `fmc order create`
|
|
367
467
|
|
|
@@ -379,16 +479,46 @@ cat order.json | fmc order create --file - --draft -y
|
|
|
379
479
|
|
|
380
480
|
# 用户明确要求直接下单时,才省略 --draft
|
|
381
481
|
fmc order create --file ./order.json -y
|
|
482
|
+
|
|
483
|
+
# 以历史单为底稿:复制其产品/寄件人/收件人/包裹/申报品(不复制单号/状态)
|
|
484
|
+
fmc order create --like 4PX0001234567 --draft -y
|
|
382
485
|
```
|
|
383
486
|
|
|
384
487
|
| Flag | Required | Description |
|
|
385
488
|
| --- | --- | --- |
|
|
386
|
-
| `--file <path>` |
|
|
489
|
+
| `--file <path>` | 二选一 | JSON 文件路径;`-` 表示 stdin(与 `--like` 互斥) |
|
|
490
|
+
| `--like <orderNo>` | 二选一 | 以历史订单为底稿,复制产品/收发件人/包裹/申报品(与 `--file` 互斥) |
|
|
387
491
|
| `--draft` | no | 保存草稿,不直接预报 |
|
|
388
492
|
| `-y, --yes` | non-TTY yes | 跳过终端交互确认 |
|
|
389
493
|
|
|
390
494
|
返回 `orderId`、物流单号、状态和客户单号。草稿确认无误后用 `forecast`。
|
|
391
495
|
|
|
496
|
+
#### 校验失败时的返回
|
|
497
|
+
|
|
498
|
+
后端校验不通过时退出码为 1,stderr 输出 JSON 信封,其中 `error.fieldErrors` 是**结构化的字段级错误**:
|
|
499
|
+
|
|
500
|
+
```json
|
|
501
|
+
{"error":{"code":"ORDER_CREATE_FAILED","message":"收件人姓名:不能为空;HS编码:不能为空",
|
|
502
|
+
"fieldErrors":[
|
|
503
|
+
{"field":"consigneeName","requestPath":"receiver.name","value":"",
|
|
504
|
+
"msg":"收件人姓名:不能为空","stdErrorCode":"CONSIGNEE_NAME_CANNOT_BE_EMPTY"},
|
|
505
|
+
{"field":"declareInvoiceList[0].hscode","requestPath":"declareItems[0].hsCode",
|
|
506
|
+
"msg":"HS编码:不能为空"}]}}
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
| 字段 | 说明 |
|
|
510
|
+
| --- | --- |
|
|
511
|
+
| `field` | 后端订单字段名,与 `order field-rules` 的 `field` 同一套命名 |
|
|
512
|
+
| `requestPath` | **改 JSON 时用这个**——该字段在请求体里的路径(`receiver.name`、`declareItems[0].hsCode`)。注意下标会保留,指向出错的那一项 |
|
|
513
|
+
| `value` | 提交时的值。空/缺失=没填;有值=填了但不合规 |
|
|
514
|
+
| `msg` | 不通过的原因,可直接念给商家 |
|
|
515
|
+
| `stdErrorCode` | 标准错误码,非空时可程序化判断 |
|
|
516
|
+
|
|
517
|
+
**优先读 `fieldErrors` 而不是 `message`** —— message 只是把所有 `msg` 用分号拼起来给人看的。
|
|
518
|
+
非校验类失败(余额不足、配额用尽等)没有 `fieldErrors`,这时才回退读 `message`。
|
|
519
|
+
|
|
520
|
+
`edit` 的失败返回结构完全相同,只是 `code` 为 `ORDER_EDIT_FAILED`。
|
|
521
|
+
|
|
392
522
|
### `fmc order edit`
|
|
393
523
|
|
|
394
524
|
只可编辑草稿或已取消订单。JSON 只传要改的字段;`sender` / `receiver` / `parcel` 内部也按非空字段覆盖,`declareItems` 一旦传入则整组替换。
|
|
@@ -177,6 +177,14 @@ fmc platform sync-record list --size 5 --output json
|
|
|
177
177
|
| --- | --- | --- | --- |
|
|
178
178
|
| `--status <code>` | string | no | 订单状态:`0` 待推送、`1` 已推送;不传查全部 |
|
|
179
179
|
| `--keyword <word>` | string | no | 关键字(平台订单号 / 客户订单号) |
|
|
180
|
+
| `--platform <name>` | string | no | 电商平台(amazon/shopee 等) |
|
|
181
|
+
| `--country <code>` | string | no | 目的国家二字码(如 US/CN) |
|
|
182
|
+
| `--receiver-name <name>` | string | no | 收件人姓名 |
|
|
183
|
+
| `--buyer-id <id>` | string | no | 买家 ID |
|
|
184
|
+
| `--seller-account-id <id>` | string | no | 卖家账号 ID(从 `platform account list` 获取) |
|
|
185
|
+
| `--product-code <code>` | string | no | 产品代码 |
|
|
186
|
+
| `--start-date <time>` | string | no | 起始时间 `yyyy-MM-dd HH:mm:ss` |
|
|
187
|
+
| `--end-date <time>` | string | no | 截止时间 `yyyy-MM-dd HH:mm:ss` |
|
|
180
188
|
| `--page <num>` | number | no | 页码,默认 1 |
|
|
181
189
|
| `--size <num>` | number | no | 每页数量,默认 10,最大 100 |
|
|
182
190
|
|
|
@@ -193,6 +201,11 @@ fmc platform order list --status 0
|
|
|
193
201
|
fmc platform order list --keyword 113-1234567-1234567
|
|
194
202
|
```
|
|
195
203
|
|
|
204
|
+
```bash
|
|
205
|
+
# 组合筛选:某卖家账号 + 平台 + 目的国 + 待推送
|
|
206
|
+
fmc platform order list --seller-account-id <id> --platform amazon --country US --status 0
|
|
207
|
+
```
|
|
208
|
+
|
|
196
209
|
#### Output (text mode)
|
|
197
210
|
|
|
198
211
|
```
|
|
@@ -312,6 +325,76 @@ fmc platform order push --ids 20001 --dry-run
|
|
|
312
325
|
|
|
313
326
|
#### Output (text mode)
|
|
314
327
|
|
|
328
|
+
全部成功:
|
|
329
|
+
|
|
330
|
+
```
|
|
331
|
+
✔ 推送成功:1 个订单
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
部分失败(后端只回失败明细,逐单列出):
|
|
335
|
+
|
|
336
|
+
```
|
|
337
|
+
✔ 推送成功:1 个
|
|
338
|
+
✖ 推送失败:2 个
|
|
339
|
+
- CO-20001: 订单已推送(当前状态:已推送),不能重复推送,重复推送会产生重复物流单
|
|
340
|
+
- CO-20002: 未设置物流产品
|
|
341
|
+
|
|
342
|
+
缺渠道或寄件人时用 platform order update 补齐后重推;
|
|
343
|
+
已推送的订单不能重复推送(会产生重复物流单)。
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
> **已推送的订单会被后端按状态拒绝。**仅「待推送」「已合单」两种状态可推送;
|
|
347
|
+
> 已推送/标记出货/回写单号一律拒绝,因为重复推送会在下游建出**重复物流单且不可撤回**。
|
|
348
|
+
> 因此重试 push 是安全的:已成功的单不会被推第二次。
|
|
349
|
+
>
|
|
350
|
+
> 推送前用 `platform order list --status 0` 只取待推送的单,可以避免这类失败。
|
|
351
|
+
|
|
352
|
+
### `fmc platform order update`
|
|
353
|
+
|
|
354
|
+
| Field | Value |
|
|
355
|
+
| --- | --- |
|
|
356
|
+
| **Name** | `platform order update` |
|
|
357
|
+
| **Description** | 按ID批量更新平台订单(写操作)。可更新字段与界面『修改订单详情』一致,仅传入的字段被更新。典型用途:push 前补齐渠道(productCode)与寄件人(sender*)信息 |
|
|
358
|
+
| **Usage** | `fmc platform order update --ids <ids> [字段flags] [-y]` |
|
|
359
|
+
|
|
360
|
+
需要 API Key 认证。返回逐单成败清单:`updatedIds` 与 `failed`(含每单失败原因)。
|
|
361
|
+
|
|
362
|
+
#### Options(常用)
|
|
363
|
+
|
|
364
|
+
| Flag | Type | Required | Description |
|
|
365
|
+
| --- | --- | --- | --- |
|
|
366
|
+
| `--ids <ids>` | string | yes | 平台订单 ID,多个用逗号分隔 |
|
|
367
|
+
| `--product-code <v>` | string | no | 物流产品代码(渠道),不传不改 |
|
|
368
|
+
| `--product-name <v>` | string | no | 物流产品名称,不传不改 |
|
|
369
|
+
| `--sender-name <v>` | string | no | 寄件人姓名,不传不改 |
|
|
370
|
+
| `--sender-company <v>` | string | no | 寄件人公司,不传不改 |
|
|
371
|
+
| `--sender-telephone <v>` | string | no | 寄件人电话,不传不改 |
|
|
372
|
+
| `--sender-address <v>` | string | no | 寄件地址,不传不改 |
|
|
373
|
+
| `--sender-city <v>` | string | no | 寄件城市,不传不改 |
|
|
374
|
+
| `--sender-province <v>` | string | no | 寄件省/州,不传不改 |
|
|
375
|
+
| `--sender-postcode <v>` | string | no | 寄件邮编,不传不改 |
|
|
376
|
+
| `--receiver-name <v>` | string | no | 收件人姓名,不传不改 |
|
|
377
|
+
| `--phone-number <v>` | string | no | 收件人电话,不传不改 |
|
|
378
|
+
| `--address-line1 <v>` | string | no | 收件地址行1,不传不改 |
|
|
379
|
+
| `--city <v>` | string | no | 城市,不传不改 |
|
|
380
|
+
| `--country-code <v>` | string | no | 目的国家二字码,不传不改 |
|
|
381
|
+
| `--postal-code <v>` | string | no | 邮编,不传不改 |
|
|
382
|
+
| `--weight <v>` | string | no | 重量(kg),不传不改 |
|
|
383
|
+
| `--ioss <v>` | string | no | IOSS号(欧盟),不传不改 |
|
|
384
|
+
| `--vat-no <v>` | string | no | VAT税号,不传不改 |
|
|
385
|
+
| `-y, --yes` | boolean | no | 跳过交互确认(非交互环境必传) |
|
|
386
|
+
|
|
387
|
+
> 完整可更新字段与界面『修改订单详情』白名单一致(另含 buyer*/county/country-name/state-or-province/address-line2/tariffno/eori/currency/has-battery/returnsign/单号类等),`--help` 可见全部。
|
|
388
|
+
|
|
389
|
+
#### Examples
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
# push 前批量补渠道 + 寄件人
|
|
393
|
+
fmc platform order update --ids 20001,20002 --product-code A65 --sender-name "深圳仓" --sender-postcode 518000 -y
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
#### Output (text mode)
|
|
397
|
+
|
|
315
398
|
```
|
|
316
|
-
✔
|
|
399
|
+
✔ 更新成功:2 个
|
|
317
400
|
```
|