- 重新设计支付页面UI,采用毛玻璃效果和动态背景- 更新支付接口调用方式,从表单提交改为JSON请求 -优化支付签名验证逻辑,统一错误处理方式 - 修改京东支付接口参数和返回结构体 - 移除OpenTelemetry追踪相关代码 - 添加支付倒计时功能和本地存储支持 - 优化支付按钮加载状态和交互反馈 - 调整HTML结构和CSS样式,提升用户体验
59 lines
2.8 KiB
Markdown
59 lines
2.8 KiB
Markdown
kami_shop
|
|
|
|
Development commands
|
|
|
|
- Build (Linux amd64): ./build.sh
|
|
- Run (dev): go run main.go
|
|
- Tests: go test ./...
|
|
- Single test file: go test ./internal/service/scan_shop_test.go
|
|
- Verbose tests: go test -v ./...
|
|
- Docker build: docker build -t kami_shop . -f deploy/Dockerfile
|
|
- Docker Compose up: export VERSION=latest && docker-compose -f deploy/docker-compose.yaml up -d
|
|
|
|
Project architecture overview
|
|
|
|
- Runtime: Go 1.24, Beego v2
|
|
- Entry: main.go initializes OpenTelemetry/logging and starts Beego
|
|
- Config: conf/app.local.conf (dev), conf/app.conf (prod); MySQL, Redis, ports, gateway URLs, secrets
|
|
- HTTP routing: internal/routers/router.go maps routes to controllers
|
|
- Controllers: internal/controllers/ handle payment endpoints (HTML and JSON flows)
|
|
- Services: internal/service/ business logic; payment orchestration and external calls
|
|
- Models: internal/models/ data structures and DB ops
|
|
- Views/static: views/ templates and static assets for payment pages
|
|
- Trace/log: internal/traceRouter provides OTEL setup, context propagation, and zap logger
|
|
- Deploy: deploy/Dockerfile, docker-compose*.yaml; .drone.yml for CI image build and remote compose deploy
|
|
|
|
Key flows
|
|
|
|
- Web pay (GET/HTML): /pay.html → PayController.Pay validates params, decrypts sign, checks timeout/keys, builds exValue, calls ScanShopController.Shop, redirects to /order-confirm.html or /error.html
|
|
- API pay (form): POST /pay → PayWithJson parses params, VerifyPaySign, service.Pay, JSON response
|
|
- API pay v2 (JSON): POST /api/pay → PayV2 JSON body, VerifyPaySign, ScanShopController.Shop, returns redirectUrl for client navigation
|
|
- JD native: POST /order/pay/original/jd → PayOriginalJD validates OriginalJdReq, VerifyPaySign, service.PayWithJd, returns wxPay
|
|
|
|
Configuration essentials
|
|
|
|
- MySQL: dev juhe_pay, prod kami; credentials/hosts in conf/*.conf
|
|
- Redis: dev localhost:6379, prod redis:6379
|
|
- Gateways: gateway/partial endpoints in conf/*.conf
|
|
- Secrets: [secret] key/iv used for encryption/sign; do not commit real secrets
|
|
|
|
Observability/logging
|
|
|
|
- traceRouter.InitTracer sets OTLP exporters (traces noop by default), metrics/log exporters, zap logger bridged via otelzap
|
|
- Middleware utilities for context propagation and CreateSpan helpers; Logger.WithContext to include trace_id
|
|
|
|
CI/CD
|
|
|
|
- .drone.yml builds and pushes image to git.oceanpay.cc and runs remote docker compose with BRANCH/DRONE vars
|
|
|
|
Local tips
|
|
|
|
- Windows binary main.exe present; prefer go run main.go during development
|
|
- build.sh compiles static Linux binary for container use
|
|
|
|
Important repository rules from CLAUDE.md
|
|
|
|
- Use provided dev commands for build/run/test
|
|
- Respect architecture boundaries: controllers → services → models; keep validation in controllers, business in services, persistence in models
|
|
- Prefer JSON API (/api/pay) for programmatic integrations; HTML endpoints for browser flows
|