v1.0.0
This commit is contained in:
71
internal/domains/finance/entities/user_invoice_info.go
Normal file
71
internal/domains/finance/entities/user_invoice_info.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package entities
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// UserInvoiceInfo 用户开票信息实体
|
||||
type UserInvoiceInfo struct {
|
||||
ID string `gorm:"primaryKey;type:varchar(36)" json:"id"`
|
||||
UserID string `gorm:"uniqueIndex;type:varchar(36);not null" json:"user_id"`
|
||||
|
||||
// 开票信息字段
|
||||
CompanyName string `gorm:"type:varchar(200);not null" json:"company_name"` // 公司名称
|
||||
TaxpayerID string `gorm:"type:varchar(50);not null" json:"taxpayer_id"` // 纳税人识别号
|
||||
BankName string `gorm:"type:varchar(100)" json:"bank_name"` // 开户银行
|
||||
BankAccount string `gorm:"type:varchar(50)" json:"bank_account"` // 银行账号
|
||||
CompanyAddress string `gorm:"type:varchar(500)" json:"company_address"` // 企业地址
|
||||
CompanyPhone string `gorm:"type:varchar(20)" json:"company_phone"` // 企业电话
|
||||
ReceivingEmail string `gorm:"type:varchar(100);not null" json:"receiving_email"` // 发票接收邮箱
|
||||
|
||||
// 元数据
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
func (UserInvoiceInfo) TableName() string {
|
||||
return "user_invoice_info"
|
||||
}
|
||||
|
||||
// IsComplete 检查开票信息是否完整
|
||||
func (u *UserInvoiceInfo) IsComplete() bool {
|
||||
return u.CompanyName != "" && u.TaxpayerID != "" && u.ReceivingEmail != ""
|
||||
}
|
||||
|
||||
// IsCompleteForSpecialInvoice 检查专票信息是否完整
|
||||
func (u *UserInvoiceInfo) IsCompleteForSpecialInvoice() bool {
|
||||
return u.CompanyName != "" && u.TaxpayerID != "" && u.BankName != "" &&
|
||||
u.BankAccount != "" && u.CompanyAddress != "" && u.CompanyPhone != "" &&
|
||||
u.ReceivingEmail != ""
|
||||
}
|
||||
|
||||
// GetMissingFields 获取缺失的字段
|
||||
func (u *UserInvoiceInfo) GetMissingFields() []string {
|
||||
var missing []string
|
||||
if u.CompanyName == "" {
|
||||
missing = append(missing, "公司名称")
|
||||
}
|
||||
if u.TaxpayerID == "" {
|
||||
missing = append(missing, "纳税人识别号")
|
||||
}
|
||||
if u.BankName == "" {
|
||||
missing = append(missing, "开户银行")
|
||||
}
|
||||
if u.BankAccount == "" {
|
||||
missing = append(missing, "银行账号")
|
||||
}
|
||||
if u.CompanyAddress == "" {
|
||||
missing = append(missing, "企业地址")
|
||||
}
|
||||
if u.CompanyPhone == "" {
|
||||
missing = append(missing, "企业电话")
|
||||
}
|
||||
if u.ReceivingEmail == "" {
|
||||
missing = append(missing, "发票接收邮箱")
|
||||
}
|
||||
return missing
|
||||
}
|
||||
Reference in New Issue
Block a user