# Cin7 Sync — Python 版

## 目标
从 Cin7 API 同步商品（SPU/SKU）、分类、品牌、联系人（会员）到 RuoYi-Vue-Pro 数据库。

## 环境要求
```bash
pip install requests pymysql
```

## 数据库（从 docker-compose.yml 确认）
- Host: `127.0.0.1`
- Port: `3306`
- Database: `ruoyi-vue-pro`
- User: `root`
- Password: `123456`

## Cin7 API
- Base URL: `https://api.cin7.com/api`
- Auth: HTTP Basic (`username:password`)
- 硬编码凭证（测试用，正式需放入 config）:
  - Username: `ACATrading2AU`
  - Password: `56170787329040fe90a499b949d72961`

## 同步范围

| 模块 | API Endpoint | 说明 |
|------|-------------|------|
| 商品 | `/Products` | SPU + SKU + 图片 |
| 分类 | `/ProductCategories` | 两级分类 |
| 品牌 | `/Branches` + `/Brands` | Branch=公司名, Brand=品牌 |
| 联系人 | `/Contacts` | 只同步 Customer 类型 |

## 已知业务规则（来自 Java 代码分析）
1. **商品状态**: Channels == "Magento 2" → 上架，否则下架（客户要求）
2. **品牌**: 用 Branch.company 当品牌名，忽略 Supplier 类型的 Branch
3. **会员**: 只导入 ContactType == Customer，忽略 Supplier
4. **SKU 属性**: optionLabel1/2/3 → Color/Size/Printed

## 暂不处理（Java 版也未实现）
- 增量同步（无 modifiedSince）
- Google Maps 地址解析（已做但 Python 版简化）
