...
|
...
|
@@ -2,6 +2,9 @@ package domain_service |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
|
"github.com/tiptok/gocomm/xa/eda"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
|
...
|
...
|
@@ -14,8 +17,6 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
|
|
|
protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/auth"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
type PgLoginService struct {
|
...
|
...
|
@@ -182,7 +183,7 @@ func (svr *PgLoginService) PartnerLogin(phone string, password string) (err erro |
|
|
return
|
|
|
}
|
|
|
|
|
|
//管理层登录
|
|
|
// 管理层登录
|
|
|
func (svr *PgLoginService) ManagerLogin(phone string, password string) (err error) {
|
|
|
if len(svr.Users) == 0 {
|
|
|
//子账号
|
...
|
...
|
@@ -198,7 +199,7 @@ func (svr *PgLoginService) ManagerLogin(phone string, password string) (err erro |
|
|
return
|
|
|
}
|
|
|
|
|
|
//合伙人统计信息
|
|
|
// 合伙人统计信息
|
|
|
func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
|
|
|
response := make(map[string]interface{})
|
|
|
response["id"] = protocolx.AdminTypePartner
|
...
|
...
|
@@ -564,7 +565,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error { |
|
|
// 用户在正常公司存在且无效或者存在非高管或者不存在、合伙人在正常公司存在且无效或者不存在、合伙人在游客公司不存在、注册合伙人到游客公司
|
|
|
if !isGuestPartner && (isUser && !isUserAvailable || isUser && !isUserSenior || !isUser) && (isPartner && !isPartnerAvailable || !isPartner) {
|
|
|
id := time.Now().Unix()
|
|
|
errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
|
|
|
m := &models.PartnerInfo{
|
|
|
Id: id,
|
|
|
CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
|
|
|
PartnerName: phone,
|
...
|
...
|
@@ -581,14 +582,16 @@ func (svr *PgLoginService) RegistryUser(phone string) error { |
|
|
UpdateAt: time.Now(),
|
|
|
PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
|
|
|
Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
|
|
|
})
|
|
|
}
|
|
|
_, errPartner = svr.transactionContext.PgDd.Model(m).Insert()
|
|
|
}
|
|
|
|
|
|
// 合伙人不存在、用户存在、非高管(普通用户)-> 注册用户
|
|
|
// 合伙人不存在、用户不存在(游客)-> 注册用户
|
|
|
if errPartner != nil && errUser == nil {
|
|
|
id := time.Now().Unix()
|
|
|
errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
|
|
|
|
|
|
m := &models.PartnerInfo{
|
|
|
Id: id,
|
|
|
CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
|
|
|
PartnerName: phone,
|
...
|
...
|
@@ -605,7 +608,8 @@ func (svr *PgLoginService) RegistryUser(phone string) error { |
|
|
UpdateAt: time.Now(),
|
|
|
PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
|
|
|
Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
|
|
|
})
|
|
|
}
|
|
|
_, errPartner = svr.transactionContext.PgDd.Model(&m).Insert()
|
|
|
}
|
|
|
|
|
|
return errPartner
|
...
|
...
|
@@ -688,7 +692,7 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { |
|
|
// 注册用户
|
|
|
if errUser != nil && errPartner != nil {
|
|
|
id := time.Now().Unix()
|
|
|
errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
|
|
|
m := &models.PartnerInfo{
|
|
|
Id: id,
|
|
|
CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
|
|
|
PartnerName: phone,
|
...
|
...
|
@@ -705,7 +709,8 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { |
|
|
UpdateAt: time.Now(),
|
|
|
PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
|
|
|
Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
|
|
|
})
|
|
|
}
|
|
|
_, errPartner = svr.transactionContext.PgDd.Model(m).Insert()
|
|
|
}
|
|
|
|
|
|
// 删除用户
|
...
|
...
|
|