Files
junhong_cmp_fiber/internal/model/refund.go
huang 95fc0b0a1b
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m16s
修复一些问题,主要是生效套餐
2026-05-12 10:32:38 +08:00

60 lines
3.5 KiB
Go
Raw 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 model
import (
"time"
"gorm.io/gorm"
)
// RefundRequest 退款申请模型
// 记录退款申请的完整生命周期,包含退款单号、关联订单、金额、状态流转、审批信息等
// 状态流转1(待审批) → 2(已通过)/3(已拒绝)/4(已退回)4(已退回) → 1(待审批)
type RefundRequest struct {
gorm.Model
BaseModel `gorm:"embedded"`
// 退款单基础信息
RefundNo string `gorm:"column:refund_no;type:varchar(50);uniqueIndex:idx_refund_request_refund_no,where:deleted_at IS NULL;not null;comment:退款单号RF+日期时间+6位随机数" json:"refund_no"`
OrderID uint `gorm:"column:order_id;index;not null;comment:关联订单ID" json:"order_id"`
OrderNo string `gorm:"column:order_no;type:varchar(30);not null;default:'';comment:关联订单号快照" json:"order_no"`
OrderType string `gorm:"column:order_type;type:varchar(20);not null;default:'';comment:订单类型快照single_card/device" json:"order_type,omitempty"`
AssetIdentifier string `gorm:"column:asset_identifier;type:varchar(100);not null;default:'';comment:下单时资产标识符快照ICCID 或 VirtualNo" json:"asset_identifier,omitempty"`
IotCardID *uint `gorm:"column:iot_card_id;comment:下单时IoT卡ID快照" json:"iot_card_id,omitempty"`
DeviceID *uint `gorm:"column:device_id;comment:下单时设备ID快照" json:"device_id,omitempty"`
PackageUsageID *uint `gorm:"column:package_usage_id;comment:关联套餐使用记录ID可选" json:"package_usage_id,omitempty"`
ShopID *uint `gorm:"column:shop_id;index;comment:店铺ID从订单获取用于数据权限过滤" json:"shop_id,omitempty"`
ShopName string `gorm:"column:shop_name;->" json:"shop_name,omitempty"`
// 金额信息
ActualReceivedAmount int64 `gorm:"column:actual_received_amount;type:bigint;not null;comment:实收金额(分)" json:"actual_received_amount"`
RequestedRefundAmount int64 `gorm:"column:requested_refund_amount;type:bigint;not null;comment:申请退款金额(分)" json:"requested_refund_amount"`
ApprovedRefundAmount *int64 `gorm:"column:approved_refund_amount;type:bigint;comment:审批实际退款金额(分)" json:"approved_refund_amount,omitempty"`
// 退款原因和状态
RefundReason string `gorm:"column:refund_reason;type:text;comment:退款原因" json:"refund_reason"`
Status int `gorm:"column:status;type:int;not null;default:1;index;comment:状态 1-待审批 2-已通过 3-已拒绝 4-已退回" json:"status"`
// 审批信息
ProcessorID *uint `gorm:"column:processor_id;comment:审批人ID" json:"processor_id,omitempty"`
ProcessedAt *time.Time `gorm:"column:processed_at;comment:审批时间" json:"processed_at,omitempty"`
RejectReason string `gorm:"column:reject_reason;type:text;comment:拒绝原因" json:"reject_reason,omitempty"`
Remark string `gorm:"column:remark;type:text;comment:审批备注" json:"remark,omitempty"`
// 后处理标记
CommissionDeducted bool `gorm:"column:commission_deducted;not null;default:false;comment:佣金是否已回扣" json:"commission_deducted"`
AssetReset bool `gorm:"column:asset_reset;not null;default:false;comment:退款后资产处理是否完成" json:"asset_reset"`
}
// TableName 指定表名
func (RefundRequest) TableName() string {
return "tb_refund_request"
}
// 退款状态常量
const (
RefundStatusPending = 1 // 待审批
RefundStatusApproved = 2 // 已通过
RefundStatusRejected = 3 // 已拒绝
RefundStatusReturned = 4 // 已退回
)