Files
junhong_cmp_fiber/internal/model/financial.go
huang 91c9bbfeb8
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 4m35s
feat: 实现账号与佣金管理模块
新增功能:
- 店铺佣金查询:店铺佣金统计、店铺佣金记录列表、店铺提现记录
- 佣金提现审批:提现申请列表、审批通过、审批拒绝
- 提现配置管理:配置列表、新增配置、获取当前生效配置
- 企业管理:企业列表、创建、更新、删除、获取详情
- 企业卡授权:授权列表、批量授权、批量取消授权、统计
- 客户账号管理:账号列表、创建、更新状态、重置密码
- 我的佣金:佣金统计、佣金记录、提现申请、提现记录

数据库变更:
- 扩展 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 依赖问题
2026-01-21 18:20:44 +08:00

78 lines
5.2 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/datatypes"
"gorm.io/gorm"
)
// CommissionWithdrawalRequest 佣金提现申请模型
// 代理佣金提现申请、审批流程、提现记录查询
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 指定表名
func (CommissionWithdrawalRequest) TableName() string {
return "tb_commission_withdrawal_request"
}
// CommissionWithdrawalSetting 佣金提现设置模型
// 提现参数配置(最低金额、手续费率、到账时间等)
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"`
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 指定表名
func (CommissionWithdrawalSetting) TableName() string {
return "tb_commission_withdrawal_setting"
}
// PaymentMerchantSetting 收款商户设置模型
// 配置支付参数(支付宝、微信等收款账户)
type PaymentMerchantSetting struct {
gorm.Model
BaseModel `gorm:"embedded"`
UserID uint `gorm:"column:user_id;index;not null;comment:用户ID" json:"user_id"`
MerchantType string `gorm:"column:merchant_type;type:varchar(20);comment:商户类型 alipay-支付宝 wechat-微信 bank-银行卡" json:"merchant_type"`
AccountName string `gorm:"column:account_name;type:varchar(255);comment:账户名称" json:"account_name"`
AccountNumber string `gorm:"column:account_number;type:varchar(255);comment:账号" json:"account_number"`
BankName string `gorm:"column:bank_name;type:varchar(255);comment:银行名称(仅银行卡)" json:"bank_name"`
BankBranch string `gorm:"column:bank_branch;type:varchar(255);comment:开户行(仅银行卡)" json:"bank_branch"`
IsVerified bool `gorm:"column:is_verified;type:boolean;default:false;comment:是否已验证" json:"is_verified"`
IsDefault bool `gorm:"column:is_default;type:boolean;default:false;comment:是否默认账户" json:"is_default"`
Status int `gorm:"column:status;type:int;default:1;comment:状态 1-启用 2-禁用" json:"status"`
}
// TableName 指定表名
func (PaymentMerchantSetting) TableName() string {
return "tb_payment_merchant_setting"
}