feat:完善入驻信息管理
This commit is contained in:
@ -5,10 +5,7 @@ import (
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/serve/orm"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Settled 入驻
|
||||
@ -80,62 +77,62 @@ func (c *Settled) filter(identity int, where ...*model2.ModelWhere) (bool, error
|
||||
return mSysIdentity.IsExamine == model2.SysIdentityExamineForYes, nil
|
||||
}
|
||||
|
||||
// Company 公司企业
|
||||
func (c *Settled) Company(params *SettledParams, inviterID uint64, other *config.IdentityForCompany) error {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
|
||||
isExist, err := model2.FirstField(mManageCompany.ManageCompany, []string{"id", "status"},
|
||||
model2.NewWhere("code", params.Code), model2.NewWhere("local", c.local),
|
||||
model2.NewWhere("status", model2.ExamineStatusForRefuse))
|
||||
|
||||
isExamine := true
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
if mManageCompany.Status == model2.ExamineStatusForOngoing {
|
||||
return errors.New("操作错误,当前企业信息审核中,不可入驻")
|
||||
}
|
||||
// 筛选企业条件
|
||||
if isExamine, err = c.filter(config.TenantUserIdentityForCompany, model2.NewWhere("company_id", mManageCompany.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
mManageCompany.Local.Local = c.local
|
||||
mManageCompany.InviterID = inviterID
|
||||
mManageCompany.Name = params.Name
|
||||
mManageCompany.Code = params.Code
|
||||
mManageCompany.Image = model2.Image{Image: params.Image}
|
||||
mManageCompany.Area = model2.Area{
|
||||
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
}
|
||||
mManageCompany.WebUrl = other.WebUrl
|
||||
mManageCompany.SetIndustryAttribute(params.Industrys)
|
||||
mManageCompany.SetKeywordAttribute(params.Keywords)
|
||||
mManageCompany.Introduce = params.Introduce
|
||||
|
||||
if isExamine {
|
||||
mManageCompany.Status = model2.ExamineStatusForAgree
|
||||
}
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if mManageCompany.ID <= 0 {
|
||||
if err = model2.Create(mManageCompany.ManageCompany, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// 过滤用户其他公司入驻信息
|
||||
mUserCompany := model.NewUserCompany()
|
||||
|
||||
if err := model2.UpdatesWhere(mUserCompany.UserCompany, map[string]interface{}{
|
||||
"status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
mUserCompany.UID = c.UID
|
||||
mUserCompany.CompanyID = mManageCompany.ID
|
||||
return model2.Create(mUserCompany.UserCompany, tx)
|
||||
})
|
||||
}
|
||||
//// Company 公司企业
|
||||
//func (c *Settled) Company(params *SettledParams, inviterID uint64, other *config.IdentityForCompany) error {
|
||||
// mManageCompany := model.NewManageCompany()
|
||||
//
|
||||
// isExist, err := model2.FirstField(mManageCompany.ManageCompany, []string{"id", "status"},
|
||||
// model2.NewWhere("code", params.Code), model2.NewWhere("local", c.local),
|
||||
// model2.NewWhere("status", model2.ExamineStatusForRefuse))
|
||||
//
|
||||
// isExamine := true
|
||||
//
|
||||
// if err != nil {
|
||||
// return err
|
||||
// } else if isExist {
|
||||
// if mManageCompany.ExamineStatus == model2.ExamineStatusForOngoing {
|
||||
// return errors.New("操作错误,当前企业信息审核中,不可入驻")
|
||||
// }
|
||||
// // 筛选企业条件
|
||||
// if isExamine, err = c.filter(config.TenantUserIdentityForCompany, model2.NewWhere("company_id", mManageCompany.ID)); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
// mManageCompany.Local.Local = c.local
|
||||
// mManageCompany.InviterID = inviterID
|
||||
// mManageCompany.Name = params.Name
|
||||
// mManageCompany.Code = params.Code
|
||||
// mManageCompany.Image = model2.Image{Image: params.Image}
|
||||
// mManageCompany.Area = model2.Area{
|
||||
// Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
// }
|
||||
// mManageCompany.Url = other.Url
|
||||
// mManageCompany.SetIndustryAttribute(params.Industrys)
|
||||
// mManageCompany.SetKeywordAttribute(params.Keywords)
|
||||
// mManageCompany.Introduce = params.Introduce
|
||||
//
|
||||
// if isExamine {
|
||||
// mManageCompany.ExamineStatus = model2.ExamineStatusForAgree
|
||||
// }
|
||||
// return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
// if mManageCompany.ID <= 0 {
|
||||
// if err = model2.Create(mManageCompany.ManageCompany, tx); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
// // 过滤用户其他公司入驻信息
|
||||
// mUserCompany := model.NewUserCompany()
|
||||
//
|
||||
// if err := model2.UpdatesWhere(mUserCompany.UserCompany, map[string]interface{}{
|
||||
// "status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
// }, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// mUserCompany.UID = c.UID
|
||||
// mUserCompany.CompanyID = mManageCompany.ID
|
||||
// return model2.Create(mUserCompany.UserCompany, tx)
|
||||
// })
|
||||
//}
|
||||
|
||||
//
|
||||
//// Expert 专家
|
||||
|
Reference in New Issue
Block a user