You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
7.1 KiB

4 years ago
package company
import (
4 years ago
"fmt"
3 years ago
"recook/internal/model/user"
4 years ago
"recook/internal/v2/model/recook/manage"
"time"
4 years ago
"github.com/golangkit/formatime"
3 years ago
"github.com/shopspring/decimal"
4 years ago
"gorm.io/gorm"
4 years ago
)
type State uint
const (
Wait State = iota + 1
Pass
Reject
)
var stateMap = map[State]string{
Wait: "待审核",
Pass: "已通过",
Reject: "已驳回",
}
func (o State) Str() string {
return stateMap[o]
}
type Status uint
const (
Normal Status = iota + 1
Disable
)
var statusMap = map[Status]string{
Normal: "正常",
Disable: "禁用",
}
func (o Status) Str() string {
return statusMap[o]
}
type Info struct {
ID uint `json:"id"`
ShopName string `json:"shop_name" `
4 years ago
Mobile string `json:"mobile"`
ContractName string `json:"contract_name"`
ContractMobile string `json:"contract_mobile"`
ContractEmail string `json:"contract_email"`
ProcessUserID uint `json:"-"`
ProcessUserInfo manage.RecookManageUserInfoModel `json:"-" gorm:"foreignKey:process_user_id"`
ProcessUserName string `json:"process_user_name" gorm:"-"`
ProcessTime formatime.Second `json:"process_time"`
ContractNo string `json:"contract_no"`
ContractStart formatime.Second `json:"contract_start"`
ContractEnd formatime.Second `json:"contract_end"`
ContractAttach string `json:"contract_attach"`
CompanyName string `json:"company_name"`
RegisterAddress string `json:"register_address"`
BusinessAddress string `json:"business_address"`
BusinessStart formatime.Second `json:"business_start"`
BusinessEnd formatime.Second `json:"business_end"`
BusinessPhoto string `json:"business_photo"`
BusinessPerson string `json:"business_person"`
4 years ago
TaxType string `json:"tax_type" validate:"required,oneof=一般纳税人 小规模纳税人"`
4 years ago
TaxBank string `json:"tax_bank"`
TaxNumber string `json:"tax_number"`
TaxAccount string `json:"tax_account"`
TaxPhoto string `json:"tax_photo"`
TaxProve string `json:"tax_prove"`
CreatedAt formatime.Second `json:"created_at"`
ApplyUserID uint `json:"-"`
ApplyUserInfo manage.RecookManageUserInfoModel `json:"-" gorm:"foreignKey:apply_user_id"`
ApplyUserName string `json:"apply_user_name" gorm:"-"`
State State `json:"state"`
StateStr string `json:"state_str" gorm:"-"`
Status Status `json:"status"`
StatusStr string `json:"status_str" gorm:"-"`
Logs []Log `json:"log" gorm:"foreignKey:company_id"`
Count int64 `json:"count" gorm:"-"`
UserID uint `json:"-"`
Password string `json:"password"`
3 years ago
Tax decimal.Decimal `json:"tax"`
3 years ago
TaxBillType string `json:"tax_bill_type"`
4 years ago
}
func (o *Info) TableName() string {
return "jyy_company_info"
}
4 years ago
func (o *Info) AfterFind(tx *gorm.DB) error {
fmt.Println(123)
4 years ago
o.ProcessUserName = o.ProcessUserInfo.Name
o.ApplyUserName = o.ApplyUserInfo.Name
o.StateStr = o.State.Str()
o.StatusStr = o.Status.Str()
return nil
}
type Log struct {
ID uint `json:"id"`
Text string `json:"text"`
UserID uint `json:"-"`
4 years ago
ManageUserInfo manage.RecookManageUserInfoModel `json:"-" gorm:"references:user_id;foreignKey:id"`
4 years ago
ManageUserName string `json:"manage_user_name" gorm:"-"`
CreatedAt formatime.Second `json:"created_at"`
4 years ago
CompanyID uint `json:"company_id"`
4 years ago
}
func (o Log) TableName() string {
return "jyy_company_log"
}
4 years ago
func (o *Log) AfterFind(tx *gorm.DB) error {
4 years ago
o.ManageUserName = o.ManageUserInfo.Name
return nil
}
type Apply struct {
3 years ago
ID int `json:"id" gorm:"primaryKey;autoIncrement"`
3 years ago
UserID int `json:"-" `
Amount decimal.Decimal `json:"amount"`
3 years ago
State int `json:"state"`
3 years ago
CreatedAt *time.Time `json:"created_at" gorm:"autoCreateTime"`
Content string `json:"content" gorm:"<-:update"`
Proof string `json:"proof" gorm:"<-:update"`
Tax int `json:"tax" validate:"oneof=1 2"`
LogisticsName string `json:"logistics_name"`
WaybillCode string `json:"waybill_code"`
ApplyUserID int `json:"-"`
ApplyUser *manage.RecookManageUserInfoModel `json:"-" gorm:"foreignKey:ApplyUserID"`
ApplyUserName string `json:"apply_user_name" gorm:"-"`
ApplyTime *time.Time `json:"apply_time" gorm:"<-:update"`
ProcessUserID int `json:"-"`
ProcessUser *manage.RecookManageUserInfoModel `json:"-" gorm:"foreignKey:ProcessUserID"`
ProcessUserName string `json:"process_user_name" gorm:"-"`
ProcessTime *time.Time `json:"process_time" gorm:"<-:update"`
CompanyID int `json:"-"`
Company *Info `json:"-" gorm:"foreignKey:CompanyID"`
Bank string `json:"bank" gorm:"-"`
Code string `json:"code" gorm:"-"`
CompanyName string `json:"comapny_name" gorm:"-"`
3 years ago
User *user.Information `json:"-" gorm:"foreignKey:UserID"`
3 years ago
Mobile string `json:"mobile" gorm:"-"`
Nickname string `json:"nickname" gorm:"-"`
}
func (o Apply) TableName() string {
return "jyy_company_apply"
}
3 years ago
func (o *Apply) AfterFind(db *gorm.DB) error {
if o.ApplyUser != nil {
o.ApplyUserName = o.ApplyUser.Name
}
if o.ProcessUser != nil {
o.ProcessUserName = o.ProcessUser.Name
}
if o.Company != nil {
o.Bank = o.Company.TaxBank
o.Code = o.Company.TaxAccount
o.CompanyName = o.Company.CompanyName
3 years ago
}
if o.User != nil {
o.Mobile = o.User.Mobile
o.Nickname = o.User.Nickname
3 years ago
}
return nil
}