feat: 实现社区激励金(公户)系统,经济闭环
- 新增 CommunityFund / FundLog 模型(公户余额单行表 + 6种流水类型) - 新增 FundRepo 仓储(GetBalance / IncrBalance / CreateLog / ListLogs / WithTx) - 改造 EnergyService 五个方法:Energize 税收入公户、DeductOnRename/DeductOnDeletePost 入公户、RefundOnRenameReject 从公户支出、AdminAdjust 拆分为 admin_transfer/system_operation - 新增 ErrInsufficientFund 错误哨兵 - 管理后台新增公户余额展示 + 公户流水页面 + 域能调整资金来源选择 - 新增 energy.css / energy.js 前端交互 - 侧边栏新增公户流水入口
This commit is contained in:
10
internal/model/community_fund.go
Normal file
10
internal/model/community_fund.go
Normal file
@ -0,0 +1,10 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// CommunityFund 公户余额(单行表,id=1)
|
||||
type CommunityFund struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Balance int `gorm:"not null;default:0" json:"balance"` // 余额(×10,允许负数)
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
35
internal/model/fund_log.go
Normal file
35
internal/model/fund_log.go
Normal file
@ -0,0 +1,35 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// 公户流水类型常量
|
||||
const (
|
||||
FundTypeEnergizeTax = "energize_tax" // 赋能税收(入公户)
|
||||
FundTypeRenameDeduction = "rename_deduction" // 改名扣费(入公户)
|
||||
FundTypeRenameRefund = "rename_refund" // 改名退款(出公户)
|
||||
FundTypeDeletePost = "delete_post_deduction" // 删稿扣费(入公户)
|
||||
FundTypeAdminTransfer = "admin_transfer" // 管理员转账(出公户,受余额约束)
|
||||
FundTypeSystemOperation = "system_operation" // 站长直调(双向,不受余额约束)
|
||||
)
|
||||
|
||||
// FundLog 公户流水记录
|
||||
type FundLog struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Amount int `gorm:"not null" json:"amount"` // +入公户 / –出公户(×10)
|
||||
Type string `gorm:"type:varchar(50);index;not null" json:"type"` // 日志类型
|
||||
RelatedType string `gorm:"type:varchar(50);default:''" json:"related_type,omitempty"`
|
||||
RelatedID uint `gorm:"default:0" json:"related_id,omitempty"`
|
||||
OperatorUID *uint `gorm:"default:null" json:"operator_uid,omitempty"`
|
||||
Description string `gorm:"type:text;not null" json:"description"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// FundLogDisplayNames 公户流水类型 → 中文名
|
||||
var FundLogDisplayNames = map[string]string{
|
||||
FundTypeEnergizeTax: "赋能税收",
|
||||
FundTypeRenameDeduction: "改名扣费",
|
||||
FundTypeRenameRefund: "改名退款",
|
||||
FundTypeDeletePost: "删稿扣费",
|
||||
FundTypeAdminTransfer: "管理转出",
|
||||
FundTypeSystemOperation: "系统操作",
|
||||
}
|
||||
Reference in New Issue
Block a user