# 电商自动化 **Repository Path**: tenpercentengineer/e-commerce-automation ## Basic Information - **Project Name**: 电商自动化 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-05 - **Last Updated**: 2026-03-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # WeChat + XHS Virtual Product Assistant V1.1 This project implements a lightweight dual-channel virtual product assistant: - XHS private message keyword intake and pay link delivery - WeChat payment callback handling - One-time questionnaire link delivery and access control ## Features - Receives payment callbacks at `POST /api/v1/webhooks/wechat/pay` - Receives XHS message events at `POST /api/v1/webhooks/xhs/messages` - Dispatches XHS note publishing at `POST /api/v1/xhs/publish/dispatch` - Verifies callback signatures with HMAC-SHA256 (mockable local implementation) - Generates one-time questionnaire links after successful payment - Delivers links through gateway abstractions with official-first and RPA fallback - Supports one-time access with expiry checks at `GET /api/v1/questionnaires/access/{token}` - Provides idempotent callback handling with unique constraints - Includes retention cleanup logic for 7-day log/event retention (including XHS tables) ## Tech Stack - Python 3.12 - FastAPI - SQLAlchemy 2 - SQLite - pytest (unit + integration markers) ## Quick Start ```bash python3 -m venv .venv source .venv/bin/activate pip install -e .[dev] uvicorn app.main:app --reload --app-dir src ``` ## Environment Variables Create `.env` in project root: ```bash APP_BASE_URL=http://localhost:8000 DATABASE_URL=sqlite:///./app.db WEBHOOK_SECRET=replace-with-secret XHS_WEBHOOK_SECRET=replace-with-secret TOKEN_HASH_SECRET=replace-with-secret TOKEN_TTL_HOURS=24 LOG_RETENTION_DAYS=7 ENABLE_SCHEDULER=true QUESTIONNAIRE_DEFAULT_URL=https://example.com/questionnaire/default QUESTIONNAIRE_MAP_JSON={"prod-1":"https://example.com/survey/q1"} WECHAT_PAY_ENTRY_URL=https://pay.example.com/checkout RECIPIENT_REF_ENC_KEY=replace-with-secret XHS_KEYWORD_MAP_JSON={"心理问卷":"prod-1"} XHS_DM_TEMPLATE=点击支付获取心理问卷:{pay_url} XHS_QUESTIONNAIRE_TEMPLATE=支付成功,问卷链接如下(一次有效):{access_url} XHS_ENABLE_RPA_FALLBACK=true XHS_DM_DAILY_LIMIT=50 XHS_DM_USER_COOLDOWN_SECONDS=600 XHS_NOTE_DAILY_LIMIT=6 XHS_CIRCUIT_BREAKER_FAILURE_THRESHOLD=3 XHS_CIRCUIT_BREAKER_OPEN_SECONDS=1800 ``` ## Run Tests ```bash pytest -m unit pytest -m integration pytest ``` ## Run Migration ```bash python3 scripts/migrate_v1_1.py ``` ## Real Environment Smoke The project includes a smoke script for manual callback simulation: ```bash chmod +x scripts/real_env_smoke.sh BASE_URL=http://localhost:8000 WEBHOOK_SECRET=your-secret ./scripts/real_env_smoke.sh ``` The script sends a signed payment callback and prints the API response.