# product +type-count

> **前置条件：** 先阅读 [`../../cai-shared/SKILL.md`](../../cai-shared/SKILL.md) 了解认证、全局参数和安全规则。

获取各状态商品的数量统计。用于快速了解店铺整体商品分布情况。

## 命令

```bash
# 默认统计四种主要状态
cai-cli product +type-count

# 只统计在售和草稿
cai-cli product +type-count --types "online,draft"

# 统计所有支持的状态
cai-cli product +type-count --types "online,soldout,draft,deleted,rejected,ban,auditing,auditpassed"
```

## 通用 API 调用（备用）

```bash
cai-cli api GET /gcli/cliapi/goods/typecountlist \
  --params '{"types":"online,soldout,draft,deleted"}'
```

## 参数

| Flag | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| `--types` | string | `online,soldout,draft,deleted` | 逗号分隔的状态列表 |

### 支持的状态值

| 值 | 说明 |
|----|------|
| `online` | 在售 |
| `soldout` | 售罄 |
| `draft` | 草稿 |
| `deleted` | 已删除 |
| `rejected` | 审核驳回 |
| `constFail` | 审核失败 |
| `ban` | 违规下架 |
| `auditing` | 审核中 |
| `auditpassed` | 审核通过（待发布）|
| `auditappealing` | 申诉中 |

## 响应字段（`data` 对象）

`data` 为平铺的 map，key 为状态名称，value 为对应数量。只返回 `--types` 中指定的状态。

```json
{
  "online": 42,
  "soldout": 5,
  "draft": 12,
  "deleted": 3
}
```

## jq 使用示例

```bash
# 查看在售数量
cai-cli product +type-count --jq '.online'

# 查看所有统计结果
cai-cli product +type-count --jq 'to_entries | map({状态: .key, 数量: .value})'
```

## 风险等级

`read`（只读，不修改任何数据）

## 参考

- [cai-product](../SKILL.md) — 商品管理全部命令
- [cai-shared](../../cai-shared/SKILL.md) — 认证和全局参数
