fix: 部分收付累计释额并扩展结算 E2E 与 CI
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
lotterLaravel E2E / e2e-api (push) Has been cancelled

账期收付改为按累计已付同步 credit_ledger,修复多笔 partial_paid 与坏账核销重复释额;新增 API E2E(占成、权限、部分收付/坏账)与 GitHub Actions e2e-api job。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-22 09:48:01 +08:00
parent 6ec9634704
commit 3f29229499
23 changed files with 1251 additions and 111 deletions

View File

@@ -6,7 +6,7 @@
# 4. php artisan serve 起应用
# 5. 启动 queue:work异步开奖/广播)
# 6. 启动 reverb:start
# 7. npx playwright install chromium首次
# 7. npx playwright install chromium仅缺浏览器缓存时
# 8. npx playwright test
# 9. 失败时打 docker logs + Laravel 日志;结束时清理 compose
@@ -49,6 +49,24 @@ require php
require node
require npx
playwright_cache_dir() {
case "$(uname -s)" in
Darwin) echo "$HOME/Library/Caches/ms-playwright" ;;
Linux) echo "${XDG_CACHE_HOME:-$HOME/.cache}/ms-playwright" ;;
MINGW*|MSYS*|CYGWIN*) echo "${LOCALAPPDATA:-$HOME/AppData/Local}/ms-playwright" ;;
*) echo "${XDG_CACHE_HOME:-$HOME/.cache}/ms-playwright" ;;
esac
}
playwright_chromium_cached() {
local cache_dir
cache_dir="$(playwright_cache_dir)"
# UI 项目依赖 chromium_headless_shellAPI 仅 request 时可能不触发,但一并检测。
compgen -G "${cache_dir}/chromium-"* >/dev/null 2>&1 \
|| compgen -G "${cache_dir}/chromium_headless_shell-"* >/dev/null 2>&1 \
|| [[ -d "$E2E_DIR/node_modules/playwright-core/.local-browsers" ]]
}
echo "==> [1/8] docker compose up -d"
if ! docker image inspect postgres:16-alpine >/dev/null 2>&1 \
|| ! docker image inspect redis:7-alpine >/dev/null 2>&1; then
@@ -224,22 +242,31 @@ cd "$E2E_DIR"
if [[ ! -d node_modules ]]; then
npm install
fi
if [[ ! -d node_modules/@playwright/test/.local-browsers ]]; then
npx playwright install chromium
# UI 默认 channel:chrome本机 Google Chrome仅显式要求 bundled 时才下载 ms-playwright Chromium。
if [[ "${PLAYWRIGHT_USE_BUNDLED_CHROMIUM:-0}" == "1" ]]; then
if ! playwright_chromium_cached; then
export PLAYWRIGHT_BROWSERS_PATH="${PLAYWRIGHT_BROWSERS_PATH:-$(playwright_cache_dir)}"
npx playwright install chromium
else
export PLAYWRIGHT_BROWSERS_PATH="${PLAYWRIGHT_BROWSERS_PATH:-$(playwright_cache_dir)}"
fi
fi
PLAYWRIGHT_JWT_SECRET=$(grep '^LOTTERY_NATIVE_JWT_SECRET=' "$ENV_FILE" | cut -d= -f2-) \
PLAYWRIGHT_API_URL="$API_URL" \
PLAYWRIGHT_ADMIN_URL="http://localhost:3801" \
PLAYWRIGHT_FRONT_URL="http://localhost:3800" \
REVERB_APP_KEY=$(grep '^REVERB_APP_KEY=' "$ENV_FILE" | cut -d= -f2-) \
REVERB_HOST=127.0.0.1 \
REVERB_PORT=8080 \
E2E_MOCK_WALLET_PORT=5555 \
E2E_ADMIN_USERNAME=admin \
E2E_ADMIN_PASSWORD=12345678 \
E2E_PLAYER_USERNAME=$(grep '^E2E_PLAYER_USERNAME=' "$ENV_E2E" | cut -d= -f2-) \
E2E_PLAYER_PASSWORD=$(grep '^E2E_PLAYER_PASSWORD=' "$ENV_E2E" | cut -d= -f2-) \
export PLAYWRIGHT_JWT_SECRET="$(grep '^LOTTERY_NATIVE_JWT_SECRET=' "$ENV_FILE" | cut -d= -f2-)"
export PLAYWRIGHT_API_URL="$API_URL"
export PLAYWRIGHT_ADMIN_URL="http://localhost:3801"
export PLAYWRIGHT_FRONT_URL="http://localhost:3800"
export REVERB_APP_KEY="$(grep '^REVERB_APP_KEY=' "$ENV_FILE" | cut -d= -f2-)"
export REVERB_HOST=127.0.0.1
export REVERB_PORT=8080
export E2E_MOCK_WALLET_PORT=5555
export E2E_ADMIN_USERNAME=admin
export E2E_ADMIN_PASSWORD=12345678
export E2E_PLAYER_USERNAME="$(grep '^E2E_PLAYER_USERNAME=' "$ENV_E2E" | cut -d= -f2-)"
export E2E_PLAYER_PASSWORD="$(grep '^E2E_PLAYER_PASSWORD=' "$ENV_E2E" | cut -d= -f2-)"
if [[ "${E2E_UI:-1}" != "1" ]]; then
set -- --project=api "$@"
fi
npx playwright test "$@"
rc=$?