ERP后端 PHP Laravel
| app | ||
| bootstrap | ||
| config | ||
| database | ||
| Modules/Ecommerce | ||
| public | ||
| resources | ||
| routes | ||
| storage | ||
| stubs/nwidart-stubs | ||
| test_module | ||
| tests | ||
| .editorconfig | ||
| .env.example | ||
| .gitattributes | ||
| .gitignore | ||
| API_DOCUMENTATION.md | ||
| artisan | ||
| COMPLETION_NOTICE.md | ||
| composer.json | ||
| composer.lock | ||
| create-test-user.php | ||
| FRONTEND_COMPLETE_NOTICE.md | ||
| modules_statuses.json | ||
| onDelete('cascade') | ||
| package.json | ||
| phpunit.xml | ||
| README.md | ||
| TASK-TASK-TEST.md | ||
| test_goods.php | ||
| test_login.php | ||
| test_orders.php | ||
| timestamps() | ||
| update_password.php | ||
| vite-module-loader.js | ||
| vite.config.js | ||
ERP系统后端项目
项目状态
✅ 已完成模块:
- 采购单模块 (PurchaseOrderController)
- 收货单模块 (ReceivingOrderController)
- 模板模块 (TemplateController)
- 仓库模板绑定模块 (WarehouseTemplateBindingController)
- 订单模块 (OrderController)
- 店铺授权模块 (ShopAuthController)
- 平台商品模块 (PlatformController)
新增模块详情
店铺授权模块 (ShopAuthController)
- 支持多平台授权 (淘宝、天猫、京东、拼多多、抖音)
- 完整的OAuth2授权流程
- 令牌管理和刷新机制
- 店铺信息管理
平台商品模块 (PlatformController)
- 平台商品数据同步
- 商品信息管理
- 批量操作支持
- 同步状态跟踪
- 统计功能
数据库结构
店铺授权表 (shop_auths)
CREATE TABLE shop_auths (
id INT PRIMARY KEY AUTO_INCREMENT,
platform VARCHAR(50) NOT NULL,
shop_name VARCHAR(255) NOT NULL,
access_token TEXT NOT NULL,
refresh_token TEXT,
expires_at DATETIME,
status VARCHAR(50) DEFAULT 'active',
config JSON,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
平台商品表 (platforms)
CREATE TABLE platforms (
id INT PRIMARY KEY AUTO_INCREMENT,
shop_auth_id INT NOT NULL,
platform_product_id VARCHAR(100) NOT NULL,
platform_sku_id VARCHAR(100),
title VARCHAR(200) NOT NULL,
description TEXT,
price DECIMAL(10,2) NOT NULL,
original_price DECIMAL(10,2),
stock INT DEFAULT 0,
sold INT DEFAULT 0,
images JSON,
specs JSON,
status ENUM('on_sale', 'off_sale', 'deleted') DEFAULT 'on_sale',
sync_status ENUM('pending', 'syncing', 'synced', 'failed') DEFAULT 'pending',
last_sync_at DATETIME,
sync_error TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (shop_auth_id) REFERENCES shop_auths(id) ON DELETE CASCADE,
INDEX idx_shop_product (shop_auth_id, platform_product_id),
INDEX idx_sync_status (sync_status),
INDEX idx_status (status)
);
API接口
店铺授权模块
GET /api/shops- 店铺列表GET /api/shops/platforms- 支持的平台POST /api/shops/auth-url- 获取授权URLPOST /api/shops/callback- 授权回调GET /api/shops/{id}- 店铺详情POST /api/shops/{id}/refresh- 刷新令牌DELETE /api/shops/{id}- 删除授权
平台商品模块
GET /api/platforms- 商品列表POST /api/platforms- 创建商品GET /api/platforms/stats- 统计信息POST /api/platforms/sync- 同步商品POST /api/platforms/batch-update- 批量更新GET /api/platforms/{id}- 商品详情PUT /api/platforms/{id}- 更新商品DELETE /api/platforms/{id}- 删除商品
安装和运行
- 安装依赖:
composer install
- 配置环境:
cp .env.example .env
php artisan key:generate
- 运行迁移:
php artisan migrate
- 启动服务:
php artisan serve
测试
运行测试:
php artisan test
前端对接
后端开发已完成,前端可以开始对接以下接口:
- 店铺授权相关接口
- 平台商品管理接口
- 其他已完成的模块接口
详细API文档请参考: API_DOCUMENTATION.md
下一步开发
- 实现具体平台API集成
- 添加商品同步队列
- 实现订单同步功能
- 完善错误处理和监控
项目结构
erp-backend/
├── app/
│ ├── Http/
│ │ └── Controllers/
│ │ ├── ShopAuthController.php
│ │ └── PlatformController.php
│ └── Models/
│ ├── ShopAuth.php
│ └── Platform.php
├── database/
│ └── migrations/
│ ├── create_shop_auths_table.php
│ └── create_platforms_table.php
├── routes/
│ └── api.php
├── tests/
│ └── ModulesTest.php
├── API_DOCUMENTATION.md
└── README.md