退款也应该记录快照
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user