feat:完善入驻信息管理
This commit is contained in:
@ -1,11 +1,17 @@
|
||||
package settled
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/serve/orm"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Company 经纪人入驻信息
|
||||
// Agent 经纪人入驻信息
|
||||
type Agent struct {
|
||||
*session.Enterprise
|
||||
local string
|
||||
@ -15,7 +21,62 @@ type AgentHandle func(session *session.Enterprise, local string) *Agent
|
||||
|
||||
// Launch 经纪人入驻
|
||||
func (c *Agent) Launch(params *BasicParams, other *config.IdentityForAgent) error {
|
||||
return nil
|
||||
if c.Identity&config.TenantUserIdentityForAgent > 0 {
|
||||
return errors.New("操作错误,不可重复申请入驻")
|
||||
}
|
||||
mManageAgent := model.NewManageAgent()
|
||||
// 查询相应的经纪人入驻信息
|
||||
isExist, err := model2.FirstField(mManageAgent.ManageAgent, []string{"id", "status"},
|
||||
model2.NewWhere("id_card", other.IDCard), model2.NewWhere("local", c.local))
|
||||
|
||||
// 用户经纪人入驻信息
|
||||
mUserAgent := model.NewUserAgent()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
// 审核中
|
||||
if mManageAgent.Examine.ExamineStatus == model2.ExamineStatusForOngoing {
|
||||
return errors.New("操作错误,当前该企业信息审核中,不可入驻")
|
||||
}
|
||||
// 审核通过
|
||||
if mManageAgent.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
// 筛选企业条件
|
||||
if err = params.filter(config.TenantUserIdentityForAgent,
|
||||
model2.NewWhere("agent_id", mManageAgent.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
mManageAgent.ID = 0
|
||||
}
|
||||
mManageAgent.Local.Local = c.local
|
||||
mManageAgent.Name = params.Name
|
||||
mManageAgent.Mobile = params.Mobile
|
||||
mManageAgent.IDCard = other.IDCard
|
||||
mManageAgent.SetIndustryAttribute(params.Industrys)
|
||||
mManageAgent.SetKeywordAttribute(params.Keywords)
|
||||
mManageAgent.WorkExperience = other.WorkExperience
|
||||
mManageAgent.WorkPlace = other.WorkPlace
|
||||
mManageAgent.SetCredentialImageAttribute(other.CredentialImages)
|
||||
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
// 删除区域相同身份证经纪人信息
|
||||
if err = model2.DeleteWhere(mManageAgent.ManageAgent, []*model2.ModelWhere{
|
||||
model2.NewWhere("id_card", other.IDCard), model2.NewWhere("local", c.local)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = model2.Create(mManageAgent.ManageAgent, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := model2.UpdatesWhere(mUserAgent.UserAgent, map[string]interface{}{
|
||||
"invalid_status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
mUserAgent.UID = c.UID
|
||||
mUserAgent.AgentID = mManageAgent.ID
|
||||
return model2.Create(mUserAgent.UserAgent, tx)
|
||||
})
|
||||
}
|
||||
|
||||
func NewAgent() AgentHandle {
|
||||
|
Reference in New Issue
Block a user