阶段七:完成 React Feature 化与前置重构收口
This commit is contained in:
1 parent
375e84d663
commit
1a228dc35c
305 files changed
+14179
-5431
No files matched your search
@@ -8,12 +8,25 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
accountmanager "xianyu-go/internal/account"
|
||||
orderapp "xianyu-go/internal/application/orders"
|
||||
"xianyu-go/internal/db"
|
||||
"xianyu-go/internal/xianyu/cookierefresh"
|
||||
"xianyu-go/internal/xianyu/mtop"
|
||||
)
|
||||
|
||||
// OrderAutomation 定义订单手动发货所需的最小自动化能力,避免订单适配器依赖具体 Center 类型。
|
||||
type OrderAutomation interface {
|
||||
// ManualFullDelivery 执行一次订单完整发货并返回实际发送数量。
|
||||
ManualFullDelivery(context.Context, *db.Order) (int, error)
|
||||
}
|
||||
|
||||
// OrderNotifier 定义订单发货结果所需的最小通知能力,通知实现不进入订单应用层。
|
||||
type OrderNotifier interface {
|
||||
// NotifyDelivery 发送订单发货结果通知。
|
||||
NotifyDelivery(string, string, string, string, string, string)
|
||||
}
|
||||
|
||||
// orderDetailMTop 是订单运行时需要的可选详情接口能力。
|
||||
type orderDetailMTop interface {
|
||||
// FetchOrderDetail 请求订单详情并返回平台响应中的订单字段。
|
||||
@@ -42,6 +55,29 @@ type OrderRuntimeHooks struct {
|
||||
ReportPersistenceFailure func(string, error)
|
||||
}
|
||||
|
||||
// NewOrderRuntimeHooks 将账号、自动化和通知依赖转换为订单运行时回调;闭包只存在于 adapter 装配边界。
|
||||
func NewOrderRuntimeHooks(client func() mtop.Client, manager *accountmanager.Manager, automation OrderAutomation, notifier OrderNotifier, updateCookie func(context.Context, string, string), recoverSession func(context.Context, string, error) bool) OrderRuntimeHooks {
|
||||
return OrderRuntimeHooks{
|
||||
Client: client,
|
||||
ClientAvailable: func() bool { return client != nil && client() != nil },
|
||||
AccountRunning: AccountRunningLookup(manager),
|
||||
AutomationReady: func() bool { return manager != nil && automation != nil },
|
||||
ManualFullDelivery: func(ctx context.Context, order *orderapp.Order) (int, error) {
|
||||
if automation == nil {
|
||||
return 0, errors.New("自动化中心未初始化")
|
||||
}
|
||||
return automation.ManualFullDelivery(ctx, OrderForAutomation(order))
|
||||
},
|
||||
UpdateRunningCookie: updateCookie,
|
||||
NotifyDelivery: func(cookieID, buyerID, itemID, chatID, message string) {
|
||||
if notifier != nil {
|
||||
notifier.NotifyDelivery(cookieID, "", buyerID, itemID, message, chatID)
|
||||
}
|
||||
},
|
||||
RecoverExpiredSession: recoverSession,
|
||||
}
|
||||
}
|
||||
|
||||
// OrderRuntime 将订单应用 Port 适配到数据库凭证、MTOP 和账号运行时。
|
||||
type OrderRuntime struct {
|
||||
// store 提供订单确认发货所需的平台凭证读取和 Cookie 写回能力。
|
||||
|
||||
Reference in new issue
Block a user