正在显示
23 个修改的文件
包含
623 行增加
和
28 行删除
@@ -5,10 +5,10 @@ go 1.14 | @@ -5,10 +5,10 @@ go 1.14 | ||
5 | require ( | 5 | require ( |
6 | github.com/astaxie/beego v1.12.1 | 6 | github.com/astaxie/beego v1.12.1 |
7 | github.com/dgrijalva/jwt-go v3.2.0+incompatible | 7 | github.com/dgrijalva/jwt-go v3.2.0+incompatible |
8 | - github.com/gin-gonic/gin v1.4.0 | 8 | + github.com/gin-gonic/gin v1.5.0 |
9 | github.com/go-pg/pg/v10 v10.0.0-beta.2 | 9 | github.com/go-pg/pg/v10 v10.0.0-beta.2 |
10 | github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 | 10 | github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 |
11 | github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect | 11 | github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect |
12 | github.com/shopspring/decimal v1.2.0 | 12 | github.com/shopspring/decimal v1.2.0 |
13 | - github.com/tiptok/gocomm v1.0.0 | 13 | + github.com/tiptok/gocomm v1.0.1 |
14 | ) | 14 | ) |
@@ -4,9 +4,12 @@ import ( | @@ -4,9 +4,12 @@ import ( | ||
4 | "fmt" | 4 | "fmt" |
5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" | 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" |
6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
7 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/domain_service" | ||
7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" |
8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" | 9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" |
9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | 10 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" |
11 | + protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/auth" | ||
12 | + "strconv" | ||
10 | "strings" | 13 | "strings" |
11 | "time" | 14 | "time" |
12 | ) | 15 | ) |
@@ -68,7 +71,7 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp | @@ -68,7 +71,7 @@ func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp | ||
68 | } | 71 | } |
69 | rsp.AuthCode, _ = utils.GenerateToken(partnerInfo.Id, request.Phone, protocol.AuthCodeExpire*time.Second) | 72 | rsp.AuthCode, _ = utils.GenerateToken(partnerInfo.Id, request.Phone, protocol.AuthCodeExpire*time.Second) |
70 | 73 | ||
71 | - if err = InitOrUpdateUserIMInfo(partnerInfo, transactionContext); err != nil { | 74 | + if _, err = InitOrUpdateUserIMInfo(partnerInfo.Id, partnerInfo.PartnerName, transactionContext); err != nil { |
72 | log.Error(err) | 75 | log.Error(err) |
73 | return | 76 | return |
74 | } | 77 | } |
@@ -220,3 +223,145 @@ func Revoke(header *protocol.RequestHeader, request *protocol.RevokeRequest) (rs | @@ -220,3 +223,145 @@ func Revoke(header *protocol.RequestHeader, request *protocol.RevokeRequest) (rs | ||
220 | //} | 223 | //} |
221 | return | 224 | return |
222 | } | 225 | } |
226 | + | ||
227 | +func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCompanysRequest) (rsp *protocolx.CenterCompanysResponse, err error) { | ||
228 | + var ( | ||
229 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
230 | + imInfo *domain.ImInfo | ||
231 | + loginSvr = domain_service.NewPgLoginService(transactionContext) | ||
232 | + ) | ||
233 | + phoneId, e := strconv.Atoi(request.Phone) | ||
234 | + if e != nil { | ||
235 | + log.Error(e) | ||
236 | + e = protocol.NewErrWithMessage(2) | ||
237 | + return | ||
238 | + } | ||
239 | + rsp = &protocolx.CenterCompanysResponse{} | ||
240 | + if err = transactionContext.StartTransaction(); err != nil { | ||
241 | + log.Error(err) | ||
242 | + return nil, err | ||
243 | + } | ||
244 | + defer func() { | ||
245 | + transactionContext.RollbackTransaction() | ||
246 | + }() | ||
247 | + loginSvr.Init(request.Phone) | ||
248 | + if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 { | ||
249 | + err = protocol.NewErrWithMessage(502, err) //账号不存在 | ||
250 | + return | ||
251 | + } | ||
252 | + switch request.GrantType { | ||
253 | + case protocol.LoginByPassword: | ||
254 | + if loginSvr.ManagerLogin(request.Phone, request.Password) != nil && loginSvr.PartnerLogin(request.Phone, request.Password) != nil { | ||
255 | + err = protocol.NewCustomMessage(1, "密码输入有误!") | ||
256 | + return | ||
257 | + } | ||
258 | + break | ||
259 | + case protocol.LoginBySmsCode: | ||
260 | + if _, err = CheckSmsCode(request.Phone, request.Captcha); err != nil { | ||
261 | + return | ||
262 | + } | ||
263 | + break | ||
264 | + default: | ||
265 | + err = protocol.NewCustomMessage(1, "登录方式不支持!") | ||
266 | + break | ||
267 | + } | ||
268 | + | ||
269 | + //获取统计信息 | ||
270 | + rsp.Partner, _ = loginSvr.PartnerStaticInfo() | ||
271 | + rsp.Manager, _ = loginSvr.ManagerStaticInfo() | ||
272 | + //没有有效人的时候 | ||
273 | + //if rsp.Partner ==nil && rsp.Manager ==nil{ | ||
274 | + // err = protocol.NewErrWithMessage(2002) //账号禁用 | ||
275 | + // return | ||
276 | + //} | ||
277 | + | ||
278 | + var nickName string | ||
279 | + if len(loginSvr.Users) > 0 { | ||
280 | + nickName = loginSvr.Users[0].Name | ||
281 | + } else if len(loginSvr.PartnerInfo) > 0 { | ||
282 | + nickName = loginSvr.PartnerInfo[0].PartnerName | ||
283 | + } | ||
284 | + //初始化im信息 | ||
285 | + if imInfo, err = InitOrUpdateUserIMInfo(int64(phoneId), nickName, transactionContext); err != nil { | ||
286 | + log.Error(err) | ||
287 | + return | ||
288 | + } | ||
289 | + | ||
290 | + rsp.CsAccountID = fmt.Sprintf("%v", imInfo.CustomerImId) | ||
291 | + rsp.ImToken = imInfo.ImToken | ||
292 | + rsp.Accid, _ = strconv.Atoi(imInfo.ImId) | ||
293 | + rsp.Credentials, _ = utils.GenerateToken(int64(phoneId), request.Phone, protocol.RefreshTokenExipre*time.Second) | ||
294 | + | ||
295 | + err = transactionContext.CommitTransaction() | ||
296 | + return | ||
297 | +} | ||
298 | + | ||
299 | +func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest) (rsp *protocolx.CompanysResponse, err error) { | ||
300 | + var ( | ||
301 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
302 | + loginSvr = domain_service.NewPgLoginService(transactionContext) | ||
303 | + claim *utils.UserTokenClaims | ||
304 | + ) | ||
305 | + rsp = &protocolx.CompanysResponse{} | ||
306 | + if err = transactionContext.StartTransaction(); err != nil { | ||
307 | + log.Error(err) | ||
308 | + return nil, err | ||
309 | + } | ||
310 | + defer func() { | ||
311 | + transactionContext.RollbackTransaction() | ||
312 | + }() | ||
313 | + if claim, err = utils.ParseJWTToken(request.Credentials); err != nil { | ||
314 | + err = protocol.NewErrWithMessage(4139, err) | ||
315 | + return | ||
316 | + } | ||
317 | + loginSvr.Init(claim.Phone) | ||
318 | + rsp.Partner, _ = loginSvr.PartnerStaticInfo() | ||
319 | + rsp.Manager, _ = loginSvr.ManagerStaticInfo() | ||
320 | + err = transactionContext.CommitTransaction() | ||
321 | + return | ||
322 | +} | ||
323 | + | ||
324 | +func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) (rsp *protocol.LoginResponse, err error) { | ||
325 | + var ( | ||
326 | + claim *utils.UserTokenClaims | ||
327 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
328 | + PartnerInfoRepository, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext) | ||
329 | + UsersRepository, _ = factory.CreateUsersRepository(transactionContext) | ||
330 | + userId int64 | ||
331 | + ) | ||
332 | + rsp = &protocol.LoginResponse{} | ||
333 | + if err = transactionContext.StartTransaction(); err != nil { | ||
334 | + return nil, err | ||
335 | + } | ||
336 | + defer func() { | ||
337 | + transactionContext.RollbackTransaction() | ||
338 | + }() | ||
339 | + if claim, err = utils.ParseJWTToken(request.Credentials); err != nil { | ||
340 | + err = protocol.NewErrWithMessage(4140, err) | ||
341 | + return | ||
342 | + } | ||
343 | + switch request.IdType { | ||
344 | + case int(protocolx.AdminTypePartner): | ||
345 | + if p, e := PartnerInfoRepository.FindOne(map[string]interface{}{"account": claim.Phone, "company_id": request.Cid, "status": 1}); e == nil { | ||
346 | + userId = p.Id | ||
347 | + } | ||
348 | + break | ||
349 | + case int(protocolx.AdminTypeManager): | ||
350 | + if p, e := UsersRepository.FindOne(map[string]interface{}{"phone": claim.Phone, "company_id": request.Cid, "status": 1}); e == nil { | ||
351 | + userId = p.Id | ||
352 | + } | ||
353 | + break | ||
354 | + default: | ||
355 | + err = protocol.NewErrWithMessage(2, fmt.Errorf("idType :%v not in range (1,2)", request.IdType)) //用户类型有误 | ||
356 | + return | ||
357 | + } | ||
358 | + if userId == 0 { | ||
359 | + err = protocol.NewErrWithMessage(502, err) //账号不存在 | ||
360 | + return | ||
361 | + } | ||
362 | + //根据simnum + cid | ||
363 | + rsp.AuthCode, _ = utils.GenerateTokenWithAdminType(userId, claim.Phone, request.IdType, protocol.AuthCodeExpire*time.Second) | ||
364 | + | ||
365 | + err = transactionContext.CommitTransaction() | ||
366 | + return | ||
367 | +} |
@@ -15,28 +15,29 @@ import ( | @@ -15,28 +15,29 @@ import ( | ||
15 | ) | 15 | ) |
16 | 16 | ||
17 | // 更新用户 IM INFO | 17 | // 更新用户 IM INFO |
18 | -func InitOrUpdateUserIMInfo(partnerInfo *domain.PartnerInfo, ctx *transaction.TransactionContext) (err error) { | 18 | +func InitOrUpdateUserIMInfo(userId int64, name string, ctx *transaction.TransactionContext) (imInfo *domain.ImInfo, err error) { |
19 | var ( | 19 | var ( |
20 | ImInfoRepository, _ = factory.CreateImInfoRepository(ctx) | 20 | ImInfoRepository, _ = factory.CreateImInfoRepository(ctx) |
21 | checkImRequest *protocol.CheckImRequest = &protocol.CheckImRequest{} | 21 | checkImRequest *protocol.CheckImRequest = &protocol.CheckImRequest{} |
22 | IsCreated = false | 22 | IsCreated = false |
23 | checkImResponse *protocol.CheckImResponse | 23 | checkImResponse *protocol.CheckImResponse |
24 | ) | 24 | ) |
25 | - imInfo, e := ImInfoRepository.FindOne(map[string]interface{}{"user_id": partnerInfo.Id}) | 25 | + var errFind error |
26 | + imInfo, errFind = ImInfoRepository.FindOne(map[string]interface{}{"user_id": userId}) | ||
26 | // 异常 | 27 | // 异常 |
27 | - if e != nil && e != domain.QueryNoRow { | ||
28 | - err = e | 28 | + if errFind != nil && errFind != domain.QueryNoRow { |
29 | + err = errFind | ||
29 | return | 30 | return |
30 | } | 31 | } |
31 | // 不存在 | 32 | // 不存在 |
32 | - if e == domain.QueryNoRow { | 33 | + if errFind == domain.QueryNoRow { |
33 | imInfo = &domain.ImInfo{ | 34 | imInfo = &domain.ImInfo{ |
34 | - UserId: partnerInfo.Id, | 35 | + UserId: userId, |
35 | CreateTime: time.Now(), | 36 | CreateTime: time.Now(), |
36 | } | 37 | } |
37 | } | 38 | } |
38 | // 已存在 | 39 | // 已存在 |
39 | - if e == nil && imInfo != nil { | 40 | + if errFind == nil && imInfo != nil { |
40 | IsCreated = true | 41 | IsCreated = true |
41 | } | 42 | } |
42 | 43 | ||
@@ -47,7 +48,7 @@ func InitOrUpdateUserIMInfo(partnerInfo *domain.PartnerInfo, ctx *transaction.Tr | @@ -47,7 +48,7 @@ func InitOrUpdateUserIMInfo(partnerInfo *domain.PartnerInfo, ctx *transaction.Tr | ||
47 | checkImRequest = &protocol.CheckImRequest{ | 48 | checkImRequest = &protocol.CheckImRequest{ |
48 | UserId: imInfo.UserId, | 49 | UserId: imInfo.UserId, |
49 | ImId: imInfo.ImId, | 50 | ImId: imInfo.ImId, |
50 | - Uname: partnerInfo.PartnerName, | 51 | + Uname: name, |
51 | CustomerImId: fmt.Sprintf("%v", imInfo.CustomerImId), | 52 | CustomerImId: fmt.Sprintf("%v", imInfo.CustomerImId), |
52 | IsCreated: IsCreated, | 53 | IsCreated: IsCreated, |
53 | } | 54 | } |
@@ -55,7 +56,7 @@ func InitOrUpdateUserIMInfo(partnerInfo *domain.PartnerInfo, ctx *transaction.Tr | @@ -55,7 +56,7 @@ func InitOrUpdateUserIMInfo(partnerInfo *domain.PartnerInfo, ctx *transaction.Tr | ||
55 | return | 56 | return |
56 | } | 57 | } |
57 | if imInfo.CustomerImId == 0 { | 58 | if imInfo.CustomerImId == 0 { |
58 | - imInfo.CustomerImId = getRandomCustomerAccount(partnerInfo.Id, ctx) | 59 | + imInfo.CustomerImId = getRandomCustomerAccount(userId, ctx) |
59 | } | 60 | } |
60 | imInfo.ImToken = checkImResponse.ImToken | 61 | imInfo.ImToken = checkImResponse.ImToken |
61 | imInfo.UpdateTime = time.Now() | 62 | imInfo.UpdateTime = time.Now() |
1 | package order | 1 | package order |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | - "fmt" | ||
5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" | 4 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" |
6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" |
@@ -118,11 +117,11 @@ func orderTotalStatic(order *domain.OrderBase) interface{} { | @@ -118,11 +117,11 @@ func orderTotalStatic(order *domain.OrderBase) interface{} { | ||
118 | // 订单统计 | 117 | // 订单统计 |
119 | func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatisticsRequest) (rsp *protocol.OrderStatisticsResponse, err error) { | 118 | func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatisticsRequest) (rsp *protocol.OrderStatisticsResponse, err error) { |
120 | var ( | 119 | var ( |
121 | - transactionContext, _ = factory.CreateTransactionContext(nil) | ||
122 | - OrderDao, _ = factory.CreateOrderBaseDao(transactionContext) | ||
123 | - PartnerInfoRepository, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext) | ||
124 | - partnerInfo *domain.PartnerInfo | ||
125 | - orderBonus domain.OrderBonusResponse | 120 | + transactionContext, _ = factory.CreateTransactionContext(nil) |
121 | + OrderDao, _ = factory.CreateOrderBaseDao(transactionContext) | ||
122 | + //PartnerInfoRepository, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext) | ||
123 | + //partnerInfo *domain.PartnerInfo | ||
124 | + //orderBonus domain.OrderBonusResponse | ||
126 | ) | 125 | ) |
127 | if err = transactionContext.StartTransaction(); err != nil { | 126 | if err = transactionContext.StartTransaction(); err != nil { |
128 | return nil, err | 127 | return nil, err |
@@ -131,10 +130,10 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic | @@ -131,10 +130,10 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic | ||
131 | transactionContext.RollbackTransaction() | 130 | transactionContext.RollbackTransaction() |
132 | }() | 131 | }() |
133 | rsp = &protocol.OrderStatisticsResponse{Statistics: protocol.OrderStatics{}} | 132 | rsp = &protocol.OrderStatisticsResponse{Statistics: protocol.OrderStatics{}} |
134 | - if partnerInfo, err := PartnerInfoRepository.FindOne(map[string]interface{}{"id": header.UserId}); err != nil { | ||
135 | - err = protocol.NewCustomMessage(1, fmt.Sprintf("%v %v", "用户不存在:", header.UserId)) | ||
136 | - return | ||
137 | - } | 133 | + //if partnerInfo, err := PartnerInfoRepository.FindOne(map[string]interface{}{"id": header.UserId}); err != nil { |
134 | + // err = protocol.NewCustomMessage(1, fmt.Sprintf("%v %v", "用户不存在:", header.UserId)) | ||
135 | + // return | ||
136 | + //} | ||
138 | 137 | ||
139 | if rsp.Statistics.TodayRealQuantity, rsp.Statistics.TodayRealMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | 138 | if rsp.Statistics.TodayRealQuantity, rsp.Statistics.TodayRealMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ |
140 | BeginTime: utils.GetDayBegin().Unix() * 1000, | 139 | BeginTime: utils.GetDayBegin().Unix() * 1000, |
@@ -23,8 +23,9 @@ type DividendOrdersQuery struct { | @@ -23,8 +23,9 @@ type DividendOrdersQuery struct { | ||
23 | 23 | ||
24 | // 订单分红统计-查询 | 24 | // 订单分红统计-查询 |
25 | type OrderBonusQuery struct { | 25 | type OrderBonusQuery struct { |
26 | - PartnerId int64 `json:"partnerId,omitempty"` | ||
27 | - CompanyId int64 `json:"companyId,omitempty"` | 26 | + PartnerId int64 `json:"partnerId,omitempty"` |
27 | + CompanyId int64 `json:"companyId,omitempty"` | ||
28 | + InPartnerIds []int64 `json:"inPartnerIds,omitempty"` | ||
28 | } | 29 | } |
29 | 30 | ||
30 | // 订单分红统计-应答 | 31 | // 订单分红统计-应答 |
pkg/domain/service/login_service.go
0 → 100644
@@ -60,6 +60,9 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d | @@ -60,6 +60,9 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d | ||
60 | if option.CompanyId > 0 { | 60 | if option.CompanyId > 0 { |
61 | q.Where(`"order_base".company_id =?`, option.CompanyId) | 61 | q.Where(`"order_base".company_id =?`, option.CompanyId) |
62 | } | 62 | } |
63 | + if len(option.InPartnerIds) > 0 { | ||
64 | + q.Where(`"order_base".partner_id in (?)`, option.InPartnerIds) | ||
65 | + } | ||
63 | err = q.Select(&rsp.Total, &rsp.Bonus, &rsp.BonusExpense) | 66 | err = q.Select(&rsp.Total, &rsp.Bonus, &rsp.BonusExpense) |
64 | return | 67 | return |
65 | } | 68 | } |
@@ -25,6 +25,13 @@ func (dao *PartnerInfoDao) Update(queryOptions map[string]interface{}) error { | @@ -25,6 +25,13 @@ func (dao *PartnerInfoDao) Update(queryOptions map[string]interface{}) error { | ||
25 | return err | 25 | return err |
26 | } | 26 | } |
27 | 27 | ||
28 | +//func(dao *PartnerInfoDao)PartnerCompanyInfo(queryOptions map[string]interface{})(values map[string]interface{},err error){ | ||
29 | +//// tx := dao.transactionContext.PgTx | ||
30 | +//// m := new(models.PartnerInfo) | ||
31 | +//// query := NewQuery(tx.Model(m), queryOptions) | ||
32 | +//// query.SetWhere("status=?","status") | ||
33 | +////} | ||
34 | + | ||
28 | func NewPartnerInfoDao(transactionContext *transaction.TransactionContext) (*PartnerInfoDao, error) { | 35 | func NewPartnerInfoDao(transactionContext *transaction.TransactionContext) (*PartnerInfoDao, error) { |
29 | if transactionContext == nil { | 36 | if transactionContext == nil { |
30 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 37 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
1 | +package domain_service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/tiptok/gocomm/xa/eda" | ||
5 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | ||
6 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/dao" | ||
7 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" | ||
8 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/repository" | ||
9 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | ||
10 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | ||
11 | + protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/auth" | ||
12 | + "strings" | ||
13 | +) | ||
14 | + | ||
15 | +type PgLoginService struct { | ||
16 | + Phone string | ||
17 | + eda.EventCenterPublisher | ||
18 | + PartnerInfo []*domain.PartnerInfo | ||
19 | + Users []*domain.Users | ||
20 | + transactionContext *transaction.TransactionContext | ||
21 | +} | ||
22 | + | ||
23 | +func (svr *PgLoginService) Init(phone string) (err error) { | ||
24 | + var ( | ||
25 | + PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext) | ||
26 | + UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext) | ||
27 | + ) | ||
28 | + svr.Phone = phone | ||
29 | + _, svr.PartnerInfo, _ = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC"}) | ||
30 | + _, svr.Users, _ = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC"}) | ||
31 | + return nil | ||
32 | +} | ||
33 | + | ||
34 | +//合伙人登录 | ||
35 | +func (svr *PgLoginService) PartnerLogin(phone string, password string) (err error) { | ||
36 | + if len(svr.PartnerInfo) == 0 { | ||
37 | + //子账号 | ||
38 | + err = protocol.NewErrWithMessage(502, err) //账号不存在 | ||
39 | + return | ||
40 | + } | ||
41 | + if !strings.EqualFold(svr.PartnerInfo[0].Password, password) { | ||
42 | + err = protocol.NewCustomMessage(1, "密码输入有误!") | ||
43 | + return | ||
44 | + } | ||
45 | + return | ||
46 | +} | ||
47 | + | ||
48 | +//管理层登录 | ||
49 | +func (svr *PgLoginService) ManagerLogin(phone string, password string) (err error) { | ||
50 | + if len(svr.Users) == 0 { | ||
51 | + //子账号 | ||
52 | + err = protocol.NewErrWithMessage(502, err) //账号不存在 | ||
53 | + return | ||
54 | + } | ||
55 | + return | ||
56 | +} | ||
57 | + | ||
58 | +//合伙人统计信息 | ||
59 | +func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { | ||
60 | + if len(svr.PartnerInfo) == 0 { | ||
61 | + return nil, nil | ||
62 | + } | ||
63 | + var ( | ||
64 | + OrderDao, _ = dao.NewOrderBaseDao(svr.transactionContext) | ||
65 | + PartnerCategoryInfoRepository, _ = repository.NewPartnerCategoryInfoRepository(svr.transactionContext) | ||
66 | + companyList []*domain.Company | ||
67 | + partnerCategory []*domain.PartnerCategoryInfo | ||
68 | + ) | ||
69 | + doGetCompanyIds := func() []int64 { | ||
70 | + var companies []int64 | ||
71 | + for i := range svr.PartnerInfo { | ||
72 | + companies = append(companies, svr.PartnerInfo[i].CompanyId) | ||
73 | + } | ||
74 | + return companies | ||
75 | + } | ||
76 | + doGetPartnerIds := func() []int64 { | ||
77 | + var array []int64 | ||
78 | + for i := range svr.PartnerInfo { | ||
79 | + array = append(array, svr.PartnerInfo[i].Id) | ||
80 | + } | ||
81 | + return array | ||
82 | + } | ||
83 | + companyList = svr.GetCompanyList(doGetCompanyIds) | ||
84 | + | ||
85 | + totalBonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: doGetPartnerIds()}) | ||
86 | + if e != nil { | ||
87 | + return nil, e | ||
88 | + } | ||
89 | + _, partnerCategory, _ = PartnerCategoryInfoRepository.Find(map[string]interface{}{"sortById": domain.ASC}) | ||
90 | + var companys = make([]*Company, 0) | ||
91 | + for i := range companyList { | ||
92 | + c := companyList[i] | ||
93 | + var partner *domain.PartnerInfo | ||
94 | + for j := range svr.PartnerInfo { | ||
95 | + if svr.PartnerInfo[j].CompanyId == c.Id { | ||
96 | + partner = svr.PartnerInfo[j] | ||
97 | + break | ||
98 | + } | ||
99 | + } | ||
100 | + if partner == nil { | ||
101 | + continue | ||
102 | + } | ||
103 | + bonus, _ := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: partner.Id}) | ||
104 | + item := &Company{ | ||
105 | + CompanyBase: newCompanyBase(c), | ||
106 | + IncomePercent: computeBonusPercent(totalBonus.Bonus, bonus.Bonus), | ||
107 | + DividendMoney: bonus.Bonus, | ||
108 | + JoinWays: svr.GetJoinWays(partnerCategory, partner, bonus.Bonus), | ||
109 | + } | ||
110 | + companys = append(companys, item) | ||
111 | + } | ||
112 | + | ||
113 | + response := make(map[string]interface{}) | ||
114 | + response["id"] = protocolx.AdminTypePartner | ||
115 | + response["name"] = svr.PartnerInfo[0].PartnerName | ||
116 | + response["companys"] = companys | ||
117 | + return response, nil | ||
118 | +} | ||
119 | +func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) { | ||
120 | + if len(svr.Users) == 0 { | ||
121 | + return nil, nil | ||
122 | + } | ||
123 | + var ( | ||
124 | + companyList []*domain.Company | ||
125 | + ) | ||
126 | + doGetCompanyIds := func() []int64 { | ||
127 | + var companies []int64 | ||
128 | + for i := range svr.PartnerInfo { | ||
129 | + companies = append(companies, svr.PartnerInfo[i].CompanyId) | ||
130 | + } | ||
131 | + return companies | ||
132 | + } | ||
133 | + companyList = svr.GetCompanyList(doGetCompanyIds) | ||
134 | + var companys = make([]protocol.CompanyBase, 0) | ||
135 | + for i := range companyList { | ||
136 | + c := companyList[i] | ||
137 | + //var user *domain.Users | ||
138 | + //for j:=range svr.Users{ | ||
139 | + // if svr.Users[j].CompanyId==c.Id{ | ||
140 | + // user = svr.Users[j] | ||
141 | + // break | ||
142 | + // } | ||
143 | + //} | ||
144 | + item := newCompanyBase(c) | ||
145 | + companys = append(companys, item) | ||
146 | + } | ||
147 | + | ||
148 | + response := make(map[string]interface{}) | ||
149 | + response["id"] = protocolx.AdminTypePartner | ||
150 | + response["name"] = svr.PartnerInfo[0].PartnerName | ||
151 | + response["companys"] = companys | ||
152 | + return response, nil | ||
153 | +} | ||
154 | +func (svr *PgLoginService) GetCompanyList(funcGetCompanyIds func() []int64) []*domain.Company { | ||
155 | + var ( | ||
156 | + CompanyRepository, _ = repository.NewCompanyRepository(svr.transactionContext) | ||
157 | + companyList []*domain.Company | ||
158 | + ) | ||
159 | + var companies []int64 = funcGetCompanyIds() | ||
160 | + if len(companies) == 0 { | ||
161 | + return companyList | ||
162 | + } | ||
163 | + if _, v, e := CompanyRepository.Find(map[string]interface{}{"companies": companies, "status": 1, "sortByCreateTime": domain.ASC}); e != nil { | ||
164 | + return companyList | ||
165 | + } else { | ||
166 | + companyList = v | ||
167 | + } | ||
168 | + return companyList | ||
169 | +} | ||
170 | +func (svr *PgLoginService) GetJoinWays(partnerCategory []*domain.PartnerCategoryInfo, partnerInfo *domain.PartnerInfo, bonus float64) []joinWay { | ||
171 | + searchCategory := func(partnerCategory []*domain.PartnerCategoryInfo, id int64) *domain.PartnerCategoryInfo { | ||
172 | + for i := range partnerCategory { | ||
173 | + if partnerCategory[i].Id == id { | ||
174 | + return partnerCategory[i] | ||
175 | + } | ||
176 | + } | ||
177 | + return nil | ||
178 | + } | ||
179 | + var ( | ||
180 | + totalBonus float64 | ||
181 | + businessBonus float64 | ||
182 | + BusinessBonusRepository, _ = repository.NewBusinessBonusRepository(svr.transactionContext) | ||
183 | + ) | ||
184 | + for i := range partnerInfo.PartnerCategoryInfos { | ||
185 | + c := partnerInfo.PartnerCategoryInfos[i] | ||
186 | + switch c.Id { | ||
187 | + case 1: | ||
188 | + totalBonus += bonus | ||
189 | + case 2: | ||
190 | + if one, e := BusinessBonusRepository.FindOne(map[string]interface{}{"partner_id": partnerInfo.Id}); e == nil { | ||
191 | + businessBonus = one.Bonus | ||
192 | + totalBonus += businessBonus | ||
193 | + } | ||
194 | + } | ||
195 | + } | ||
196 | + var joinWays []joinWay | ||
197 | + for i := range partnerCategory { | ||
198 | + c := partnerCategory[i] | ||
199 | + searchC := searchCategory(partnerInfo.PartnerCategoryInfos, c.Id) | ||
200 | + if searchC != nil { | ||
201 | + item := joinWay{ | ||
202 | + Type: int(c.Id), | ||
203 | + Name: c.Name, | ||
204 | + } | ||
205 | + if c.Id == 1 { | ||
206 | + item.Percent = computeBonusPercent(totalBonus, bonus) * 100 | ||
207 | + } else if c.Id == 2 { | ||
208 | + item.Percent = computeBonusPercent(totalBonus, businessBonus) * 100 | ||
209 | + } | ||
210 | + joinWays = append(joinWays, item) | ||
211 | + } | ||
212 | + } | ||
213 | + return joinWays | ||
214 | +} | ||
215 | +func newCompanyBase(company *domain.Company) protocol.CompanyBase { | ||
216 | + return protocol.CompanyBase{ | ||
217 | + Id: company.Id, | ||
218 | + Name: company.Name, | ||
219 | + ShortName: "TODO", | ||
220 | + Image: protocol.NewImage(company.Logo), | ||
221 | + Phone: company.Phone, | ||
222 | + } | ||
223 | +} | ||
224 | +func computeBonusPercent(totalBonus float64, bonus float64) float64 { | ||
225 | + if totalBonus == 0 { | ||
226 | + return 0 | ||
227 | + } | ||
228 | + return utils.Decimal(bonus / totalBonus) | ||
229 | +} | ||
230 | + | ||
231 | +type Company struct { | ||
232 | + protocol.CompanyBase | ||
233 | + // 收入占比 | ||
234 | + IncomePercent float64 `json:"incomePercent"` | ||
235 | + // 分红金额 | ||
236 | + DividendMoney float64 `json:"dividendMoney"` | ||
237 | + JoinWays []joinWay | ||
238 | +} | ||
239 | +type incomeInfo struct { | ||
240 | + // 收入占比 | ||
241 | + IncomePercent float64 `json:"incomePercent"` | ||
242 | + // 分红金额 | ||
243 | + DividendMoney float64 `json:"dividendMoney"` | ||
244 | +} | ||
245 | +type joinWay struct { | ||
246 | + Type int `json:"type"` | ||
247 | + Name string `json:"name"` | ||
248 | + Percent float64 `json:"percent"` | ||
249 | +} | ||
250 | + | ||
251 | +func NewPgLoginService(ctx *transaction.TransactionContext) *PgLoginService { | ||
252 | + return &PgLoginService{ | ||
253 | + transactionContext: ctx, | ||
254 | + } | ||
255 | +} |
@@ -49,6 +49,7 @@ func (repository *BusinessBonusRepository) FindOne(queryOptions map[string]inter | @@ -49,6 +49,7 @@ func (repository *BusinessBonusRepository) FindOne(queryOptions map[string]inter | ||
49 | BusinessBonusModel := new(models.BusinessBonus) | 49 | BusinessBonusModel := new(models.BusinessBonus) |
50 | query := NewQuery(tx.Model(BusinessBonusModel), queryOptions) | 50 | query := NewQuery(tx.Model(BusinessBonusModel), queryOptions) |
51 | query.SetWhere("id = ?", "id") | 51 | query.SetWhere("id = ?", "id") |
52 | + query.SetWhere("partner_id = ?", "partner_id") | ||
52 | if err := query.First(); err != nil { | 53 | if err := query.First(); err != nil { |
53 | return nil, fmt.Errorf("query row not found") | 54 | return nil, fmt.Errorf("query row not found") |
54 | } | 55 | } |
@@ -62,6 +62,11 @@ func (repository *CompanyRepository) Find(queryOptions map[string]interface{}) ( | @@ -62,6 +62,11 @@ func (repository *CompanyRepository) Find(queryOptions map[string]interface{}) ( | ||
62 | var CompanyModels []*models.Company | 62 | var CompanyModels []*models.Company |
63 | Companys := make([]*domain.Company, 0) | 63 | Companys := make([]*domain.Company, 0) |
64 | query := NewQuery(tx.Model(&CompanyModels), queryOptions) | 64 | query := NewQuery(tx.Model(&CompanyModels), queryOptions) |
65 | + if companies, ok := queryOptions["companies"]; ok { | ||
66 | + query.WhereIn("id in (?)", companies) | ||
67 | + } | ||
68 | + query.SetWhere("status = ?", "status") | ||
69 | + query.SetOrder(`create_at`, "sortByCreateTime") | ||
65 | var err error | 70 | var err error |
66 | if query.AffectRow, err = query.SelectAndCount(); err != nil { | 71 | if query.AffectRow, err = query.SelectAndCount(); err != nil { |
67 | return 0, Companys, err | 72 | return 0, Companys, err |
@@ -64,7 +64,8 @@ func (repository *PartnerCategoryInfoRepository) Find(queryOptions map[string]in | @@ -64,7 +64,8 @@ func (repository *PartnerCategoryInfoRepository) Find(queryOptions map[string]in | ||
64 | PartnerCategoryInfos := make([]*domain.PartnerCategoryInfo, 0) | 64 | PartnerCategoryInfos := make([]*domain.PartnerCategoryInfo, 0) |
65 | query := NewQuery(tx.Model(&PartnerCategoryInfoModels), queryOptions). | 65 | query := NewQuery(tx.Model(&PartnerCategoryInfoModels), queryOptions). |
66 | SetOrder("create_time", "sortByCreateTime"). | 66 | SetOrder("create_time", "sortByCreateTime"). |
67 | - SetOrder("update_time", "sortByUpdateTime") | 67 | + SetOrder("update_time", "sortByUpdateTime"). |
68 | + SetOrder("id", "sortById") | ||
68 | var err error | 69 | var err error |
69 | if query.AffectRow, err = query.SelectAndCount(); err != nil { | 70 | if query.AffectRow, err = query.SelectAndCount(); err != nil { |
70 | return 0, PartnerCategoryInfos, err | 71 | return 0, PartnerCategoryInfos, err |
@@ -48,7 +48,7 @@ func (repository *UsersRepository) FindOne(queryOptions map[string]interface{}) | @@ -48,7 +48,7 @@ func (repository *UsersRepository) FindOne(queryOptions map[string]interface{}) | ||
48 | tx := repository.transactionContext.PgTx | 48 | tx := repository.transactionContext.PgTx |
49 | UsersModel := new(models.Users) | 49 | UsersModel := new(models.Users) |
50 | query := NewQuery(tx.Model(UsersModel), queryOptions) | 50 | query := NewQuery(tx.Model(UsersModel), queryOptions) |
51 | - query.SetWhere("id = ?", "id") | 51 | + query.SetWhere("phone = ?", "phone") |
52 | if err := query.First(); err != nil { | 52 | if err := query.First(); err != nil { |
53 | return nil, fmt.Errorf("query row not found") | 53 | return nil, fmt.Errorf("query row not found") |
54 | } | 54 | } |
@@ -63,8 +63,11 @@ func (repository *UsersRepository) Find(queryOptions map[string]interface{}) (in | @@ -63,8 +63,11 @@ func (repository *UsersRepository) Find(queryOptions map[string]interface{}) (in | ||
63 | var UsersModels []*models.Users | 63 | var UsersModels []*models.Users |
64 | Userss := make([]*domain.Users, 0) | 64 | Userss := make([]*domain.Users, 0) |
65 | query := NewQuery(tx.Model(&UsersModels), queryOptions). | 65 | query := NewQuery(tx.Model(&UsersModels), queryOptions). |
66 | - SetOrder("create_time", "sortByCreateTime"). | ||
67 | - SetOrder("update_time", "sortByUpdateTime") | 66 | + SetWhere("phone = ?", "phone"). |
67 | + SetWhere("company_id = ?", "companyId"). | ||
68 | + SetWhere(`status = ?`, "status"). | ||
69 | + SetOrder("create_at", "sortByCreateTime"). | ||
70 | + SetOrder("update_at", "sortByUpdateTime") | ||
68 | var err error | 71 | var err error |
69 | if query.AffectRow, err = query.SelectAndCount(); err != nil { | 72 | if query.AffectRow, err = query.SelectAndCount(); err != nil { |
70 | return 0, Userss, err | 73 | return 0, Userss, err |
@@ -54,3 +54,21 @@ func GenerateToken(uid int64, phone string, expire time.Duration) (string, error | @@ -54,3 +54,21 @@ func GenerateToken(uid int64, phone string, expire time.Duration) (string, error | ||
54 | token, err := tokenClaims.SignedString(jwtSecret) | 54 | token, err := tokenClaims.SignedString(jwtSecret) |
55 | return token, err | 55 | return token, err |
56 | } | 56 | } |
57 | + | ||
58 | +func GenerateTokenWithAdminType(uid int64, phone string, adminType int, expire time.Duration) (string, error) { | ||
59 | + now := time.Now() | ||
60 | + expireTime := now.Add(expire) | ||
61 | + claims := UserTokenClaims{ | ||
62 | + UserId: uid, | ||
63 | + Phone: phone, | ||
64 | + AdminType: adminType, | ||
65 | + StandardClaims: jwt.StandardClaims{ | ||
66 | + ExpiresAt: expireTime.Unix(), | ||
67 | + Issuer: "jwt", | ||
68 | + }, | ||
69 | + } | ||
70 | + | ||
71 | + tokenClaims := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) | ||
72 | + token, err := tokenClaims.SignedString(jwtSecret) | ||
73 | + return token, err | ||
74 | +} |
@@ -4,6 +4,7 @@ import ( | @@ -4,6 +4,7 @@ import ( | ||
4 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/auth" | 4 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/auth" |
5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" | 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" |
6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" |
7 | + protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/auth" | ||
7 | "time" | 8 | "time" |
8 | ) | 9 | ) |
9 | 10 | ||
@@ -163,3 +164,83 @@ func (this *AuthController) AuthCheckSmsCode() { | @@ -163,3 +164,83 @@ func (this *AuthController) AuthCheckSmsCode() { | ||
163 | err = CacheSms.Put(request.Phone, rsp.CaptchaCertificate, 5*time.Minute) | 164 | err = CacheSms.Put(request.Phone, rsp.CaptchaCertificate, 5*time.Minute) |
164 | msg = protocol.NewReturnResponse(rsp, err) | 165 | msg = protocol.NewReturnResponse(rsp, err) |
165 | } | 166 | } |
167 | + | ||
168 | +// CenterCompanys | ||
169 | +// 获取统一用户中心公司(登录凭证) | ||
170 | +func (this *AuthController) CenterCompanys() { | ||
171 | + var msg *protocol.ResponseMessage | ||
172 | + defer func() { | ||
173 | + this.Resp(msg) | ||
174 | + }() | ||
175 | + var request *protocolx.CenterCompanysRequest | ||
176 | + if err := this.JsonUnmarshal(&request); err != nil { | ||
177 | + msg = protocol.BadRequestParam(1) | ||
178 | + return | ||
179 | + } | ||
180 | + if b, m := this.Valid(request); !b { | ||
181 | + msg = m | ||
182 | + return | ||
183 | + } | ||
184 | + if len(request.Password) == 0 { | ||
185 | + msg = protocol.NewResponseMessage(1, "密码不能为空!") | ||
186 | + return | ||
187 | + } | ||
188 | + header := this.GetRequestHeader(this.Ctx) | ||
189 | + data, err := auth.CenterCompanys(header, request) | ||
190 | + if err != nil { | ||
191 | + log.Error(err) | ||
192 | + } | ||
193 | + msg = protocol.NewReturnResponse(data, err) | ||
194 | +} | ||
195 | + | ||
196 | +// Companys | ||
197 | +// 测试 | ||
198 | +func (this *AuthController) Companys() { | ||
199 | + var msg *protocol.ResponseMessage | ||
200 | + defer func() { | ||
201 | + this.Resp(msg) | ||
202 | + }() | ||
203 | + var request *protocolx.CompanysRequest | ||
204 | + if err := this.JsonUnmarshal(&request); err != nil { | ||
205 | + msg = protocol.BadRequestParam(1) | ||
206 | + return | ||
207 | + } | ||
208 | + if b, m := this.Valid(request); !b { | ||
209 | + msg = m | ||
210 | + return | ||
211 | + } | ||
212 | + header := this.GetRequestHeader(this.Ctx) | ||
213 | + data, err := auth.Companys(header, request) | ||
214 | + if err != nil { | ||
215 | + log.Error(err) | ||
216 | + } | ||
217 | + msg = protocol.NewReturnResponse(data, err) | ||
218 | +} | ||
219 | + | ||
220 | +// LoginV2 | ||
221 | +// @router /loginV2 [post] | ||
222 | +func (this *AuthController) LoginV2() { | ||
223 | + var msg *protocol.ResponseMessage | ||
224 | + defer func() { | ||
225 | + this.Resp(msg) | ||
226 | + }() | ||
227 | + var request *protocol.LoginRequestV2 | ||
228 | + if err := this.JsonUnmarshal(&request); err != nil { | ||
229 | + msg = protocol.BadRequestParam(1) | ||
230 | + return | ||
231 | + } | ||
232 | + if b, m := this.Valid(request); !b { | ||
233 | + msg = m | ||
234 | + return | ||
235 | + } | ||
236 | + if request.ClientId != clientId { | ||
237 | + msg = protocol.NewResponseMessage(101, "clientId无效") | ||
238 | + return | ||
239 | + } | ||
240 | + header := this.GetRequestHeader(this.Ctx) | ||
241 | + data, err := auth.LoginV2(header, request) | ||
242 | + if err != nil { | ||
243 | + log.Error(err) | ||
244 | + } | ||
245 | + msg = protocol.NewReturnResponse(data, err) | ||
246 | +} |
@@ -15,6 +15,8 @@ func init() { | @@ -15,6 +15,8 @@ func init() { | ||
15 | nsV1.Router("/auth/revoke", &controllers.AuthController{}, "Post:Revoke") | 15 | nsV1.Router("/auth/revoke", &controllers.AuthController{}, "Post:Revoke") |
16 | nsV1.Router("/auth/updateDevice", &controllers.AuthController{}, "Post:UpdateDevice") | 16 | nsV1.Router("/auth/updateDevice", &controllers.AuthController{}, "Post:UpdateDevice") |
17 | nsV1.Router("/auth/checkSmsCode", &controllers.AuthController{}, "Post:AuthCheckSmsCode") | 17 | nsV1.Router("/auth/checkSmsCode", &controllers.AuthController{}, "Post:AuthCheckSmsCode") |
18 | + nsV1.Router("/auth/centerCompanys", &controllers.AuthController{}, "post:CenterCompanys") | ||
19 | + nsV1.Router("/auth/companys", &controllers.AuthController{}, "post:Companys") | ||
18 | 20 | ||
19 | nsV1.Router("/user/userInfo", &controllers.UserController{}, "Post:UserInfo") | 21 | nsV1.Router("/user/userInfo", &controllers.UserController{}, "Post:UserInfo") |
20 | nsV1.Router("/user/checkSmsCode", &controllers.UserController{}, "Post:CheckSmsCode") | 22 | nsV1.Router("/user/checkSmsCode", &controllers.UserController{}, "Post:CheckSmsCode") |
@@ -31,3 +33,9 @@ func init() { | @@ -31,3 +33,9 @@ func init() { | ||
31 | nsV1.Router("/dividend/orders", &controllers.DividendController{}, "Post:DividendOrders") | 33 | nsV1.Router("/dividend/orders", &controllers.DividendController{}, "Post:DividendOrders") |
32 | beego.AddNamespace(nsV1) | 34 | beego.AddNamespace(nsV1) |
33 | } | 35 | } |
36 | + | ||
37 | +func InitV2() { | ||
38 | + nsV2 := beego.NewNamespace("v2", beego.NSBefore(middleware.CheckJWTToken)) | ||
39 | + nsV2.Router("/auth/login", &controllers.AuthController{}, "Post:LoginV2") | ||
40 | + beego.AddNamespace(nsV2) | ||
41 | +} |
@@ -25,6 +25,13 @@ type LoginResponse struct { | @@ -25,6 +25,13 @@ type LoginResponse struct { | ||
25 | AuthCode string `json:"authCode"` | 25 | AuthCode string `json:"authCode"` |
26 | } | 26 | } |
27 | 27 | ||
28 | +type LoginRequestV2 struct { | ||
29 | + Cid int `json:"cid"` | ||
30 | + IdType int `json:"idType"` | ||
31 | + Credentials string `json:"credentials"` // 登录类型 1:密码 2:验证码 | ||
32 | + ClientId string `json:"clientId"` | ||
33 | +} | ||
34 | + | ||
28 | //JWT用户信息 | 35 | //JWT用户信息 |
29 | type JWTUserInfo struct { | 36 | type JWTUserInfo struct { |
30 | UserId string `json:"id"` //用户id | 37 | UserId string `json:"id"` //用户id |
pkg/protocol/auth/center_companys_request.go
0 → 100644
1 | +package auth | ||
2 | + | ||
3 | +type CenterCompanysResponse struct { | ||
4 | + Accid int `json:"accid"` //网易云信ID | ||
5 | + ImToken string `json:"imToken"` //网易云信Token | ||
6 | + CsAccountID string `json:"csAccountID"` //系统分配客服ID | ||
7 | + Credentials string `json:"credentials"` //登录凭证 | ||
8 | + Partner interface{} `json:"partner"` //合伙人对象 | ||
9 | + Manager interface{} `json:"manager"` //高管对象 | ||
10 | +} |
pkg/protocol/auth/companys_request.go
0 → 100644
pkg/protocol/auth/companys_response.go
0 → 100644
pkg/protocol/auth/constant.go
0 → 100644
pkg/protocol/value.go
0 → 100644
1 | +package protocol | ||
2 | + | ||
3 | +type CompanyBase struct { | ||
4 | + Id int64 `json:"id"` | ||
5 | + Name string `json:"name"` | ||
6 | + ShortName string `json:"shortName"` | ||
7 | + Image interface{} `json:"image"` | ||
8 | + Phone string `json:"phone"` | ||
9 | +} | ||
10 | + | ||
11 | +type Image struct { | ||
12 | + Path string `json:"path"` | ||
13 | +} | ||
14 | + | ||
15 | +func NewImage(path string) Image { | ||
16 | + return Image{ | ||
17 | + Path: path, | ||
18 | + } | ||
19 | +} |
-
请 注册 或 登录 后发表评论