作者 陈志颖

合并分支 'dev' 到 'test'

fix:用户注册问题



查看合并请求 !31
appname = partner
runmode = "${RUN_MODE||dev}"
httpport = "${HTTP_PORT||8083}"
httpport = "${HTTP_PORT||8082}"
#开启监控
EnableAdmin = false
... ...
... ... @@ -450,8 +450,8 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
rsp.Partner, _ = loginSvr.PartnerStaticInfo()
rsp.Manager, _ = loginSvr.ManagerStaticInfo()
if !loginSvr.HasAvailableCompany {
err = protocol.NewErrWithMessage(10008) //账号禁用
if !loginSvr.HasAvailableCompany && !loginSvr.HasAvailableManagerCompany { // 判断合伙人或者高管是否有可访问的公司
err = protocol.NewErrWithMessage(10008) //账号禁用, 抱歉,企业管理员未帮您开通权限。如需访问,请联系企业管理员
return
}
... ... @@ -481,14 +481,24 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
v = map[string]interface{}{"center": rsp}
} else {
var companies []interface{}
for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]struct{}) {
companies = append(companies, company)
if rsp.Partner.(map[string]interface{})["companys"] != nil {
for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) {
companies = append(companies, company)
}
} else {
companies = []interface{}{}
}
for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) {
companies = append(companies, company)
if rsp.Manager.(map[string]interface{})["companys"] != nil {
for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]struct{}) {
companies = append(companies, company)
}
}
rsp.Partner.(map[string]interface{})["companys"] = companies
rsp.Manager.(map[string]interface{})["companys"] = []struct{}{}
v = map[string]interface{}{"center": rsp}
}
... ...
... ... @@ -18,7 +18,7 @@ var UCENTER_APP_KEY = "0c2c2a23dfc64ae230f5c54ab243ab52"
var BUSINESS_ADMIN_SERVICE_HOST = "http://suplus-business-admin-test.fjmaimaimai.com"
var BUSINESS_ADMIN_PLATFORM_ID = "25" //合伙人模块
var DEFAULT_GUEST_COMPANY int = 10011
var DEFAULT_GUEST_COMPANY int = 358
var SHARE_SHOP_PREVIEW_IMADGE = "https://media.fjmaimaimai.com/image/default/3E0C7050C13147CE8C7AF86C75F904E9-6-2.jpg" //分享店铺预览图
var WEHAT_MINI_PROGRAM_VERSION_TYPE = 2 //0:正式版 1:开发版 2:体验版
... ...
... ... @@ -24,7 +24,8 @@ type PgLoginService struct {
Users []*domain.Users
transactionContext *transaction.TransactionContext
// 标识:登录的账号信息是否有可用的公司, true:有 false:没有
HasAvailableCompany bool
HasAvailableCompany bool
HasAvailableManagerCompany bool
}
func (svr *PgLoginService) Init(phone string) (err error) {
... ... @@ -294,7 +295,7 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) {
companys = append(companys, item)
}
if len(companys) > 0 {
svr.HasAvailableCompany = true
svr.HasAvailableManagerCompany = true
}
response["companys"] = companys
... ... @@ -370,15 +371,18 @@ func computeBonusPercent(totalBonus float64, bonus float64) float64 {
func (svr *PgLoginService) RegistryUser(phone string) error {
var (
PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext)
UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext)
)
partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone})
partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone}) // 合伙人是否存在
user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone}) // 用户是否存在
_, errSenior := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "isSenior": 2}) // 用户是否是高管
if partnerInfo != nil {
if partnerInfo != nil && user != nil { // 用户存在且合伙人存在,不注册合伙人
return nil
}
if errPartner != nil {
if errPartner != nil && errUser == nil && errSenior == nil { // 合伙人不存在、用户存在且不是高管,注册合伙人
id := time.Now().Unix()
errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
Id: id,
... ...
... ... @@ -55,6 +55,7 @@ func (repository *UsersRepository) FindOne(queryOptions map[string]interface{})
query.SetWhere("phone = ?", "phone")
query.SetWhere("company_id = ?", "companyId")
query.SetWhere(`delete_at is null`, "deleteAtIsNull")
query.SetWhere("is_senior = ?", "isSenior")
if err := query.First(); err != nil {
return nil, fmt.Errorf("query row not found")
... ...