补充一些通知
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m7s

This commit is contained in:
2026-07-28 15:50:12 +08:00
parent 9303af3d46
commit 1fee19feeb
12 changed files with 151 additions and 27 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"strconv"
notificationapp "github.com/break/junhong_cmp_fiber/internal/application/notification"
walletapp "github.com/break/junhong_cmp_fiber/internal/application/wallet"
"github.com/break/junhong_cmp_fiber/internal/infrastructure/messaging/outbox"
"github.com/break/junhong_cmp_fiber/pkg/constants"
@@ -33,5 +34,22 @@ func (w *CreditEventWriter) Append(ctx context.Context, tx *gorm.DB, event walle
ResourceType: event.ReferenceType, ResourceID: strconv.FormatUint(uint64(event.ReferenceID), 10),
BusinessKey: event.EventID, RequestID: event.RequestID, CorrelationID: event.CorrelationID, Payload: event,
})
if err != nil || event.ReferenceType != constants.ReferenceTypeTopup || event.TransactionType != constants.AgentTransactionTypeRecharge {
return err
}
rechargeID := strconv.FormatUint(uint64(event.ReferenceID), 10)
notificationEventID := "agent-recharge:" + rechargeID + ":completed"
_, err = w.outbox.AppendIdempotent(ctx, tx, outbox.Envelope{
EventID: notificationEventID, EventType: constants.OutboxEventTypeAdminDynamicNotification,
PayloadVersion: constants.NotificationPayloadVersionV1,
AggregateType: "agent_recharge", AggregateID: rechargeID,
ResourceType: constants.NotificationRefTypeAgentRecharge, ResourceID: rechargeID,
BusinessKey: notificationEventID, RequestID: event.RequestID, CorrelationID: event.CorrelationID,
Payload: notificationapp.AdminDynamicPayload{
TargetKind: constants.NotificationTargetKindShop, TargetID: event.ShopID,
NotificationType: constants.NotificationTypeAgentRechargeCompleted, TemplateData: map[string]string{},
RefType: constants.NotificationRefTypeAgentRecharge, RefID: rechargeID,
},
})
return err
}