Files
douba_shop/聚水潭商品拉取测试报告.md
Karlcarlo c7f85ffbda feat: 添加阿里云短信服务支持并优化验证码逻辑
- 引入 alibabacloud/dysmsapi-20170525 依赖,集成阿里云短信服务
- 将短信验证码从6位改为4位,优化用户体验
- 添加聚水潭商品按时间范围同步功能,支持分页拉取
- 增强Cron任务异常处理,添加错误日志记录
- 修复系统附件服务中图片路径处理逻辑
- 更新阿里云SDK相关组件至最新版本
- 添加think-trace调试扩展,便于问题排查
- 优化跨域中间件,使用str_contains替代strpos
2026-04-30 15:19:40 +08:00

160 lines
3.5 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 聚水潭商品拉取接口测试报告
## 测试时间
2026-04-02
## 测试结果
### ✅ 接口可正常调用
通过测试脚本 `test_haichao.php` 验证,聚水潭按SPU拉取商品接口 **可以正常调用**。
### ❌ Access Token 问题
测试过程中遇到错误:
```
验证失败!无效的access_token或access_token已过期
```
这说明接口调用链路是通的,但需要在后台完成聚水潭授权配置。
---
## 测试脚本说明
我已创建了测试脚本,您可以用于验证接口功能:
### 使用方法
```bash
cd /home/jone/workspace/CRMEB_PRO
# 测试1: 不带参数,自动获取示例数据
php test_haichao.php
# 测试2: 带SPU参数,查询指定商品
php test_haichao.php 你的SPU编码
```
### 脚本文件
- `test_haichao.php` - 主测试脚本
---
## 聚水潭配置检查清单
在测试接口之前,请确保完成以下配置:
### 1️⃣ 开启ERP功能
后台路径:`系统设置 → ERP配置 → 开启ERP功能`
### 2️⃣ 配置聚水潭应用密钥
需要配置以下参数:
- `jst_appkey` - 聚水潭应用Key
- `jst_appsecret` - 聚水潭应用Secret
- `jst_login_account` - 聚水潭登录账号
- `jst_login_password` - 聚水潭登录密码
### 3️⃣ 完成OAuth授权
授权地址:`https://openweb.jushuitan.com/auth`
授权后系统会自动获取并缓存 Access Token。
---
## 接口调用说明
### 按SPU拉取商品
**方法1: HaichaoJstServices**
```php
$haichaoJst = \app\haichao\HaichaoJstServices::getServices();
$result = $haichaoJst->getProductListKuan($spu);
```
**API**: `/open/mall/item/query`
- 参数: `i_ids` - SPU ID数组
- 返回: 商品详情包含SKU列表
### 其他可用方法
| 方法 | 说明 | API |
|------|------|-----|
| `getProductListShop($key)` | 按店铺拉取 | `/open/skumap/query` |
| `getProductListName($key)` | 按名称查询 | `/open/sku/query` |
| `getProductListKuan($key)` | 按SPU拉取 | `/open/mall/item/query` |
| `getProductListStand()` | 拉取标准商品 | `/open/mall/item/query` |
| `getProductList()` | 全量拉取(分页) | `/open/mall/item/query` |
---
## 返回数据结构
成功的响应示例:
```json
{
"code": 0,
"msg": "success",
"datas": [
{
"i_id": "SPU001",
"name": "商品名称",
"s_price": 99.00,
"market_price": 199.00,
"c_price": 50.00,
"pic": "http://xxx.jpg",
"skus": [
{
"sku_id": "SKU001",
"properties_value": "红色/L",
"sale_price": 99.00,
"market_price": 199.00,
"cost_price": 50.00
}
]
}
]
}
```
---
## 故障排查
### 问题1: Access Token过期
**错误**: `无效的access_token或access_token已过期`
**解决方案**:
1. 清除缓存的Token
2. 重新进行OAuth授权
3. 检查系统时间是否正确
### 问题2: 配置未保存
**错误**: `JST config missing`
**解决方案**:
1. 检查后台ERP配置是否保存
2. 确认配置参数不为空
### 问题3: 网络问题
**错误**: `cURL error 7` 或连接超时
**解决方案**:
1. 检查服务器网络连接
2. 确认防火墙允许访问 `openapi.jushuitan.com`
---
## 下一步操作
1. 完成聚水潭授权配置
2. 重新运行测试脚本验证
3. 如需指定SPU商品,请提供有效的SPU编码
---
## 相关文件
- 测试脚本: `/home/jone/workspace/CRMEB_PRO/test_haichao.php`
- 核心服务: `/home/jone/workspace/CRMEB_PRO/app/haichao/HaichaoJstServices.php`
- 商品同步: `/home/jone/workspace/CRMEB_PRO/app/haichao/sync/JstProductSync.php`