作者 yangfu

1.review code

... ... @@ -13,3 +13,7 @@ require (
github.com/shopspring/decimal v1.2.0
github.com/tiptok/gocomm v1.0.2
)
replace (
github.com/tiptok/gocomm v1.0.2 => F:\go\src\learn_project\gocomm
)
... ...
... ... @@ -19,6 +19,7 @@ import (
"time"
)
// 该方法废弃
func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp *protocol.LoginResponse, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
... ... @@ -222,7 +223,7 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT
return
}
//验证短信验证码 T
// 验证短信验证码 T
func CheckSmsCode(phone, code string) (result bool, err error) {
sms, _ := factory.CreateSmsCodeService()
var data map[string]interface{}
... ... @@ -236,7 +237,7 @@ func CheckSmsCode(phone, code string) (result bool, err error) {
return
}
//验证手机号码(修改手机号码、重置密码的前一步)
// 验证手机号码(修改手机号码、重置密码的前一步)
func AuthCheckSmsCode(header *protocol.RequestHeader, request *protocol.AuthCheckSmsCodeRequest) (rsp *protocol.AuthCheckSmsCodeResponse, err error) {
var ()
if _, err = CheckSmsCode(request.Phone, request.Captcha); err != nil {
... ... @@ -248,7 +249,7 @@ func AuthCheckSmsCode(header *protocol.RequestHeader, request *protocol.AuthChec
return
}
//注销登录
// 注销登录
func Revoke(header *protocol.RequestHeader, request *protocol.RevokeRequest) (rsp *protocol.RevokeResponse, err error) {
//auth := userAuth.NewRedisUserAuth(userAuth.WithUserId(header.UserId))
//rsp = &protocol.RevokeResponse{}
... ... @@ -263,7 +264,7 @@ func Revoke(header *protocol.RequestHeader, request *protocol.RevokeRequest) (rs
return
}
//注销登录
// 注销登录
func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol.RevokeResponse, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
... ... @@ -300,7 +301,8 @@ func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol.
return
}
func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCompanysRequest) (v interface{}, err error) {
// 企业平台-多公司登录
func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCompanysRequest) (v interface{}, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
imInfo *domain.ImInfo
... ... @@ -320,14 +322,14 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom
defer func() {
transactionContext.RollbackTransaction()
}()
// 通过短信验证码登录的游客,注册一个账号到配置的公司去(ios审核使用)
if request.GrantType == protocol.LoginBySmsCode {
e := loginSvr.RegistryGuest(request.Phone)
if e != nil {
log.Error(e)
}
}
// loginSvr 初始化
loginSvr.Init(request.Phone)
if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 {
err = protocol.NewErrWithMessage(10001)
... ... @@ -365,22 +367,21 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom
break
}
//获取统计信息
// 获取统计信息(合伙人/高管)
rsp.Partner, _ = loginSvr.PartnerStaticInfo()
rsp.Manager, _ = loginSvr.ManagerStaticInfo()
//没有有效人的时候
if !loginSvr.AvailableCompany {
if !loginSvr.HasAvailableCompany {
err = protocol.NewErrWithMessage(10008) //账号禁用
return
}
// 初始化网易IM信息
var nickName string
if len(loginSvr.Users) > 0 {
nickName = loginSvr.Users[0].Name
} else if len(loginSvr.PartnerInfo) > 0 {
nickName = loginSvr.PartnerInfo[0].PartnerName
}
//初始化im信息
if imInfo, err = InitOrUpdateUserIMInfo(int64(phoneId), nickName, transactionContext); err != nil {
log.Error(err)
return
... ... @@ -395,12 +396,13 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom
//添加手机对应的凭证
userAuth.NewRedisUserCredential(request.Phone).AddAuth(rsp.Credentials)
err = transactionContext.CommitTransaction()
v = map[string]interface{}{"center": rsp}
err = transactionContext.CommitTransaction()
return
}
func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest) (rsp *protocolx.CompanysResponse, err error) {
// 企业平台-多公司登录 - 通过凭证
func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protocolx.CompanysRequest) (rsp *protocolx.CompanysResponse, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
loginSvr = domain_service.NewPgLoginService(transactionContext)
... ... @@ -424,11 +426,12 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest
err = protocol.NewErrWithMessage(4140, err)
return
}
// loginSvr 初始化
loginSvr.Init(claim.Phone)
rsp.Partner, _ = loginSvr.PartnerStaticInfo()
rsp.Manager, _ = loginSvr.ManagerStaticInfo()
//没有有效人的时候
if !loginSvr.AvailableCompany {
if !loginSvr.HasAvailableCompany {
err = protocol.NewErrWithMessage(4140, err) //账号禁用
return
}
... ... @@ -437,6 +440,7 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest
return
}
// 登录
func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) (rsp *protocol.LoginResponse, err error) {
var (
claim *utils.UserTokenClaims
... ... @@ -477,12 +481,12 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) (
return
}
}
//验证公司模块权限
if _, adminUsers, e := UsersRepository.Find(map[string]interface{}{"inCompanyIds": []int64{int64(request.Cid)}, "adminType": 2, "deleteAtIsNull": true}); e == nil {
if len(adminUsers) > 0 {
au := adminUsers[0]
if code, e := adminApiGateway.UserAuth(au.Id, constant.BUSINESS_ADMIN_PLATFORM_ID); e != nil || code != 0 {
log.Debug("【合伙人检查权限】", claim.Phone, "【公司】", request.Cid, au.Id, code, e.Error())
//合伙人 需要验证对应公司模块权限(查询该公司的主管理员是否有权限)
if _, admins, e := UsersRepository.Find(map[string]interface{}{"inCompanyIds": []int64{int64(request.Cid)}, "adminType": 2, "deleteAtIsNull": true}); e == nil {
if len(admins) > 0 {
admin := admins[0]
if code, e := adminApiGateway.UserAuth(admin.Id, constant.BUSINESS_ADMIN_PLATFORM_ID); e != nil || code != 0 {
log.Debug("【合伙人检查权限】", claim.Phone, "【公司】", request.Cid, admin.Id, code, e.Error())
err = protocol.NewErrWithMessage(10008, err) // 抱歉,企业管理员未帮您开通权限
return
}
... ... @@ -497,7 +501,7 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) (
return
}
}
//校验模块权限
//高管 需要校验高管是否模块权限
if userId != 0 {
if code, e := adminApiGateway.UserAuth(userId, constant.BUSINESS_ADMIN_PLATFORM_ID); e != nil || code != 0 {
log.Debug("【检查权限】", userId, "【公司】", request.Cid, "【错误】:", code, e.Error())
... ... @@ -514,7 +518,8 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) (
err = protocol.NewErrWithMessage(10001, err) //账号不存在
return
}
//根据simnum + cid
// 生成授权码
userClaims := utils.UserTokenClaims{
UserId: userId,
CompanyId: int64(request.Cid),
... ...
... ... @@ -2,6 +2,7 @@ package company
import (
"github.com/tiptok/gocomm/pkg/log"
"github.com/tiptok/gocomm/sync/task"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction"
... ... @@ -11,6 +12,7 @@ import (
"strings"
)
// 公司属性 合伙人类型/区域
func Property(header *protocol.RequestHeader, request *protocolx.PropertyRequest) (rsp *protocolx.PropertyResponse, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
... ... @@ -24,14 +26,19 @@ func Property(header *protocol.RequestHeader, request *protocolx.PropertyRequest
transactionContext.RollbackTransaction()
}()
//用户查询区域
if (request.Action & 0x01) > 0 {
rsp.Districts, _ = getDistricts(header.UserId, transactionContext)
}
//查询合伙人类型
if (request.Action & 0x02) > 0 {
rsp.JoinWays, _ = getJoinWays(transactionContext)
}
//并行查询区域/合伙人类型
task.Parallel(
func() {
if (request.Action & 0x01) > 0 {
rsp.Districts, _ = getDistricts(header.UserId, transactionContext)
}
},
func() {
if (request.Action & 0x02) > 0 {
rsp.JoinWays, _ = getJoinWays(transactionContext)
}
},
)
err = transactionContext.CommitTransaction()
return
}
... ... @@ -205,6 +212,32 @@ func getPartners(userId int64, request *protocolx.PartnersRequest, transactionCo
}
}
queryOption := newQueryOption(request)
if partners, e := PartnerInfo.Partners(user.AccessPartnerIds(), queryOption); e == nil {
var array []interface{}
for i := range partners {
mapPartner := make(map[string]interface{})
p := partners[i]
mapPartner["uid"] = p.Id
mapPartner["uname"] = p.PartnerName
mapPartner["joinWays"] = newJoinWays(mapCategoryInfo, p)
if p.RegionInfo != nil {
mapPartner["district"] = protocolx.Districts{Id: p.RegionInfo.RegionId, Name: p.RegionInfo.RegionName}
}
mapPartner["cooperationTime"] = p.CooperateTime.Unix() * 1000
mapPartner["dividend"] = utils.Decimal(p.Bonus)
mapPartner["ordersCount"] = p.Total
mapPartner["ordersMoney"] = utils.Decimal(p.Amount)
array = append(array, mapPartner)
}
return array, nil
}
return nil, nil
}
// 查询参数
func newQueryOption(request *protocolx.PartnersRequest) map[string]interface{} {
queryOption := make(map[string]interface{})
if len(request.Districts) > 0 {
... ... @@ -234,33 +267,16 @@ func getPartners(userId int64, request *protocolx.PartnersRequest, transactionCo
if request.SortBy != 0 {
queryOption["sortByBonus"] = domain.ASC
}
return queryOption
}
if partners, e := PartnerInfo.Partners(user.AccessPartnerIds(), queryOption); e == nil {
var array []interface{}
for i := range partners {
mapPartners := make(map[string]interface{})
p := partners[i]
mapPartners["uid"] = p.Id
mapPartners["uname"] = p.PartnerName
var joinWays []protocolx.JoinWays
for j := range p.PartnerCategoryInfos {
c := p.PartnerCategoryInfos[j]
if v, ok := mapCategoryInfo[c.Id]; ok {
joinWays = append(joinWays, protocolx.JoinWays{Type: v.Id, Name: v.Name})
}
}
mapPartners["joinWays"] = joinWays
if p.RegionInfo != nil {
mapPartners["district"] = protocolx.Districts{Id: p.RegionInfo.RegionId, Name: p.RegionInfo.RegionName}
}
mapPartners["cooperationTime"] = p.CooperateTime.Unix() * 1000
mapPartners["dividend"] = utils.Decimal(p.Bonus)
mapPartners["ordersCount"] = p.Total
mapPartners["ordersMoney"] = utils.Decimal(p.Amount)
array = append(array, mapPartners)
func newJoinWays(mapCategoryInfo map[int64]*domain.PartnerCategoryInfo, p *domain.PartnerStatics) []protocolx.JoinWays {
var joinWays []protocolx.JoinWays
for j := range p.PartnerCategoryInfos {
c := p.PartnerCategoryInfos[j]
if v, ok := mapCategoryInfo[c.Id]; ok {
joinWays = append(joinWays, protocolx.JoinWays{Type: v.Id, Name: v.Name})
}
return array, nil
}
return nil, nil
return joinWays
}
... ...
... ... @@ -48,8 +48,8 @@ func getPartnersV2(userId int64, request *protocolx.PartnersRequest, transaction
}
var company *domain.Company
var CompanyResponsitory, _ = factory.CreateCompanyRepository(transactionContext)
if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": user.CompanyId}); err != nil {
var CompanyRepository, _ = factory.CreateCompanyRepository(transactionContext)
if company, err = CompanyRepository.FindOne(map[string]interface{}{"id": user.CompanyId}); err != nil {
return nil, err
}
... ... @@ -63,7 +63,31 @@ func getPartnersV2(userId int64, request *protocolx.PartnersRequest, transaction
}
}
queryOption := newQueryOptionV2(request)
if partners, e := PartnerInfo.Partners(user.AccessPartnerIds(), queryOption); e == nil {
var array []interface{}
for i := range partners {
mapPartners := make(map[string]interface{})
p := partners[i]
mapPartners["uid"] = p.Id
mapPartners["uname"] = p.PartnerName
mapPartners["joinWays"] = newJoinWays(mapCategoryInfo, p)
mapPartners["dividend"] = utils.Decimal(p.Bonus)
mapPartners["ordersCount"] = p.Total
mapPartners["ordersMoney"] = utils.Decimal(p.Amount)
mapPartners["phone"] = p.Account
mapPartners["company"] = newCompany(company, p)
array = append(array, mapPartners)
}
return array, nil
}
return nil, nil
}
// 查询参数
func newQueryOptionV2(request *protocolx.PartnersRequest) map[string]interface{} {
queryOption := make(map[string]interface{})
if len(request.Districts) > 0 {
var districts []string
for i := 0; i < len(request.Districts); i++ {
... ... @@ -91,77 +115,23 @@ func getPartnersV2(userId int64, request *protocolx.PartnersRequest, transaction
if request.SortBy != 0 {
queryOption["sortByBonus"] = domain.ASC
}
if partners, e := PartnerInfo.Partners(user.AccessPartnerIds(), queryOption); e == nil {
var array []interface{}
for i := range partners {
mapPartners := make(map[string]interface{})
p := partners[i]
mapPartners["uid"] = p.Id
mapPartners["uname"] = p.PartnerName
var joinWays []protocolx.JoinWays
for j := range p.PartnerCategoryInfos {
c := p.PartnerCategoryInfos[j]
if v, ok := mapCategoryInfo[c.Id]; ok {
joinWays = append(joinWays, protocolx.JoinWays{Type: v.Id, Name: v.Name})
}
}
mapPartners["joinWays"] = joinWays
mapPartners["dividend"] = utils.Decimal(p.Bonus)
mapPartners["ordersCount"] = p.Total
mapPartners["ordersMoney"] = utils.Decimal(p.Amount)
mapPartners["phone"] = p.Account
partnerCompany := userx.Company{
Id: company.Id,
Name: company.Name,
Phone: company.Phone,
SerialNo: p.Id,
CooperateTime: p.CooperateTime.Unix() * 1000,
MiniProgram: nil,
District: map[string]interface{}{"id": p.RegionInfo.RegionId, "name": p.RegionInfo.RegionName},
}
if len(p.Salesman) > 0 {
partnerCompany.Salesman = map[string]interface{}{"uname": p.Salesman[0].Name, "phone": p.Salesman[0].Telephone}
} else {
partnerCompany.Salesman = map[string]interface{}{}
}
mapPartners["company"] = partnerCompany
array = append(array, mapPartners)
}
return array, nil
}
return nil, nil
return queryOption
}
func funcPartnerCompanyInfo(companyId int64, transactionContext *transaction.TransactionContext) (partnerCompany userx.Company, err error) {
var (
CompanyResponsitory, _ = factory.CreateCompanyRepository(transactionContext)
company *domain.Company
)
if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": companyId}); err != nil {
return
func newCompany(company *domain.Company, p *domain.PartnerStatics) userx.Company {
partnerCompany := userx.Company{
Id: company.Id,
Name: company.Name,
Phone: company.Phone,
SerialNo: p.Id,
CooperateTime: p.CooperateTime.Unix() * 1000,
MiniProgram: nil,
District: map[string]interface{}{"id": p.RegionInfo.RegionId, "name": p.RegionInfo.RegionName},
}
partnerCompany = userx.Company{
Id: company.Id,
Name: company.Name,
Phone: company.Phone,
//SerialNo: partnerInfo.Id,
//CooperateTime: partnerInfo.CooperateTime.Unix() * 1000,
MiniProgram: nil,
//District: map[string]interface{}{"id": partnerInfo.RegionInfo.RegionId, "name": partnerInfo.RegionInfo.RegionName},
if len(p.Salesman) > 0 {
partnerCompany.Salesman = map[string]interface{}{"uname": p.Salesman[0].Name, "phone": p.Salesman[0].Telephone}
} else {
partnerCompany.Salesman = map[string]interface{}{}
}
//if len(partnerInfo.Salesman) > 0 {
// u.CooperateCompany.Salesman = map[string]interface{}{"uname": partnerInfo.Salesman[0].Name, "phone": partnerInfo.Salesman[0].Telephone}
//} else {
// u.CooperateCompany.Salesman = map[string]interface{}{}
//}
//rspMap["user"] = u
//rsp = rspMap
return
return partnerCompany
}
... ...
... ... @@ -124,11 +124,10 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR
rsp = &protocol.DividendOrdersResponse{List: make([]*protocol.DividendOrderListItem, 0)}
count, orders, err = OrderDao.DividendOrders(&domain.DividendOrdersQueryOption{
OrderTypes: domain.UserOrderTypes(domain.Career),
PartnerId: request.PartnerId,
DetailAction: request.DetailAction,
DividendAction: request.DividendAction,
//IsDisable: "0",
OrderTypes: domain.UserOrderTypes(domain.Career),
PartnerId: request.PartnerId,
DetailAction: request.DetailAction,
DividendAction: request.DividendAction,
StartTime: request.StartTime,
EndTime: request.EndTime,
Offset: request.PageIndex * request.PageSize,
... ... @@ -145,7 +144,7 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR
item := &protocol.DividendOrderListItem{
Id: o.Id,
DeliveryNo: o.DeliveryCode,
OrderAmount: s.PlanOrderAmount, //s.OrderAmount(),
OrderAmount: s.PlanOrderAmount,
DividendReceivable: utils.Decimal(s.OrderTotalReceivable()),
}
rsp.List = append(rsp.List, item)
... ...
package order
import (
"github.com/tiptok/gocomm/sync/task"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
... ... @@ -23,9 +24,8 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.OrderStatist
rsp = &protocol.OrderStatisticsResponse{}
//事业分红/业务分红
var total float64 //,developBonus,appBonus,careerBonus, businessBonus,
var total float64
if bonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career)}); e == nil {
//careerBonus = bonus.Bonus
total += bonus.Bonus
}
calcOrderStatic := func(catId int, total float64) protocol.OrderStatic {
... ... @@ -55,10 +55,12 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.OrderStatist
CumulativeMoney: utils.Decimal(cumulativeMoney),
}
}
rsp.Career = calcOrderStatic(domain.Career, total)
rsp.Business = calcOrderStatic(domain.Business, total)
rsp.Develop = calcOrderStatic(domain.Develop, total)
rsp.App = calcOrderStatic(domain.App, total)
task.Parallel(
func() { rsp.Career = calcOrderStatic(domain.Career, total) },
func() { rsp.Business = calcOrderStatic(domain.Business, total) },
func() { rsp.Develop = calcOrderStatic(domain.Develop, total) },
func() { rsp.App = calcOrderStatic(domain.App, total) },
)
err = transactionContext.CommitTransaction()
return
... ...
... ... @@ -12,6 +12,7 @@ import (
protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/partner"
)
// 模块已废弃
func Detail(header *protocol.RequestHeader, request *protocolx.DetailRequest) (rsp *protocolx.DetailResponse, err error) {
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
... ...
... ... @@ -22,14 +22,14 @@ import (
//用户信息
func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) (rsp *protocol.UserInfoResponse, err error) {
var (
partnerInfo *domain.PartnerInfo
transactionContext, _ = factory.CreateTransactionContext(nil)
CompanyResponsitory, _ = factory.CreateCompanyRepository(transactionContext)
PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext)
UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
ImInfoRepository, _ = factory.CreateImInfoRepository(transactionContext)
company *domain.Company
user *domain.Users
partnerInfo *domain.PartnerInfo
transactionContext, _ = factory.CreateTransactionContext(nil)
CompanyRepository, _ = factory.CreateCompanyRepository(transactionContext)
PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext)
UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
ImInfoRepository, _ = factory.CreateImInfoRepository(transactionContext)
company *domain.Company
user *domain.Users
)
if err = transactionContext.StartTransaction(); err != nil {
return nil, err
... ... @@ -44,7 +44,7 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest)
err = protocol.NewErrWithMessage(502, err) //账号不存在
return
}
if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil {
if company, err = CompanyRepository.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil {
return
}
rsp.User = protocol.User{
... ... @@ -72,7 +72,7 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest)
err = protocol.NewErrWithMessage(502, err) //账号不存在
return
}
if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil {
if company, err = CompanyRepository.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil {
return
}
rsp.User = protocol.User{
... ... @@ -188,13 +188,13 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass
func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoRequest) (rsp interface{}, err error) {
var (
partnerInfo *domain.PartnerInfo
transactionContext, _ = factory.CreateTransactionContext(nil)
CompanyResponsitory, _ = factory.CreateCompanyRepository(transactionContext)
PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext)
UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
company *domain.Company
user *domain.Users
partnerInfo *domain.PartnerInfo
transactionContext, _ = factory.CreateTransactionContext(nil)
CompanyRepository, _ = factory.CreateCompanyRepository(transactionContext)
PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext)
UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
company *domain.Company
user *domain.Users
)
if err = transactionContext.StartTransaction(); err != nil {
return nil, err
... ... @@ -209,7 +209,7 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques
err = protocol.NewErrWithMessage(502, err) //账号不存在
return
}
if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil {
if company, err = CompanyRepository.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil {
return
}
var miniProgram map[string]interface{}
... ... @@ -253,7 +253,7 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques
err = protocol.NewErrWithMessage(502, err) //账号不存在
return
}
if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil {
if company, err = CompanyRepository.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil {
return
}
rspMap["user"] = userx.User{
... ...
... ... @@ -23,7 +23,8 @@ type PgLoginService struct {
PartnerInfo []*domain.PartnerInfo
Users []*domain.Users
transactionContext *transaction.TransactionContext
AvailableCompany bool
// 标识:登录的账号信息是否有可用的公司, true:有 false:没有
HasAvailableCompany bool
}
func (svr *PgLoginService) Init(phone string) (err error) {
... ... @@ -166,7 +167,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
companys = append(companys, item)
}
if len(companys) > 0 {
svr.AvailableCompany = true
svr.HasAvailableCompany = true
}
response["companys"] = companys
... ... @@ -218,7 +219,7 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) {
companys = append(companys, item)
}
if len(companys) > 0 {
svr.AvailableCompany = true
svr.HasAvailableCompany = true
}
response["companys"] = companys
... ... @@ -341,7 +342,7 @@ type joinWay struct {
func NewPgLoginService(ctx *transaction.TransactionContext) *PgLoginService {
return &PgLoginService{
transactionContext: ctx,
AvailableCompany: false,
transactionContext: ctx,
HasAvailableCompany: false,
}
}
... ...
... ... @@ -183,7 +183,7 @@ func (this *AuthController) CenterCompanys() {
return
}
header := this.GetRequestHeader(this.Ctx)
data, err := auth.CenterCompanys(header, request)
data, err := auth.CompaniesLogin(header, request)
if err != nil {
log.Error(err)
}
... ... @@ -211,7 +211,7 @@ func (this *AuthController) Companys() {
return
}
header := this.GetRequestHeader(this.Ctx)
data, err := auth.Companys(header, request)
data, err := auth.CompaniesLoginByCredential(header, request)
if err != nil {
log.Error(err)
}
... ...
... ... @@ -29,7 +29,7 @@ type LoginResponse struct {
type LoginRequestV2 struct {
Cid int `json:"cid"`
IdType int `json:"idType"`
IdType int `json:"idType"` // 用户类型 1:合伙人 2:高管
Credentials string `json:"credentials"` // 登录类型 1:密码 2:验证码
ClientId string `json:"clientId"`
}
... ...