From 918b9b4f2542fe02bf4bb5aed798d6ba704fc91d Mon Sep 17 00:00:00 2001 From: Break Date: Mon, 1 Jun 2026 11:45:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E6=AC=BE=E4=B9=9F=E5=BA=94=E8=AF=A5?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=BF=AB=E7=85=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/service/refund/service.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/internal/service/refund/service.go b/internal/service/refund/service.go index 936087b..554fc2d 100644 --- a/internal/service/refund/service.go +++ b/internal/service/refund/service.go @@ -312,6 +312,7 @@ func (s *Service) refundAgentWalletPayment(ctx context.Context, tx *gorm.DB, ref refType := constants.ReferenceTypeRefund refID := refund.ID remark := fmt.Sprintf("订单%s退款退回预充值钱包", order.OrderNo) + assetType, assetID, assetIdentifier := buildRefundWalletTransactionAssetSnapshot(order) transaction := &model.AgentWalletTransaction{ AgentWalletID: wallet.ID, ShopID: wallet.ShopID, @@ -325,6 +326,9 @@ func (s *Service) refundAgentWalletPayment(ctx context.Context, tx *gorm.DB, ref ReferenceType: &refType, ReferenceID: &refID, RelatedShopID: relatedShopID, + AssetType: assetType, + AssetID: assetID, + AssetIdentifier: assetIdentifier, Remark: &remark, Creator: operatorID, ShopIDTag: wallet.ShopIDTag, @@ -965,3 +969,24 @@ func buildRefundResponse(r *model.RefundRequest) *dto.RefundResponse { return resp } + +// buildRefundWalletTransactionAssetSnapshot 从订单中生成退款流水的资产快照。 +func buildRefundWalletTransactionAssetSnapshot(order *model.Order) (string, uint, string) { + if order == nil { + return "", 0, "" + } + switch order.OrderType { + case model.OrderTypeSingleCard: + if order.IotCardID == nil { + return constants.AssetTypeIotCard, 0, order.AssetIdentifier + } + return constants.AssetTypeIotCard, *order.IotCardID, order.AssetIdentifier + case model.OrderTypeDevice: + if order.DeviceID == nil { + return constants.AssetTypeDevice, 0, order.AssetIdentifier + } + return constants.AssetTypeDevice, *order.DeviceID, order.AssetIdentifier + default: + return "", 0, order.AssetIdentifier + } +}