ERP后端 PHP Laravel
Go to file
2026-04-01 17:07:04 +08:00
app Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
bootstrap Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
config Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
database Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
Modules/Ecommerce Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
public Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
resources Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
routes Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
storage Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
stubs/nwidart-stubs Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
tests Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
.editorconfig Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
.env.example Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
.gitattributes Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
.gitignore Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
API_DOCUMENTATION.md Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
artisan Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
COMPLETION_NOTICE.md Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
composer.json Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
composer.lock Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
create-test-user.php Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
FRONTEND_COMPLETE_NOTICE.md Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
modules_statuses.json Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
onDelete('cascade') Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
package.json Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
phpunit.xml Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
README.md Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
test_goods.php Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
test_login.php Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
test_orders.php Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
timestamps() Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
update_password.php Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
vite-module-loader.js Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00
vite.config.js Initial commit: ERP Backend baseline 2026-04-01 17:07:04 +08:00

ERP系统后端项目

项目状态

已完成模块:

  1. 采购单模块 (PurchaseOrderController)
  2. 收货单模块 (ReceivingOrderController)
  3. 模板模块 (TemplateController)
  4. 仓库模板绑定模块 (WarehouseTemplateBindingController)
  5. 订单模块 (OrderController)
  6. 店铺授权模块 (ShopAuthController)
  7. 平台商品模块 (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 - 获取授权URL
  • POST /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} - 删除商品

安装和运行

  1. 安装依赖:
composer install
  1. 配置环境:
cp .env.example .env
php artisan key:generate
  1. 运行迁移:
php artisan migrate
  1. 启动服务:
php artisan serve

测试

运行测试:

php artisan test

前端对接

后端开发已完成,前端可以开始对接以下接口:

  1. 店铺授权相关接口
  2. 平台商品管理接口
  3. 其他已完成的模块接口

详细API文档请参考: API_DOCUMENTATION.md

下一步开发

  1. 实现具体平台API集成
  2. 添加商品同步队列
  3. 实现订单同步功能
  4. 完善错误处理和监控

项目结构

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