Files
platforms/backend/api/internal/models/payment_refund.go

46 lines
4.3 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package models
import (
"time"
"git.apinb.com/bsm-sdk/core/database"
)
// PaymentRefund 对应 payment_refund保存用户发起、财务审核并退入钱包的退款申请。
type PaymentRefund struct {
Entity // 公共实体字段
RefundStatus int `gorm:"column:refund_status;not null;default:10;index" json:"refund_status"` // 10待审核、20已通过、30已驳回
PaymentOrderID uint64 `gorm:"column:payment_order_id;not null;index" json:"payment_order_id"` // 原支付单内部主键
WalletBasicID uint64 `gorm:"column:wallet_basic_id;not null;index" json:"wallet_basic_id"` // 入账钱包内部主键
RefundNo string `gorm:"column:refund_no;type:varchar(64);not null;uniqueIndex" json:"refund_no"` // 平台退款单号
RequestNo string `gorm:"column:request_no;type:varchar(128);not null;uniqueIndex:idx_refund_request" json:"request_no"` // 用户端幂等号
BusinessType string `gorm:"column:business_type;type:varchar(32);not null;index" json:"business_type"` // 原业务类型
BusinessIdentity string `gorm:"column:business_identity;type:varchar(36);not null;index" json:"business_identity"` // 原业务标识
UserIdentity string `gorm:"column:user_identity;type:varchar(36);not null;index;uniqueIndex:idx_refund_request" json:"user_identity"` // 申请用户标识
Amount int64 `gorm:"column:amount;not null;check:amount > 0" json:"amount"` // 核定退款金额,单位分
Reason string `gorm:"column:reason;type:varchar(256);not null" json:"reason"` // 用户退款原因
Description string `gorm:"column:description;type:text;not null;default:''" json:"description"` // 用户补充说明
ReviewRemark string `gorm:"column:review_remark;type:text;not null;default:''" json:"review_remark"` // 财务审核说明
ReviewerIdentity string `gorm:"column:reviewer_identity;type:varchar(36);not null;default:''" json:"reviewer_identity"` // 审核人标识
ReviewedAt *time.Time `gorm:"column:reviewed_at;type:timestamptz" json:"reviewed_at"` // 审核时间
CompletedAt *time.Time `gorm:"column:completed_at;type:timestamptz" json:"completed_at"` // 钱包入账完成时间
}
func init() { database.AppendMigrate(&PaymentRefund{}) }
func (*PaymentRefund) TableName() string { return "payment_refund" }
// PaymentRefundItem 对应 payment_refund_item保存退款订单项、数量和服务端核定金额。
type PaymentRefundItem struct {
ID uint64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` // 数据库自增主键
Identity string `gorm:"column:identity;type:varchar(36);not null;uniqueIndex" json:"identity"` // 对外退款明细标识
PaymentRefundID uint64 `gorm:"column:payment_refund_id;not null;index" json:"payment_refund_id"` // 退款申请内部主键
OrderItemIdentity string `gorm:"column:order_item_identity;type:varchar(36);not null;index" json:"order_item_identity"` // 原订单项标识
Quantity int `gorm:"column:quantity;not null;check:quantity > 0" json:"quantity"` // 退款数量
Amount int64 `gorm:"column:amount;not null;check:amount >= 0" json:"amount"` // 分摊退款金额,单位分
CreatedAt time.Time `gorm:"column:created_at;type:timestamptz;not null" json:"created_at"` // 创建时间
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamptz;not null" json:"updated_at"` // 更新时间
}
func init() { database.AppendMigrate(&PaymentRefundItem{}) }
func (*PaymentRefundItem) TableName() string { return "payment_refund_item" }