|
|
package domain_service
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"github.com/tiptok/gocomm/xa/eda"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
|
...
|
...
|
@@ -20,11 +21,19 @@ import ( |
|
|
type PgLoginService struct {
|
|
|
Phone string
|
|
|
eda.EventCenterPublisher
|
|
|
PartnerInfo []*domain.PartnerInfo
|
|
|
Users []*domain.Users
|
|
|
transactionContext *transaction.TransactionContext
|
|
|
PartnerInfo []*domain.PartnerInfo // 所有公司有效合伙人
|
|
|
GuestPartnerInfo []*domain.PartnerInfo // 游客公司合伙人
|
|
|
GuestPartnerInfoAvailable []*domain.PartnerInfo // 游客公司有效合伙人
|
|
|
NormalPartnerInfo []*domain.PartnerInfo // 所有公司合伙人
|
|
|
IsPartnerInfo []*domain.PartnerInfo // 真实公司有效合伙人
|
|
|
Users []*domain.Users // 所有公司有效用户
|
|
|
NormalUsers []*domain.Users // 所有公司用户
|
|
|
IsSenior []*domain.Users // 所有公司有效高管
|
|
|
IsRealSenior []*domain.Users // 真实公司的有效高管
|
|
|
transactionContext *transaction.TransactionContext
|
|
|
// 标识:登录的账号信息是否有可用的公司, true:有 false:没有
|
|
|
HasAvailableCompany bool
|
|
|
HasAvailableCompany bool // 是否有可访问的合伙公司
|
|
|
HasAvailableManagerCompany bool // 是否有可访问的高管公司
|
|
|
}
|
|
|
|
|
|
func (svr *PgLoginService) Init(phone string) (err error) {
|
...
|
...
|
@@ -32,12 +41,118 @@ func (svr *PgLoginService) Init(phone string) (err error) { |
|
|
PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext)
|
|
|
UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext)
|
|
|
)
|
|
|
|
|
|
svr.Phone = phone
|
|
|
|
|
|
// 所有公司合伙人
|
|
|
_, svr.NormalPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC"})
|
|
|
// 所有公司有效合伙人
|
|
|
_, svr.PartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC"})
|
|
|
// 真实公司有效合伙人
|
|
|
_, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "isNot": constant.DEFAULT_GUEST_COMPANY})
|
|
|
// 游客公司合伙人
|
|
|
_, svr.GuestPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})
|
|
|
// 游客公司有效合伙人
|
|
|
_, svr.GuestPartnerInfoAvailable, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})
|
|
|
|
|
|
// 所有公司用户
|
|
|
_, svr.NormalUsers, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "sortByCreateTime": "ASC", "deleteAtIsNull": true})
|
|
|
// 所有公司有效用户
|
|
|
_, svr.Users, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true})
|
|
|
// 所有公司有效高管
|
|
|
_, svr.IsSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1})
|
|
|
// 真实公司有效高管
|
|
|
_, svr.IsRealSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1, "isNot": constant.DEFAULT_GUEST_COMPANY})
|
|
|
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (svr *PgLoginService) InitNormal(phone string) (err error) {
|
|
|
var (
|
|
|
PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext)
|
|
|
)
|
|
|
|
|
|
svr.Phone = phone
|
|
|
|
|
|
_, svr.NormalPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC"})
|
|
|
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (svr *PgLoginService) InitSenior(phone string) (err error) {
|
|
|
var (
|
|
|
UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext)
|
|
|
)
|
|
|
|
|
|
svr.Phone = phone
|
|
|
|
|
|
_, svr.IsSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1})
|
|
|
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (svr *PgLoginService) InitPartner(phone string) (err error) {
|
|
|
var (
|
|
|
PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext)
|
|
|
)
|
|
|
|
|
|
svr.Phone = phone
|
|
|
|
|
|
_, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "isNot": constant.DEFAULT_GUEST_COMPANY})
|
|
|
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @Author SteveChan
|
|
|
* @Description // 判断是否是高管
|
|
|
* @Date 10:44 2021/1/12
|
|
|
* @Param
|
|
|
* @return
|
|
|
**/
|
|
|
func (svr *PgLoginService) CheckIsSenior(phone string, companyId int64) (ok bool, err error) {
|
|
|
var (
|
|
|
UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext)
|
|
|
)
|
|
|
svr.Phone = phone
|
|
|
user, err := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "status": 1, "companyId": companyId, "deleteAtIsNull": true})
|
|
|
if err != nil {
|
|
|
return false, err
|
|
|
} else {
|
|
|
if user.IsSenior == 1 {
|
|
|
ok = true
|
|
|
} else if user.IsSenior == 2 {
|
|
|
ok = false
|
|
|
}
|
|
|
}
|
|
|
return ok, nil
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @Author SteveChan
|
|
|
* @Description // 判断是否合伙人
|
|
|
* @Date 13:25 2021/1/13
|
|
|
* @Param
|
|
|
* @return
|
|
|
**/
|
|
|
func (svr *PgLoginService) CheckIsPartner(phone string, companyId int64) (ok bool, err error) {
|
|
|
var (
|
|
|
PartnerInfoRepository, _ = repository.NewPartnerInfoRepository(svr.transactionContext)
|
|
|
)
|
|
|
svr.Phone = phone
|
|
|
user, err := PartnerInfoRepository.FindOne(map[string]interface{}{"account": phone, "status": 1})
|
|
|
if err != nil {
|
|
|
return false, err
|
|
|
}
|
|
|
if user != nil {
|
|
|
ok = true
|
|
|
} else {
|
|
|
ok = false
|
|
|
}
|
|
|
|
|
|
return ok, nil
|
|
|
}
|
|
|
|
|
|
//合伙人登录
|
|
|
func (svr *PgLoginService) PartnerLogin(phone string, password string) (err error) {
|
|
|
if len(svr.PartnerInfo) == 0 {
|
...
|
...
|
@@ -46,7 +161,7 @@ func (svr *PgLoginService) PartnerLogin(phone string, password string) (err erro |
|
|
return
|
|
|
}
|
|
|
if !strings.EqualFold(svr.PartnerInfo[0].Password, password) {
|
|
|
err = protocol.NewCustomMessage(1, "密码输入有误!")
|
|
|
err = protocol.NewCustomMessage(1, "密码输入错误!")
|
|
|
return
|
|
|
}
|
|
|
return
|
...
|
...
|
@@ -73,10 +188,12 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { |
|
|
response := make(map[string]interface{})
|
|
|
response["id"] = protocolx.AdminTypePartner
|
|
|
response["name"] = protocolx.AdminTypePartnerName
|
|
|
|
|
|
if len(svr.PartnerInfo) == 0 {
|
|
|
response["companys"] = make([]struct{}, 0)
|
|
|
return response, nil
|
|
|
}
|
|
|
|
|
|
var (
|
|
|
OrderDao, _ = dao.NewOrderBaseDao(svr.transactionContext)
|
|
|
BusinessBonusDao, _ = dao.NewBusinessBonusDao(svr.transactionContext)
|
...
|
...
|
@@ -87,6 +204,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { |
|
|
UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext)
|
|
|
adminApiGateway = http_gateway.NewHttplibBusinessAdminApiServiceGateway()
|
|
|
)
|
|
|
|
|
|
doGetCompanyIds := func() []int64 {
|
|
|
var companies []int64
|
|
|
for i := range svr.PartnerInfo {
|
...
|
...
|
@@ -94,6 +212,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { |
|
|
}
|
|
|
return companies
|
|
|
}
|
|
|
|
|
|
doGetPartnerIds := func() []int64 {
|
|
|
var array []int64
|
|
|
for i := range svr.PartnerInfo {
|
...
|
...
|
@@ -101,17 +220,21 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { |
|
|
}
|
|
|
return array
|
|
|
}
|
|
|
|
|
|
companyList = svr.GetCompanyList(doGetCompanyIds)
|
|
|
if len(companyList) == 0 {
|
|
|
return response, nil
|
|
|
}
|
|
|
|
|
|
totalBonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: doGetPartnerIds(), OrderTypes: domain.UserOrderTypes(domain.Career)})
|
|
|
if e != nil {
|
|
|
return response, e
|
|
|
}
|
|
|
|
|
|
if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: doGetPartnerIds(), IsDisable: 1}); e == nil {
|
|
|
totalBonus.Bonus += businessBonus.Bonus
|
|
|
}
|
|
|
|
|
|
_, allPartnerCategory, e = PartnerCategoryInfoRepository.Find(map[string]interface{}{"sortById": domain.ASC})
|
|
|
var mapPartnerBussinessBonus = make(map[int64]*domain.BusinessBonus)
|
|
|
if _, bussinessBonus, e := BusinessBonusRepository.Find(map[string]interface{}{"inPartnerIds": doGetPartnerIds(), "isDisable": 1}); e == nil {
|
...
|
...
|
@@ -129,6 +252,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { |
|
|
mapCompanyAdminUsers[adminUsers[i].CompanyId] = adminUsers[i]
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var companys = make([]*Company, 0)
|
|
|
for i := range companyList {
|
|
|
c := companyList[i]
|
...
|
...
|
@@ -166,13 +290,26 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { |
|
|
}
|
|
|
companys = append(companys, item)
|
|
|
}
|
|
|
|
|
|
if len(companys) > 0 {
|
|
|
svr.HasAvailableCompany = true
|
|
|
}
|
|
|
|
|
|
if len(companys) > 1 || len(svr.IsRealSenior) > 0 { // 有真实合伙公司或高管公司时,过滤游客公司
|
|
|
var companies = make([]*Company, 0)
|
|
|
for _, company := range companys {
|
|
|
if company.CompanyBase.Id != int64(constant.DEFAULT_GUEST_COMPANY) {
|
|
|
companies = append(companies, company)
|
|
|
}
|
|
|
}
|
|
|
companys = companies
|
|
|
}
|
|
|
|
|
|
response["companys"] = companys
|
|
|
return response, nil
|
|
|
}
|
|
|
|
|
|
// 高管统计信息
|
|
|
func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) {
|
|
|
response := make(map[string]interface{})
|
|
|
response["id"] = protocolx.AdminTypeManager
|
...
|
...
|
@@ -187,8 +324,8 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) { |
|
|
)
|
|
|
doGetCompanyIds := func() []int64 {
|
|
|
var companies []int64
|
|
|
for i := range svr.Users {
|
|
|
companies = append(companies, svr.Users[i].CompanyId)
|
|
|
for i := range svr.IsSenior {
|
|
|
companies = append(companies, svr.IsSenior[i].CompanyId)
|
|
|
}
|
|
|
return companies
|
|
|
}
|
...
|
...
|
@@ -200,9 +337,9 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) { |
|
|
if constant.POSTGRESQL_DB_NAME != "partner_dev" {
|
|
|
//通过企业平台 校验模块权限
|
|
|
var user *domain.Users
|
|
|
for j := range svr.Users {
|
|
|
if svr.Users[j].CompanyId == c.Id {
|
|
|
user = svr.Users[j]
|
|
|
for j := range svr.IsSenior {
|
|
|
if svr.IsSenior[j].CompanyId == c.Id {
|
|
|
user = svr.IsSenior[j]
|
|
|
break
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -219,12 +356,23 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) { |
|
|
companys = append(companys, item)
|
|
|
}
|
|
|
if len(companys) > 0 {
|
|
|
svr.HasAvailableCompany = true
|
|
|
svr.HasAvailableManagerCompany = true
|
|
|
}
|
|
|
|
|
|
if len(companys) > 1 || len(svr.IsPartnerInfo) > 0 { // 有真实合伙公司或高管公司时,过滤游客公司
|
|
|
var companies = make([]protocol.CompanyBase, 0)
|
|
|
for _, company := range companys {
|
|
|
if company.Id != int64(constant.DEFAULT_GUEST_COMPANY) {
|
|
|
companies = append(companies, company)
|
|
|
}
|
|
|
}
|
|
|
companys = companies
|
|
|
}
|
|
|
|
|
|
response["companys"] = companys
|
|
|
return response, nil
|
|
|
}
|
|
|
|
|
|
func (svr *PgLoginService) GetCompanyList(funcGetCompanyIds func() []int64) []*domain.Company {
|
|
|
var (
|
|
|
CompanyRepository, _ = repository.NewCompanyRepository(svr.transactionContext)
|
...
|
...
|
@@ -242,6 +390,7 @@ func (svr *PgLoginService) GetCompanyList(funcGetCompanyIds func() []int64) []*d |
|
|
}
|
|
|
return companyList
|
|
|
}
|
|
|
|
|
|
func (svr *PgLoginService) GetJoinWays(partnerCategory []*domain.PartnerCategoryInfo, partnerInfo *domain.PartnerInfo, bonus float64) []joinWay {
|
|
|
searchCategory := func(partnerCategory []*domain.PartnerCategoryInfo, id int64) *domain.PartnerCategoryInfo {
|
|
|
for i := range partnerCategory {
|
...
|
...
|
@@ -285,16 +434,182 @@ func computeBonusPercent(totalBonus float64, bonus float64) float64 { |
|
|
return utils.Decimal(bonus / totalBonus)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @Author SteveChan
|
|
|
* @Description // 注册用户到合伙人
|
|
|
* @Date 13:52 2021/1/13
|
|
|
* @Param
|
|
|
* @return
|
|
|
**/
|
|
|
func (svr *PgLoginService) RegistryUser(phone string) error {
|
|
|
var (
|
|
|
PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext)
|
|
|
UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext)
|
|
|
isPartner bool
|
|
|
isPartnerAvailable bool
|
|
|
isGuestPartner bool
|
|
|
isGuestPartnerAvailable bool
|
|
|
isUser bool
|
|
|
isUserAvailable bool
|
|
|
isUserSenior bool
|
|
|
)
|
|
|
|
|
|
partnerInfo, _ := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "isNot": constant.DEFAULT_GUEST_COMPANY}) // 合伙人在正常公司是否存在
|
|
|
if partnerInfo == nil {
|
|
|
isPartner = false
|
|
|
} else {
|
|
|
isPartner = true
|
|
|
}
|
|
|
partnerAvailableInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "status": 1, "isNot": constant.DEFAULT_GUEST_COMPANY}) // 合伙人在正常公司是否有效
|
|
|
if partnerAvailableInfo == nil {
|
|
|
isPartnerAvailable = false
|
|
|
} else {
|
|
|
isPartnerAvailable = true
|
|
|
}
|
|
|
|
|
|
guestInfo, _ := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "companyId": constant.DEFAULT_GUEST_COMPANY}) // 合伙人是否存在游客公司
|
|
|
if guestInfo == nil {
|
|
|
isGuestPartner = false
|
|
|
} else {
|
|
|
isGuestPartner = true
|
|
|
}
|
|
|
guestAvailableInfo, _ := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "status": 1, "companyId": constant.DEFAULT_GUEST_COMPANY}) // 合伙人在游客公司是否有效
|
|
|
if guestAvailableInfo == nil {
|
|
|
isGuestPartnerAvailable = false
|
|
|
} else {
|
|
|
isGuestPartnerAvailable = true
|
|
|
}
|
|
|
|
|
|
user, _ := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true}) // 用户是否存在
|
|
|
if user == nil {
|
|
|
isUser = false
|
|
|
} else {
|
|
|
isUser = true
|
|
|
}
|
|
|
userAvailable, _ := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "status": 1, "deleteAtIsNull": true}) // 用户是否有效
|
|
|
if userAvailable == nil {
|
|
|
isUserAvailable = false
|
|
|
} else {
|
|
|
isUserAvailable = true
|
|
|
}
|
|
|
senior, _ := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "status": 1, "isSenior": 1, "deleteAtIsNull": true}) // 用户是否是高管
|
|
|
if senior == nil {
|
|
|
isUserSenior = false
|
|
|
} else {
|
|
|
isUserSenior = true
|
|
|
}
|
|
|
|
|
|
fmt.Print("合伙人在正常公司存在?", isPartner, "\n")
|
|
|
fmt.Print("合伙人在正常公司有效?", isPartnerAvailable, "\n")
|
|
|
|
|
|
fmt.Print("合伙人在游客公司存在?", isGuestPartner, "\n")
|
|
|
fmt.Print("合伙人在游客公司有效?", isGuestPartnerAvailable, "\n")
|
|
|
|
|
|
fmt.Print("用户存在?", isUser, "\n")
|
|
|
fmt.Print("用户有效?", isUserAvailable, "\n")
|
|
|
fmt.Print("用户高管?", isUserSenior, "\n")
|
|
|
|
|
|
// 用户在正常公司存在且无效或者不存在、合伙人在正常公司存在且无效或者不存在、合伙人在游客公司存在且无效,更新游客公司合伙人状态
|
|
|
//if (isUser && !isUserAvailable || !isUser) && (isPartner && !isPartnerAvailable || !isPartner) && (isGuestPartner && !isGuestPartnerAvailable) {
|
|
|
// _, err := svr.transactionContext.PgTx.Model(&models.PartnerInfo{
|
|
|
// CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
|
|
|
// PartnerName: phone,
|
|
|
// Account: phone,
|
|
|
// Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
|
|
|
// PartnerCategory: 1,
|
|
|
// RegionInfo: &domain.RegionInfo{
|
|
|
// RegionName: "客户区域",
|
|
|
// RegionId: 0,
|
|
|
// },
|
|
|
// Status: 1,
|
|
|
// CooperateTime: time.Now(),
|
|
|
// CreateAt: time.Now(),
|
|
|
// UpdateAt: time.Now(),
|
|
|
// PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
|
|
|
// Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}}}).
|
|
|
// Where("partner_info.account = ?", phone).
|
|
|
// Where("partner_info.company_id = ?", constant.DEFAULT_GUEST_COMPANY).
|
|
|
// Update()
|
|
|
// if err != nil {
|
|
|
// return err
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
// 合伙人存在、用户存在、是高管(高管合伙人)
|
|
|
// 合伙人不存在、用户存在、是高管(高管)|| partnerInfo == nil && user != nil && senior != nil
|
|
|
// 合伙人存在、用户存在、非高管(合伙人)
|
|
|
// 游客公司合伙人存在
|
|
|
//if partnerInfo != nil && user != nil && senior != nil || partnerInfo != nil && user != nil && senior == nil || guestInfo != nil {
|
|
|
// return nil
|
|
|
//}
|
|
|
if guestInfo != nil {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// 用户在正常公司存在且无效或者存在非高管或者不存在、合伙人在正常公司存在且无效或者不存在、合伙人在游客公司不存在、注册合伙人到游客公司
|
|
|
if !isGuestPartner && (isUser && !isUserAvailable || isUser && !isUserSenior || !isUser) && (isPartner && !isPartnerAvailable || !isPartner) {
|
|
|
id := time.Now().Unix()
|
|
|
errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
|
|
|
Id: id,
|
|
|
CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
|
|
|
PartnerName: phone,
|
|
|
Account: phone,
|
|
|
Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
|
|
|
Status: 1,
|
|
|
PartnerCategory: 1,
|
|
|
RegionInfo: &domain.RegionInfo{
|
|
|
RegionName: "客户区域",
|
|
|
RegionId: 0,
|
|
|
},
|
|
|
CooperateTime: time.Now(),
|
|
|
CreateAt: time.Now(),
|
|
|
UpdateAt: time.Now(),
|
|
|
PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
|
|
|
Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// 合伙人不存在、用户存在、非高管(普通用户)-> 注册用户
|
|
|
// 合伙人不存在、用户不存在(游客)-> 注册用户
|
|
|
//if errPartner != nil && errUser == nil && errSenior == nil || errPartner != nil && errUser != nil {
|
|
|
// id := time.Now().Unix()
|
|
|
// errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
|
|
|
// Id: id,
|
|
|
// CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
|
|
|
// PartnerName: phone,
|
|
|
// Account: phone,
|
|
|
// Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
|
|
|
// Status: 1,
|
|
|
// PartnerCategory: 1,
|
|
|
// RegionInfo: &domain.RegionInfo{
|
|
|
// RegionName: "客户区域",
|
|
|
// RegionId: 0,
|
|
|
// },
|
|
|
// CooperateTime: time.Now(),
|
|
|
// CreateAt: time.Now(),
|
|
|
// UpdateAt: time.Now(),
|
|
|
// PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
|
|
|
// Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
|
|
|
// })
|
|
|
//}
|
|
|
|
|
|
return errPartner
|
|
|
}
|
|
|
|
|
|
// 注册游客到指定的公司
|
|
|
func (svr *PgLoginService) RegistryGuest(phone string) error {
|
|
|
var (
|
|
|
PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext)
|
|
|
UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext)
|
|
|
)
|
|
|
|
|
|
partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone})
|
|
|
user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone})
|
|
|
user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true})
|
|
|
|
|
|
if partnerInfo != nil || user != nil {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
if errUser != nil && errPartner != nil {
|
|
|
id := time.Now().Unix()
|
|
|
errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
|
...
|
...
|
|