Files
junhong_cmp_fiber/internal/model/refund.go
huang 02b10f87cf
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m8s
feat: 新增退款管理模块 — 完整的退款审批流程、佣金回扣和资产重置
新增退款申请全生命周期管理:创建/列表/详情/审批通过/拒绝/退回/重新提交
审批通过后异步执行佣金全额回扣(扣减各代理佣金钱包)和资产重置(套餐失效+停机+世代重置)
新增 tb_refund_request 表(迁移 000093)、RefundRequest Model、8 个 DTO
新增 Store/Service/Handler/路由注册,仅平台用户可访问
2026-03-28 17:57:52 +08:00

54 lines
2.8 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"`
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"`
// 金额信息
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 // 已退回
)