feat: 实现账号与佣金管理模块
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 4m35s

新增功能:
- 店铺佣金查询:店铺佣金统计、店铺佣金记录列表、店铺提现记录
- 佣金提现审批:提现申请列表、审批通过、审批拒绝
- 提现配置管理:配置列表、新增配置、获取当前生效配置
- 企业管理:企业列表、创建、更新、删除、获取详情
- 企业卡授权:授权列表、批量授权、批量取消授权、统计
- 客户账号管理:账号列表、创建、更新状态、重置密码
- 我的佣金:佣金统计、佣金记录、提现申请、提现记录

数据库变更:
- 扩展 tb_commission_withdrawal_request 新增提现单号等字段
- 扩展 tb_account 新增 is_primary 字段
- 扩展 tb_commission_record 新增 shop_id、balance_after
- 扩展 tb_commission_withdrawal_setting 新增每日提现次数限制
- 扩展 tb_iot_card、tb_device 新增 shop_id 冗余字段
- 新建 tb_enterprise_card_authorization 企业卡授权表
- 新建 tb_asset_allocation_record 资产分配记录表
- 数据迁移:owner_type 枚举值 agent 统一为 shop

测试:
- 新增 7 个单元测试文件覆盖各服务
- 修复集成测试 Redis 依赖问题
This commit is contained in:
2026-01-21 18:20:44 +08:00
parent 1489abe668
commit 91c9bbfeb8
89 changed files with 11958 additions and 159 deletions

View File

@@ -12,17 +12,25 @@ import (
type CommissionWithdrawalRequest struct {
gorm.Model
BaseModel `gorm:"embedded"`
WithdrawalNo string `gorm:"column:withdrawal_no;type:varchar(50);uniqueIndex:uk_commission_withdrawal_no,where:deleted_at IS NULL AND withdrawal_no IS NOT NULL;comment:提现单号唯一格式W + 时间戳 + 随机数)" json:"withdrawal_no"`
AgentID uint `gorm:"column:agent_id;index;not null;comment:代理用户ID" json:"agent_id"`
ApplicantID uint `gorm:"column:applicant_id;index;comment:申请人账号ID" json:"applicant_id"`
ShopID uint `gorm:"column:shop_id;index;comment:店铺ID冗余字段" json:"shop_id"`
Amount int64 `gorm:"column:amount;type:bigint;not null;comment:提现金额(分为单位)" json:"amount"`
Fee int64 `gorm:"column:fee;type:bigint;default:0;comment:手续费(分为单位)" json:"fee"`
FeeRate int64 `gorm:"column:fee_rate;type:bigint;default:0;comment:手续费比率基点100=1%,快照)" json:"fee_rate"`
ActualAmount int64 `gorm:"column:actual_amount;type:bigint;comment:实际到账金额(分为单位)" json:"actual_amount"`
WithdrawalMethod string `gorm:"column:withdrawal_method;type:varchar(20);comment:提现方式 alipay-支付宝 wechat-微信 bank-银行卡" json:"withdrawal_method"`
PaymentType string `gorm:"column:payment_type;type:varchar(20);default:'manual';comment:放款类型manual=人工打款)" json:"payment_type"`
AccountInfo datatypes.JSON `gorm:"column:account_info;type:jsonb;comment:收款账户信息(姓名、账号等)" json:"account_info"`
Status int `gorm:"column:status;type:int;default:1;comment:状态 1-待审核 2-已通过 3-已拒绝 4-已到账" json:"status"`
ApprovedBy uint `gorm:"column:approved_by;index;comment:审批人用户ID" json:"approved_by"`
ApprovedAt *time.Time `gorm:"column:approved_at;comment:审批时间" json:"approved_at"`
ProcessorID uint `gorm:"column:processor_id;index;comment:处理人ID" json:"processor_id"`
ProcessedAt *time.Time `gorm:"column:processed_at;comment:处理时间" json:"processed_at"`
PaidAt *time.Time `gorm:"column:paid_at;comment:到账时间" json:"paid_at"`
RejectReason string `gorm:"column:reject_reason;type:text;comment:拒绝原因" json:"reject_reason"`
Remark string `gorm:"column:remark;type:text;comment:备注" json:"remark"`
}
// TableName 指定表名
@@ -34,11 +42,12 @@ func (CommissionWithdrawalRequest) TableName() string {
// 提现参数配置(最低金额、手续费率、到账时间等)
type CommissionWithdrawalSetting struct {
gorm.Model
BaseModel `gorm:"embedded"`
MinWithdrawalAmount int64 `gorm:"column:min_withdrawal_amount;type:bigint;comment:最低提现金额(分为单位)" json:"min_withdrawal_amount"`
FeeRate int64 `gorm:"column:fee_rate;type:bigint;comment:手续费率(万分比,如100表示1%)" json:"fee_rate"`
ArrivalDays int `gorm:"column:arrival_days;type:int;comment:到账天数" json:"arrival_days"`
IsActive bool `gorm:"column:is_active;type:boolean;default:true;comment:是否生效(最新一条)" json:"is_active"`
BaseModel `gorm:"embedded"`
MinWithdrawalAmount int64 `gorm:"column:min_withdrawal_amount;type:bigint;comment:最低提现金额(分为单位)" json:"min_withdrawal_amount"`
FeeRate int64 `gorm:"column:fee_rate;type:bigint;comment:手续费率(万分比,如100表示1%)" json:"fee_rate"`
ArrivalDays int `gorm:"column:arrival_days;type:int;comment:到账天数" json:"arrival_days"`
DailyWithdrawalLimit int `gorm:"column:daily_withdrawal_limit;type:int;default:3;comment:每日提现次数限制" json:"daily_withdrawal_limit"`
IsActive bool `gorm:"column:is_active;type:boolean;default:true;comment:是否生效(最新一条)" json:"is_active"`
}
// TableName 指定表名