Files
affiliate_dash/backend/internal/model/recharge.go
T
yml2213 941e7ad79a 积分充值全流程落地:申请审核入账、凭证上传压缩转webp、管理员调账收权
- 新增积分充值申请与审核:商户提交充值申请(凭证图片必填,1元=100积分),
  管理员审核通过后事务内自动入账,幂等键防重复
- 新增通用图片上传组件 ImageUploader:canvas 压缩转 webp、预览、删除,
  后端按魔数校验图片格式并持久化到 data/uploads
- 管理员钱包调整改为按商户维度:移除商户侧调账接口,新增管理员
  平台商户积分调整与钱包流水查看
- 低余额 Webhook 告警配置持久化,充值入账/调账后自动检查推送
- 平台商户操作列移除进入/成员,积分充值页接入真实接口并修复金额单位换算
2026-08-04 13:03:29 +08:00

48 lines
1.8 KiB
Go

package model
import (
"time"
"gorm.io/gorm"
)
// 充值申请状态
const (
RechargeStatusPending = "pending"
RechargeStatusApproved = "approved"
RechargeStatusRejected = "rejected"
)
// RechargeApplication 商户提交的人民币充值申请,凭证图片必填,由平台管理员审核后入账。
type RechargeApplication struct {
ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
MerchantID uint `gorm:"not null;index" json:"merchant_id"`
ApplicationNo string `gorm:"uniqueIndex;size:64;not null" json:"application_no"`
AmountCNY int64 `gorm:"not null" json:"amount_cny"` // 人民币金额,单位:分
PointsAmount int64 `gorm:"not null" json:"points_amount"`
Status string `gorm:"size:16;not null;default:pending;index" json:"status"`
Vouchers []string `gorm:"type:text;serializer:json" json:"vouchers"` // 打款凭证图片 URL
Note string `gorm:"size:512" json:"note"`
ReviewNote string `gorm:"size:512" json:"review_note"`
ReviewedAt *time.Time `json:"reviewed_at"`
ReviewedBy *uint `json:"reviewed_by"`
Merchant *Merchant `gorm:"foreignKey:MerchantID" json:"merchant,omitempty"`
}
// MerchantAlertConfig 低余额 Webhook 告警配置(每商户一份)。
type MerchantAlertConfig struct {
ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
MerchantID uint `gorm:"not null;uniqueIndex" json:"merchant_id"`
Enabled bool `gorm:"not null;default:false" json:"enabled"`
ThresholdPoints int64 `gorm:"not null;default:0" json:"threshold_points"`
WebhookURL string `gorm:"size:1024" json:"webhook_url"`
}