作者 yangfu

Merge remote-tracking branch 'origin/test'

... ... @@ -70,6 +70,8 @@ spec:
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
value: "1000"
- name: DEFAULT_GUEST_COMPANY
value: "10011"
- name: ABILITY_SERVICE_HOST
value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com"
- name: MMM_OPEN_API_SERVICE_HOST
... ...
... ... @@ -70,6 +70,8 @@ spec:
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
value: "1000"
- name: DEFAULT_GUEST_COMPANY
value: "12"
- name: ABILITY_SERVICE_HOST
value: "https://ability.fjmaimaimai.com"
- name: MMM_OPEN_API_SERVICE_HOST
... ...
... ... @@ -70,6 +70,8 @@ spec:
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
value: "1000"
- name: DEFAULT_GUEST_COMPANY
value: "358"
- name: ABILITY_SERVICE_HOST
value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com"
- name: MMM_OPEN_API_SERVICE_HOST
... ...
... ... @@ -320,6 +320,14 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom
defer func() {
transactionContext.RollbackTransaction()
}()
if request.GrantType == protocol.LoginBySmsCode {
e := loginSvr.RegistryGuest(request.Phone)
if e != nil {
log.Error(e)
}
}
loginSvr.Init(request.Phone)
if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 {
err = protocol.NewErrWithMessage(10001)
... ...
package constant
import "os"
import (
"os"
"strconv"
)
const SERVICE_NAME = "partner"
... ... @@ -14,6 +17,8 @@ var UCENTER_APP_KEY = "0c2c2a23dfc64ae230f5c54ab243ab52"
var BUSINESS_ADMIN_SERVICE_HOST = "http://suplus-business-admin-dev.fjmaimaimai.com"
var BUSINESS_ADMIN_PLATFORM_ID = "25" //合伙人模块
var DEFAULT_GUEST_COMPANY int = 10011
func init() {
if os.Getenv("LOG_LEVEL") != "" {
LOG_LEVEL = os.Getenv("LOG_LEVEL")
... ... @@ -24,4 +29,7 @@ func init() {
if os.Getenv("BUSINESS_ADMIN_SERVICE_HOST") != "" {
BUSINESS_ADMIN_SERVICE_HOST = os.Getenv("BUSINESS_ADMIN_SERVICE_HOST")
}
if v := os.Getenv("DEFAULT_GUEST_COMPANY"); v != "" {
DEFAULT_GUEST_COMPANY, _ = strconv.Atoi(v)
}
}
... ...
... ... @@ -5,6 +5,7 @@ import (
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/repository"
http_gateway "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/svr"
... ... @@ -13,6 +14,7 @@ import (
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/auth"
"strings"
"time"
)
type PgLoginService struct {
... ... @@ -282,6 +284,41 @@ func computeBonusPercent(totalBonus float64, bonus float64) float64 {
return utils.Decimal(bonus / totalBonus)
}
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})
if partnerInfo != nil || user != nil {
return nil
}
if errUser != nil && errPartner != 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}},
Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
})
}
return errPartner
}
type Company struct {
protocol.CompanyBase
// 收入占比
... ...