fix:子公司登录

master
howell 3 years ago
parent 150b5c2cf8
commit 2b84c8cc5c

@ -326,6 +326,19 @@ type CompanyInfo struct {
func (o logic) Apply(args CompanyInfo) error {
if args.ID != 0 {
if err := mysql.Db.Transaction(func(tx *gorm.DB) error {
var c1 company.Info
mysql.Db.First(&c1, "id=?", args.ID)
if c1.ID > 0 {
return fmt.Errorf("店铺名字已存在")
}
if args.ShopName != c1.ShopName {
var c2 company.Info
mysql.Db.First(&c2, "shop_name=?", args.ShopName)
if c1.ID > 0 {
return fmt.Errorf("店铺名字已存在")
}
}
if err := tx.Table((&company.Info{}).TableName()).Where("id = ?", args.ID).Updates(args).Error; err != nil {
return err
}
@ -350,6 +363,11 @@ func (o logic) Apply(args CompanyInfo) error {
if u1.Id > 0 {
return fmt.Errorf("手机已存在")
}
var c1 company.Info
mysql.Db.First(&c1, "shop_name=?", args.ShopName)
if c1.ID > 0 {
return fmt.Errorf("店铺名字已存在")
}
args.State = company.Wait
args.CreatedAt = formatime.NewSecondNow()
args.Logs = nil

Loading…
Cancel
Save