收口订单运行时Port基础设施类型

This commit is contained in:
Christ committed 2026-08-15 16:39:53 +08:00
1 parent 5b30551694
commit c1c065e023
2 files changed
+11 -10

No files matched your search

@@ -746,3 +746,4 @@ npm --prefix frontend run build
| 2026-08-15 | P2 商品多规格跨请求缓存切片 | 已完成 | Server 新增按账号/商品隔离的 10 分钟 TTL 多规格缓存;同步成功结果(含 false)均缓存,后续同步命中缓存时跳过远端探测,过期项自动清理;新增缓存命中、过期和并发探测回归测试,注释门禁通过。跨实例共享缓存、主动失效通知、平台限流指标和 MySQL/Postgres 查询计划仍待完成,P2 批量同步保持“进行中” |
| 2026-08-15 | P2 订单复合游标索引与查询计划切片 | 已完成 | SQLite/MySQL/Postgres 新增 `idx_orders_cursor(cookie_id, deleted_at, created_at, order_id)` 复合索引;新增 SQLite `EXPLAIN QUERY PLAN` 回归,确认订单游标查询使用该索引;迁移、订单扫描和中文注释门禁通过。MySQL/Postgres 实际执行计划仍需外部数据库环境验证,P2 批量同步保持“进行中” |
| 2026-08-15 | P1 订单刷新持久化后台任务切片 | 已完成 | 新增 SQLite/MySQL/Postgres `order_refresh_jobs` 迁移及应用层 `RefreshJobRepository` Port;订单刷新 HTTP 端点改为 202 + 用户隔离的状态查询,后台 worker 受 Server 生命周期管理,使用 worker token/lease fencing,并提供过期任务恢复扫描;React 客户端改为可取消的状态轮询;新增任务生命周期、跨用户隔离、旧 worker 拒绝写入、成功/失败/取消和 HTTP/前端契约回归;Go 全量测试、架构/中文注释门禁、前端 317 测试、类型检查和生产构建通过。仍待补充取消端点、进度事件、MySQL/Postgres 实际任务迁移回归与统一运维查询,阶段 4/5/8/9 继续保持“进行中” |
| 2026-08-15 | P1 订单运行时 Port 基础设施类型收口切片 | 已完成 | `orderRuntimePort` 的完整自动化发货参数改为应用层 `orders.Order`,Cookie 会话持久化参数改为 `orders.PlatformRuntimeData`;`db.Order`/`db.CookieDetail` 转换下沉到 Server 装配适配器,业务服务不再通过运行时 Port 接触数据库模型;补充订单与平台视图边界转换回归,架构门禁、中文注释门禁和订单定向测试通过。订单应用服务实现仍位于 `internal/server`,Port 仍含平台协议接口,其他应用服务和基础设施适配器继续按后续切片迁移,阶段 4/8/9 保持“进行中” |
+10 -10
View File
@@ -22,7 +22,7 @@ type orderRuntimePort interface {
// AutomationReady 判断完整发货自动化依赖是否已装配。
AutomationReady() bool
// ManualFullDelivery 执行完整自动化发货。
ManualFullDelivery(ctx context.Context, order *db.Order) (int, error)
ManualFullDelivery(ctx context.Context, order *orderapp.Order) (int, error)
// MTopAvailable 判断平台客户端是否已注入。
MTopAvailable() bool
// MTopClient 返回平台客户端。
@@ -36,7 +36,7 @@ type orderRuntimePort interface {
// RecordOrderReconciliation 记录外部发货成功但本地状态未完成的补偿任务。
RecordOrderReconciliation(ctx context.Context, orderID, cookieID, kind, message string) (string, error)
// persistMTopCookieSessionLocked 持久化平台响应 Cookie Jar。
persistMTopCookieSessionLocked(ctx context.Context, detail *db.CookieDetail, session *mtop.CookieSession) (string, bool, bool, error)
persistMTopCookieSessionLocked(ctx context.Context, detail *orderapp.PlatformRuntimeData, session *mtop.CookieSession) (string, bool, bool, error)
// recoverExpiredMTOPSession 处理平台会话过期。
recoverExpiredMTOPSession(ctx context.Context, cookieID string, err error) bool
// discoverSoldOrders 拉取并同步账号已售订单索引。
@@ -73,11 +73,11 @@ func (a serverOrderRuntimeAdapter) AutomationReady() bool {
}
// ManualFullDelivery 执行完整自动化发货。
func (a serverOrderRuntimeAdapter) ManualFullDelivery(ctx context.Context, order *db.Order) (int, error) {
func (a serverOrderRuntimeAdapter) ManualFullDelivery(ctx context.Context, order *orderapp.Order) (int, error) {
if a.server == nil || a.server.automation == nil {
return 0, errors.New("自动化中心未初始化")
}
return a.server.automation.ManualFullDelivery(ctx, order)
return a.server.automation.ManualFullDelivery(ctx, orderForAutomation(order))
}
// MTopAvailable 判断平台客户端是否已注入。
@@ -117,8 +117,8 @@ func (a serverOrderRuntimeAdapter) RecordOrderReconciliation(ctx context.Context
}
// persistMTopCookieSessionLocked 持久化平台响应 Cookie Jar。
func (a serverOrderRuntimeAdapter) persistMTopCookieSessionLocked(ctx context.Context, detail *db.CookieDetail, session *mtop.CookieSession) (string, bool, bool, error) {
return a.server.persistMTopCookieSessionLocked(ctx, detail, session)
func (a serverOrderRuntimeAdapter) persistMTopCookieSessionLocked(ctx context.Context, detail *orderapp.PlatformRuntimeData, session *mtop.CookieSession) (string, bool, bool, error) {
return a.server.persistMTopCookieSessionLocked(ctx, cookieDetailForOrderPlatform(detail), session)
}
// recoverExpiredMTOPSession 处理平台会话过期。
@@ -681,7 +681,7 @@ func (a *orderApplicationService) manualFullDelivery(ctx context.Context, order
return
}
// sent、err 保存sent、err,供当前处理流程使用
sent, err := a.server.ManualFullDelivery(ctx, orderForAutomation(order))
sent, err := a.server.ManualFullDelivery(ctx, order)
if err != nil {
a.appendManualFailure(result, orderID, err.Error())
a.server.notifyDelivery(order.CookieID, order.BuyerID, order.ItemID, order.ChatID, "手动完整发货失败: "+err.Error())
@@ -805,7 +805,7 @@ func (a *orderApplicationService) RefreshSingle(ctx context.Context, userID int6
// runtimeCookieChanged 保存runtime登录凭证Changed,供当前处理流程使用
runtimeCookieChanged := false
// value、valueChanged、handled、persistErr 保存value、valueChanged、handled、persistErr,供当前处理流程使用
value, valueChanged, handled, persistErr := a.server.persistMTopCookieSessionLocked(ctx, latestDetail, cookieSession)
value, valueChanged, handled, persistErr := a.server.persistMTopCookieSessionLocked(ctx, latest, cookieSession)
if persistErr != nil {
callErr = errors.Join(callErr, fmt.Errorf("保存订单详情响应 Cookie Jar: %w", persistErr))
} else if handled && valueChanged {
@@ -899,7 +899,7 @@ func (a *orderApplicationService) Refresh(ctx context.Context, userID int64, coo
// value、valueChanged、persistErr 保存value、valueChanged、persistErr,供当前处理流程使用
value, valueChanged, _, persistErr := "", false, false, error(nil)
if reloadErr == nil && latestAfterDiscovery != nil && latestAfterDiscovery.UserID == userID && !credentialSnapshotChanged {
value, valueChanged, _, persistErr = a.server.persistMTopCookieSessionLocked(ctx, latestDetail, cookieSession)
value, valueChanged, _, persistErr = a.server.persistMTopCookieSessionLocked(ctx, latest, cookieSession)
}
if persistErr != nil {
discoveryErr = errors.Join(discoveryErr, fmt.Errorf("保存订单列表响应 Cookie Jar: %w", persistErr))
@@ -1132,7 +1132,7 @@ func (a *orderApplicationService) Refresh(ctx context.Context, userID int64, coo
// value、valueChanged、persistErr 保存value、valueChanged、persistErr,供当前处理流程使用
value, valueChanged, _, persistErr := "", false, false, error(nil)
if !credentialSnapshotChanged {
value, valueChanged, _, persistErr = a.server.persistMTopCookieSessionLocked(ctx, latestDetail, cookieSession)
value, valueChanged, _, persistErr = a.server.persistMTopCookieSessionLocked(ctx, latest, cookieSession)
}
credentialUnlock()
if detailsReloadErr != nil {