七月迭代短暂完结,还有很多后端的关键东西没有弄,这是一版赶时间做的东西
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m26s

This commit is contained in:
2026-07-25 17:06:58 +08:00
parent ad9f613dd6
commit 73f5125d3d
249 changed files with 17137 additions and 877 deletions

View File

@@ -0,0 +1,49 @@
// Package exchange 提供换货用例的可靠通知编排。
package exchange
import (
"context"
"gorm.io/gorm"
"github.com/break/junhong_cmp_fiber/pkg/errors"
)
// ShippingCreatedEvent 是物流换货单创建后通知个人客户的稳定业务事件。
type ShippingCreatedEvent struct {
ExchangeID uint
ExchangeNo string
CustomerID uint
AssetType string
AssetID uint
AssetIdentifier string
RequestID string
CorrelationID string
}
// ShippingCreatedEventWriter 将物流换货创建通知写入可靠事件基础设施。
type ShippingCreatedEventWriter interface {
Append(ctx context.Context, tx *gorm.DB, event ShippingCreatedEvent) error
}
// ShippingCreatedNotifier 在换货业务事务内编排个人客户通知事件。
type ShippingCreatedNotifier struct {
writer ShippingCreatedEventWriter
}
// NewShippingCreatedNotifier 创建物流换货通知用例。
func NewShippingCreatedNotifier(writer ShippingCreatedEventWriter) *ShippingCreatedNotifier {
return &ShippingCreatedNotifier{writer: writer}
}
// Notify 在换货单事务内追加指定个人客户的可靠通知事件。
func (n *ShippingCreatedNotifier) Notify(ctx context.Context, tx *gorm.DB, event ShippingCreatedEvent) error {
if n == nil || n.writer == nil {
return errors.New(errors.CodeInternalError, "物流换货通知事件 Writer 未配置")
}
if tx == nil || event.ExchangeID == 0 || event.ExchangeNo == "" || event.CustomerID == 0 ||
event.AssetType == "" || event.AssetID == 0 || event.AssetIdentifier == "" {
return errors.New(errors.CodeInvalidParam, "物流换货通知事件参数不完整")
}
return n.writer.Append(ctx, tx, event)
}