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.
66 lines
1.9 KiB
66 lines
1.9 KiB
package copartner
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"git.oa00.com/go/mysql"
|
|
"github.com/golangkit/formatime"
|
|
"github.com/shopspring/decimal"
|
|
"gorm.io/gorm"
|
|
"recook/internal/v2/model/company"
|
|
"recook/internal/v2/model/recook/user"
|
|
)
|
|
|
|
var CompanyLogic = &companyLogic{}
|
|
|
|
type companyLogic struct {
|
|
}
|
|
type CompanyInfo struct {
|
|
Phone string //手机号
|
|
NikeName string //昵称
|
|
BusinessLicense string //营业执照
|
|
TaxPhoto string //一般纳税人传的照片
|
|
CorporationName string //企业名
|
|
TaxBillType string //纳税类型
|
|
Taxpayer string //纳税识别号
|
|
OpeningBank string //开户行
|
|
BankAccount string //银行账户
|
|
MakeTax decimal.Decimal //开票税率
|
|
Linkman string //联系人
|
|
ContractMobile string //联系人手机号
|
|
}
|
|
|
|
// Add @Title 添加合伙人
|
|
func (c *companyLogic) Add(data CompanyInfo) error {
|
|
userInfoModel := user.RecookUserInfoModel{Mobile: data.Phone}
|
|
mysql.Db.Where(&userInfoModel).First(&userInfoModel)
|
|
if userInfoModel.Id > 0 {
|
|
return fmt.Errorf("手机已存在")
|
|
}
|
|
companyInfo := company.Info{
|
|
ShopName: data.NikeName,
|
|
Mobile: data.Phone,
|
|
BusinessPhoto: data.BusinessLicense,
|
|
TaxBank: data.OpeningBank,
|
|
TaxAccount: data.BankAccount,
|
|
Tax: data.MakeTax,
|
|
TaxType: data.TaxBillType,
|
|
ContractMobile: data.ContractMobile,
|
|
TaxNumber: data.Taxpayer,
|
|
ContractName: data.Linkman,
|
|
CompanyName: data.CorporationName,
|
|
State: company.Wait,
|
|
CreatedAt: formatime.NewSecondNow(),
|
|
}
|
|
if data.TaxBillType == "一般纳税人" {
|
|
companyInfo.TaxPhoto = data.TaxPhoto
|
|
}
|
|
|
|
return mysql.Db.Transaction(func(tx *gorm.DB) error {
|
|
if tx.Create(&companyInfo).Error != nil {
|
|
return errors.New("提交失败")
|
|
}
|
|
return nil
|
|
})
|
|
}
|