Merge remote-tracking branch 'origin/test'
正在显示
23 个修改的文件
包含
388 行增加
和
19 行删除
@@ -351,11 +351,13 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom | @@ -351,11 +351,13 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom | ||
351 | break | 351 | break |
352 | case protocol.LoginByCredentials: | 352 | case protocol.LoginByCredentials: |
353 | //凭证是否存在 | 353 | //凭证是否存在 |
354 | + if constant.DISENABLE_MULTI_DEVICE_LOGIN { | ||
354 | if credential, e := userAuth.NewRedisUserCredential(request.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) { | 355 | if credential, e := userAuth.NewRedisUserCredential(request.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) { |
355 | log.Debug("凭证过期或者已失效:", request.Phone) | 356 | log.Debug("凭证过期或者已失效:", request.Phone) |
356 | err = protocol.NewErrWithMessage(4140, err) | 357 | err = protocol.NewErrWithMessage(4140, err) |
357 | return | 358 | return |
358 | } | 359 | } |
360 | + } | ||
359 | if _, err = utils.ParseJWTToken(request.Credentials); err != nil { | 361 | if _, err = utils.ParseJWTToken(request.Credentials); err != nil { |
360 | err = protocol.NewErrWithMessage(4140, err) | 362 | err = protocol.NewErrWithMessage(4140, err) |
361 | return | 363 | return |
@@ -419,11 +421,13 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest | @@ -419,11 +421,13 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest | ||
419 | return | 421 | return |
420 | } | 422 | } |
421 | //凭证是否存在 | 423 | //凭证是否存在 |
424 | + if constant.DISENABLE_MULTI_DEVICE_LOGIN { | ||
422 | if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) { | 425 | if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) { |
423 | log.Debug("凭证过期或者已失效:", claim.Phone) | 426 | log.Debug("凭证过期或者已失效:", claim.Phone) |
424 | err = protocol.NewErrWithMessage(4140, err) | 427 | err = protocol.NewErrWithMessage(4140, err) |
425 | return | 428 | return |
426 | } | 429 | } |
430 | + } | ||
427 | loginSvr.Init(claim.Phone) | 431 | loginSvr.Init(claim.Phone) |
428 | rsp.Partner, _ = loginSvr.PartnerStaticInfo() | 432 | rsp.Partner, _ = loginSvr.PartnerStaticInfo() |
429 | rsp.Manager, _ = loginSvr.ManagerStaticInfo() | 433 | rsp.Manager, _ = loginSvr.ManagerStaticInfo() |
@@ -458,12 +462,14 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( | @@ -458,12 +462,14 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( | ||
458 | err = protocol.NewErrWithMessage(4140, err) | 462 | err = protocol.NewErrWithMessage(4140, err) |
459 | return | 463 | return |
460 | } | 464 | } |
465 | + if constant.DISENABLE_MULTI_DEVICE_LOGIN { | ||
461 | //凭证是否存在 | 466 | //凭证是否存在 |
462 | if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) { | 467 | if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) { |
463 | log.Debug("凭证过期或者已失效:", claim.Phone) | 468 | log.Debug("凭证过期或者已失效:", claim.Phone) |
464 | err = protocol.NewErrWithMessage(4140, err) | 469 | err = protocol.NewErrWithMessage(4140, err) |
465 | return | 470 | return |
466 | } | 471 | } |
472 | + } | ||
467 | if company, e := CompanyRepository.FindOne(map[string]interface{}{"id": request.Cid, "enable": 1}); e != nil || company == nil { | 473 | if company, e := CompanyRepository.FindOne(map[string]interface{}{"id": request.Cid, "enable": 1}); e != nil || company == nil { |
468 | err = protocol.NewErrWithMessage(10007, err) | 474 | err = protocol.NewErrWithMessage(10007, err) |
469 | return | 475 | return |
@@ -145,7 +145,7 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont | @@ -145,7 +145,7 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont | ||
145 | UsersRepository, _ = factory.CreateUsersRepository(transactionContext) | 145 | UsersRepository, _ = factory.CreateUsersRepository(transactionContext) |
146 | PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext) | 146 | PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext) |
147 | OrderBaseDao, _ = factory.CreateOrderBaseDao(transactionContext) | 147 | OrderBaseDao, _ = factory.CreateOrderBaseDao(transactionContext) |
148 | - BusinessBonusDao, _ = factory.CreateBusinessBonusDao(transactionContext) | 148 | + //BusinessBonusDao, _ = factory.CreateBusinessBonusDao(transactionContext) |
149 | //user *domain.Users | 149 | //user *domain.Users |
150 | partnerIds []int64 | 150 | partnerIds []int64 |
151 | ) | 151 | ) |
@@ -156,6 +156,10 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont | @@ -156,6 +156,10 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont | ||
156 | partnerIds = user.AccessPartnerIds() | 156 | partnerIds = user.AccessPartnerIds() |
157 | } | 157 | } |
158 | Statistics := make(map[string]interface{}) | 158 | Statistics := make(map[string]interface{}) |
159 | + //Statistics["developDividend"] = 0 | ||
160 | + //Statistics["developOrdersMoney"] = 0 | ||
161 | + //Statistics["appDividend"] = 0 | ||
162 | + //Statistics["appOrdersMoney"] = 0 | ||
159 | if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.Career}); e == nil { | 163 | if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.Career}); e == nil { |
160 | Statistics["careerCount"] = count | 164 | Statistics["careerCount"] = count |
161 | } | 165 | } |
@@ -168,18 +172,27 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont | @@ -168,18 +172,27 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont | ||
168 | if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.App}); e == nil { | 172 | if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.App}); e == nil { |
169 | Statistics["appCount"] = count | 173 | Statistics["appCount"] = count |
170 | } | 174 | } |
171 | - if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career)}); e == nil { | 175 | + if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Career}); e == nil { |
172 | Statistics["careerOrdersMoney"] = bonus.TotalOrderAmount | 176 | Statistics["careerOrdersMoney"] = bonus.TotalOrderAmount |
173 | Statistics["careerDividend"] = bonus.Bonus | 177 | Statistics["careerDividend"] = bonus.Bonus |
174 | } | 178 | } |
175 | - if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, IsDisable: 1}); e == nil { | ||
176 | - Statistics["businessDividend"] = businessBonus.Bonus | ||
177 | - Statistics["businessOrdersMoney"] = businessBonus.TotalOrderAmount | 179 | + if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Business}); e == nil { |
180 | + Statistics["businessOrdersMoney"] = bonus.TotalOrderAmount | ||
181 | + Statistics["businessDividend"] = bonus.Bonus | ||
178 | } | 182 | } |
179 | - Statistics["developDividend"] = 0 | ||
180 | - Statistics["developOrdersMoney"] = 0 | ||
181 | - Statistics["appDividend"] = 0 | ||
182 | - Statistics["appOrdersMoney"] = 0 | 183 | + if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Develop}); e == nil { |
184 | + Statistics["developOrdersMoney"] = bonus.TotalOrderAmount | ||
185 | + Statistics["developDividend"] = bonus.Bonus | ||
186 | + } | ||
187 | + if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.App}); e == nil { | ||
188 | + Statistics["appOrdersMoney"] = bonus.TotalOrderAmount | ||
189 | + Statistics["appDividend"] = bonus.Bonus | ||
190 | + } | ||
191 | + //if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, IsDisable: 1}); e == nil { | ||
192 | + // Statistics["businessDividend"] = businessBonus.Bonus | ||
193 | + // Statistics["businessOrdersMoney"] = businessBonus.TotalOrderAmount | ||
194 | + //} | ||
195 | + | ||
183 | Statistics["totalCount"] = len(partnerIds) | 196 | Statistics["totalCount"] = len(partnerIds) |
184 | return Statistics, nil | 197 | return Statistics, nil |
185 | } | 198 | } |
pkg/application/company/company_v2.go
0 → 100644
1 | +package company | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/tiptok/gocomm/pkg/log" | ||
5 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" | ||
6 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | ||
7 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" | ||
8 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | ||
9 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | ||
10 | + protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/company" | ||
11 | + userx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/user" | ||
12 | +) | ||
13 | + | ||
14 | +func PartnersV2(header *protocol.RequestHeader, request *protocolx.PartnersRequest) (rsp *protocolx.PartnersResponse, err error) { | ||
15 | + var ( | ||
16 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
17 | + ) | ||
18 | + rsp = &protocolx.PartnersResponse{} | ||
19 | + if err = transactionContext.StartTransaction(); err != nil { | ||
20 | + log.Error(err) | ||
21 | + return nil, err | ||
22 | + } | ||
23 | + defer func() { | ||
24 | + transactionContext.RollbackTransaction() | ||
25 | + }() | ||
26 | + if rsp.Partners, err = getPartnersV2(header.UserId, request, transactionContext); err != nil { | ||
27 | + log.Error(err) | ||
28 | + return | ||
29 | + } | ||
30 | + if rsp.Partners == nil { | ||
31 | + rsp.Partners = []struct{}{} | ||
32 | + } | ||
33 | + err = transactionContext.CommitTransaction() | ||
34 | + return | ||
35 | +} | ||
36 | + | ||
37 | +func getPartnersV2(userId int64, request *protocolx.PartnersRequest, transactionContext *transaction.TransactionContext) (interface{}, error) { | ||
38 | + var ( | ||
39 | + UsersRepository, _ = factory.CreateUsersRepository(transactionContext) | ||
40 | + PartnerInfo, _ = factory.CreatePartnerInfoDao(transactionContext) | ||
41 | + user *domain.Users | ||
42 | + err error | ||
43 | + PartnerCategoryInfoRepository, _ = factory.CreatePartnerCategoryInfoRepository(transactionContext) | ||
44 | + ) | ||
45 | + | ||
46 | + if user, err = UsersRepository.FindOne(map[string]interface{}{"id": userId}); err != nil { | ||
47 | + return nil, err | ||
48 | + } | ||
49 | + | ||
50 | + var company *domain.Company | ||
51 | + var CompanyResponsitory, _ = factory.CreateCompanyRepository(transactionContext) | ||
52 | + if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": user.CompanyId}); err != nil { | ||
53 | + return nil, err | ||
54 | + } | ||
55 | + | ||
56 | + if len(user.AccessPartnerIds()) == 0 { | ||
57 | + return nil, nil | ||
58 | + } | ||
59 | + mapCategoryInfo := make(map[int64]*domain.PartnerCategoryInfo) | ||
60 | + if _, categories, e := PartnerCategoryInfoRepository.Find(nil); e == nil { | ||
61 | + for i := range categories { | ||
62 | + mapCategoryInfo[categories[i].Id] = categories[i] | ||
63 | + } | ||
64 | + } | ||
65 | + | ||
66 | + queryOption := make(map[string]interface{}) | ||
67 | + if len(request.Districts) > 0 { | ||
68 | + var districts []string | ||
69 | + for i := 0; i < len(request.Districts); i++ { | ||
70 | + districts = append(districts, request.Districts[i].Name) | ||
71 | + } | ||
72 | + queryOption["districts"] = districts | ||
73 | + } | ||
74 | + if len(request.JoinWays) > 0 { | ||
75 | + var joinWays []int64 | ||
76 | + for i := 0; i < len(request.JoinWays); i++ { | ||
77 | + joinWays = append(joinWays, request.JoinWays[i].Type) | ||
78 | + } | ||
79 | + queryOption["joinWays"] = joinWays | ||
80 | + } | ||
81 | + if request.StartTime > 0 { | ||
82 | + queryOption["startTime"] = request.StartTime / 1000 | ||
83 | + } | ||
84 | + if request.EndTime > 0 { | ||
85 | + queryOption["endTime"] = request.EndTime / 1000 | ||
86 | + } | ||
87 | + queryOption["limit"] = request.PageSize | ||
88 | + queryOption["offset"] = request.PageSize * request.PageIndex | ||
89 | + | ||
90 | + queryOption["sortByBonus"] = domain.DESC | ||
91 | + if request.SortBy != 0 { | ||
92 | + queryOption["sortByBonus"] = domain.ASC | ||
93 | + } | ||
94 | + | ||
95 | + if partners, e := PartnerInfo.Partners(user.AccessPartnerIds(), queryOption); e == nil { | ||
96 | + var array []interface{} | ||
97 | + for i := range partners { | ||
98 | + mapPartners := make(map[string]interface{}) | ||
99 | + p := partners[i] | ||
100 | + mapPartners["uid"] = p.Id | ||
101 | + mapPartners["uname"] = p.PartnerName | ||
102 | + | ||
103 | + var joinWays []protocolx.JoinWays | ||
104 | + for j := range p.PartnerCategoryInfos { | ||
105 | + c := p.PartnerCategoryInfos[j] | ||
106 | + if v, ok := mapCategoryInfo[c.Id]; ok { | ||
107 | + joinWays = append(joinWays, protocolx.JoinWays{Type: v.Id, Name: v.Name}) | ||
108 | + } | ||
109 | + } | ||
110 | + mapPartners["joinWays"] = joinWays | ||
111 | + | ||
112 | + mapPartners["dividend"] = utils.Decimal(p.Bonus) | ||
113 | + mapPartners["ordersCount"] = p.Total | ||
114 | + mapPartners["ordersMoney"] = utils.Decimal(p.Amount) | ||
115 | + mapPartners["phone"] = p.Account | ||
116 | + | ||
117 | + partnerCompany := userx.Company{ | ||
118 | + Id: company.Id, | ||
119 | + Name: company.Name, | ||
120 | + Phone: company.Phone, | ||
121 | + SerialNo: p.Id, | ||
122 | + CooperateTime: p.CooperateTime.Unix() * 1000, | ||
123 | + MiniProgram: nil, | ||
124 | + District: map[string]interface{}{"id": p.RegionInfo.RegionId, "name": p.RegionInfo.RegionName}, | ||
125 | + } | ||
126 | + if len(p.Salesman) > 0 { | ||
127 | + partnerCompany.Salesman = map[string]interface{}{"uname": p.Salesman[0].Name, "phone": p.Salesman[0].Telephone} | ||
128 | + } else { | ||
129 | + partnerCompany.Salesman = map[string]interface{}{} | ||
130 | + } | ||
131 | + mapPartners["company"] = partnerCompany | ||
132 | + | ||
133 | + array = append(array, mapPartners) | ||
134 | + } | ||
135 | + return array, nil | ||
136 | + } | ||
137 | + return nil, nil | ||
138 | +} | ||
139 | + | ||
140 | +func funcPartnerCompanyInfo(companyId int64, transactionContext *transaction.TransactionContext) (partnerCompany userx.Company, err error) { | ||
141 | + var ( | ||
142 | + CompanyResponsitory, _ = factory.CreateCompanyRepository(transactionContext) | ||
143 | + company *domain.Company | ||
144 | + ) | ||
145 | + if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": companyId}); err != nil { | ||
146 | + return | ||
147 | + } | ||
148 | + | ||
149 | + partnerCompany = userx.Company{ | ||
150 | + Id: company.Id, | ||
151 | + Name: company.Name, | ||
152 | + Phone: company.Phone, | ||
153 | + //SerialNo: partnerInfo.Id, | ||
154 | + //CooperateTime: partnerInfo.CooperateTime.Unix() * 1000, | ||
155 | + MiniProgram: nil, | ||
156 | + //District: map[string]interface{}{"id": partnerInfo.RegionInfo.RegionId, "name": partnerInfo.RegionInfo.RegionName}, | ||
157 | + } | ||
158 | + | ||
159 | + //if len(partnerInfo.Salesman) > 0 { | ||
160 | + // u.CooperateCompany.Salesman = map[string]interface{}{"uname": partnerInfo.Salesman[0].Name, "phone": partnerInfo.Salesman[0].Telephone} | ||
161 | + //} else { | ||
162 | + // u.CooperateCompany.Salesman = map[string]interface{}{} | ||
163 | + //} | ||
164 | + //rspMap["user"] = u | ||
165 | + //rsp = rspMap | ||
166 | + return | ||
167 | +} |
@@ -24,7 +24,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis | @@ -24,7 +24,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis | ||
24 | }() | 24 | }() |
25 | 25 | ||
26 | // 事业分红统计-查询订单 | 26 | // 事业分红统计-查询订单 |
27 | - _, orderAll, e := OrderBaseResponsitory.Find(utils.ObjectJsonToMap(domain.OrderQueryOption{PartnerId: header.UserId, EndTime: time.Now(), SortByCreateTime: domain.DESC, OrderTypes: domain.UserOrderTypes(domain.Career)})) | 27 | + _, orderAll, e := OrderBaseResponsitory.Find(utils.ObjectJsonToMap(domain.OrderQueryOption{PartnerId: request.PartnerId, EndTime: time.Now(), SortByCreateTime: domain.DESC, OrderTypes: domain.UserOrderTypes(domain.Career)})) |
28 | if e != nil { | 28 | if e != nil { |
29 | log.Error(e) | 29 | log.Error(e) |
30 | } | 30 | } |
@@ -40,7 +40,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis | @@ -40,7 +40,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis | ||
40 | bonusQuarters := QuartersBonusStatics(orderBetween, 0) | 40 | bonusQuarters := QuartersBonusStatics(orderBetween, 0) |
41 | 41 | ||
42 | // 业务分红统计 | 42 | // 业务分红统计 |
43 | - if bonus, e := BusinessBonusRepository.FindOne(map[string]interface{}{"partner_id": header.UserId, "isDisable": 1}); e == nil { | 43 | + if bonus, e := BusinessBonusRepository.FindOne(map[string]interface{}{"partner_id": request.PartnerId, "isDisable": 1}); e == nil { |
44 | bonusAll.Receivable += bonus.Bonus | 44 | bonusAll.Receivable += bonus.Bonus |
45 | bonusAll.Received += bonus.BonusHas | 45 | bonusAll.Received += bonus.BonusHas |
46 | bonusAll.Outstanding += bonus.BonusNot | 46 | bonusAll.Outstanding += bonus.BonusNot |
@@ -125,7 +125,7 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR | @@ -125,7 +125,7 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR | ||
125 | 125 | ||
126 | count, orders, err = OrderDao.DividendOrders(&domain.DividendOrdersQueryOption{ | 126 | count, orders, err = OrderDao.DividendOrders(&domain.DividendOrdersQueryOption{ |
127 | OrderTypes: domain.UserOrderTypes(domain.Career), | 127 | OrderTypes: domain.UserOrderTypes(domain.Career), |
128 | - PartnerId: header.UserId, | 128 | + PartnerId: request.PartnerId, |
129 | DetailAction: request.DetailAction, | 129 | DetailAction: request.DetailAction, |
130 | DividendAction: request.DividendAction, | 130 | DividendAction: request.DividendAction, |
131 | //IsDisable: "0", | 131 | //IsDisable: "0", |
@@ -3,10 +3,13 @@ package event | @@ -3,10 +3,13 @@ package event | ||
3 | import ( | 3 | import ( |
4 | "github.com/tiptok/gocomm/xa/eda" | 4 | "github.com/tiptok/gocomm/xa/eda" |
5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/event/subscriber" | 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/event/subscriber" |
6 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" | ||
6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain/event" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain/event" |
7 | ) | 8 | ) |
8 | 9 | ||
9 | func InitEventCenter() { | 10 | func InitEventCenter() { |
11 | + if constant.DISENABLE_MULTI_DEVICE_LOGIN { | ||
10 | eda.RegisterSubscribe(&event.AccessTokenEvent{}, &subscriber.AuthCacheSubscribe{}) | 12 | eda.RegisterSubscribe(&event.AccessTokenEvent{}, &subscriber.AuthCacheSubscribe{}) |
11 | eda.RegisterSubscribe(&event.RefreshTokenEvent{}, &subscriber.AuthCacheSubscribe{}) | 13 | eda.RegisterSubscribe(&event.RefreshTokenEvent{}, &subscriber.AuthCacheSubscribe{}) |
14 | + } | ||
12 | } | 15 | } |
@@ -132,7 +132,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic | @@ -132,7 +132,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic | ||
132 | defer func() { | 132 | defer func() { |
133 | transactionContext.RollbackTransaction() | 133 | transactionContext.RollbackTransaction() |
134 | }() | 134 | }() |
135 | - rsp = &protocol.OrderStatisticsResponse{Statistics: protocol.OrderStatics{}} | 135 | + rsp = &protocol.OrderStatisticsResponse{Statistics: &protocol.OrderStatics{}} |
136 | 136 | ||
137 | // 当天订单/累计订单 | 137 | // 当天订单/累计订单 |
138 | 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{ |
@@ -195,10 +195,11 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r | @@ -195,10 +195,11 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r | ||
195 | 195 | ||
196 | // 查询订单列表 | 196 | // 查询订单列表 |
197 | queryOption := &domain.OrderQueryOption{ | 197 | queryOption := &domain.OrderQueryOption{ |
198 | - PartnerId: header.UserId, | ||
199 | Limit: request.PageSize, | 198 | Limit: request.PageSize, |
200 | Offset: request.PageSize * request.PageIndex, | 199 | Offset: request.PageSize * request.PageIndex, |
201 | SortByUpdateTime: domain.DESC, | 200 | SortByUpdateTime: domain.DESC, |
201 | + PartnerId: request.PartnerId, | ||
202 | + PartnerCategoryId: request.JoinWay, | ||
202 | } | 203 | } |
203 | if request.StartTime > 0 { | 204 | if request.StartTime > 0 { |
204 | queryOption.BeginTime = time.Unix(request.StartTime/1000, 0) | 205 | queryOption.BeginTime = time.Unix(request.StartTime/1000, 0) |
@@ -211,7 +212,12 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r | @@ -211,7 +212,12 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r | ||
211 | total, orders, _ = OrderResponsitory.Find(utils.ObjectJsonToMap(queryOption)) | 212 | total, orders, _ = OrderResponsitory.Find(utils.ObjectJsonToMap(queryOption)) |
212 | if len(orders) != 0 { | 213 | if len(orders) != 0 { |
213 | for i := range orders { | 214 | for i := range orders { |
214 | - rsp.List = append(rsp.List, DomainOrderToOrderListItem(orders[i])) | 215 | + item := DomainOrderToOrderListItem(orders[i]) |
216 | + // 高管查看都是标记已读 | ||
217 | + if orders[i].PartnerId != header.UserId { | ||
218 | + item.IsRead = 1 | ||
219 | + } | ||
220 | + rsp.List = append(rsp.List, item) | ||
215 | } | 221 | } |
216 | } | 222 | } |
217 | 223 | ||
@@ -224,7 +230,8 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r | @@ -224,7 +230,8 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r | ||
224 | cumulativeQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | 230 | cumulativeQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ |
225 | EndTime: time.Now().Unix() * 1000, | 231 | EndTime: time.Now().Unix() * 1000, |
226 | OrderTypes: domain.UserOrderTypes(domain.Career), | 232 | OrderTypes: domain.UserOrderTypes(domain.Career), |
227 | - PartnerId: header.UserId, | 233 | + PartnerId: request.PartnerId, |
234 | + PartnerCategoryId: request.JoinWay, | ||
228 | }) | 235 | }) |
229 | rsp.Total = cumulativeQuantity | 236 | rsp.Total = cumulativeQuantity |
230 | } | 237 | } |
pkg/application/order/order_v2.go
0 → 100644
1 | +package order | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" | ||
5 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | ||
6 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | ||
7 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | ||
8 | + "time" | ||
9 | +) | ||
10 | + | ||
11 | +// 订单统计 | ||
12 | +func StatisticsV2(header *protocol.RequestHeader, request *protocol.OrderStatisticsRequest) (rsp *protocol.OrderStatisticsResponse, err error) { | ||
13 | + var ( | ||
14 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
15 | + OrderDao, _ = factory.CreateOrderBaseDao(transactionContext) | ||
16 | + ) | ||
17 | + if err = transactionContext.StartTransaction(); err != nil { | ||
18 | + return nil, err | ||
19 | + } | ||
20 | + defer func() { | ||
21 | + transactionContext.RollbackTransaction() | ||
22 | + }() | ||
23 | + rsp = &protocol.OrderStatisticsResponse{} | ||
24 | + | ||
25 | + //事业分红/业务分红 | ||
26 | + var total float64 //,developBonus,appBonus,careerBonus, businessBonus, | ||
27 | + if bonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career)}); e == nil { | ||
28 | + //careerBonus = bonus.Bonus | ||
29 | + total += bonus.Bonus | ||
30 | + } | ||
31 | + calcOrderStatic := func(catId int, total float64) protocol.OrderStatic { | ||
32 | + todayRealQuantity, todayRealMoney, _ := OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
33 | + BeginTime: utils.GetDayBegin().Unix() * 1000, | ||
34 | + EndTime: utils.GetDayEnd().Unix() * 1000, | ||
35 | + OrderTypes: domain.UserOrderTypes(domain.Career), | ||
36 | + PartnerId: request.PartnerId, | ||
37 | + PartnerCategoryId: catId, | ||
38 | + }) | ||
39 | + cumulativeQuantity, cumulativeMoney, _ := OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
40 | + EndTime: time.Now().Unix() * 1000, | ||
41 | + OrderTypes: domain.UserOrderTypes(domain.Career), | ||
42 | + PartnerId: request.PartnerId, | ||
43 | + PartnerCategoryId: catId, | ||
44 | + }) | ||
45 | + bonus, _ := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: catId}) | ||
46 | + var percent float64 = 0 | ||
47 | + if bonus.Bonus != 0 { | ||
48 | + percent = utils.DecimalToNumber(bonus.Bonus * 100 / total) | ||
49 | + } | ||
50 | + return protocol.OrderStatic{ | ||
51 | + Percent: percent, | ||
52 | + TodayRealQuantity: todayRealQuantity, | ||
53 | + TodayRealMoney: utils.Decimal(todayRealMoney), | ||
54 | + CumulativeQuantity: cumulativeQuantity, | ||
55 | + CumulativeMoney: utils.Decimal(cumulativeMoney), | ||
56 | + } | ||
57 | + } | ||
58 | + rsp.Career = calcOrderStatic(domain.Career, total) | ||
59 | + rsp.Business = calcOrderStatic(domain.Business, total) | ||
60 | + rsp.Develop = calcOrderStatic(domain.Develop, total) | ||
61 | + rsp.App = calcOrderStatic(domain.App, total) | ||
62 | + | ||
63 | + err = transactionContext.CommitTransaction() | ||
64 | + return | ||
65 | +} |
@@ -220,7 +220,9 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques | @@ -220,7 +220,9 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques | ||
220 | miniProgram["userName"] = company.Applets[0].Id | 220 | miniProgram["userName"] = company.Applets[0].Id |
221 | miniProgram["path"] = fmt.Sprintf("%v?inviter_id=%v&company_id=%v", company.Applets[0].URL, partnerInfo.Id, partnerInfo.CompanyId) | 221 | miniProgram["path"] = fmt.Sprintf("%v?inviter_id=%v&company_id=%v", company.Applets[0].URL, partnerInfo.Id, partnerInfo.CompanyId) |
222 | miniProgram["hdImageUrl"] = constant.SHARE_SHOP_PREVIEW_IMADGE | 222 | miniProgram["hdImageUrl"] = constant.SHARE_SHOP_PREVIEW_IMADGE |
223 | - //miniProgram["miniprogramType"] = constant.WEHAT_MINI_PROGRAM_VERSION_TYPE | 223 | + if len(company.Applets[0].ImageUrl) > 0 { |
224 | + miniProgram["hdImageUrl"] = company.Applets[0].ImageUrl | ||
225 | + } | ||
224 | miniProgram["title"] = company.Applets[0].Name | 226 | miniProgram["title"] = company.Applets[0].Name |
225 | } | 227 | } |
226 | } | 228 | } |
@@ -21,6 +21,9 @@ var DEFAULT_GUEST_COMPANY int = 10011 | @@ -21,6 +21,9 @@ var DEFAULT_GUEST_COMPANY int = 10011 | ||
21 | 21 | ||
22 | var SHARE_SHOP_PREVIEW_IMADGE = "https://media.fjmaimaimai.com/image/default/3E0C7050C13147CE8C7AF86C75F904E9-6-2.jpg" //分享店铺预览图 | 22 | var SHARE_SHOP_PREVIEW_IMADGE = "https://media.fjmaimaimai.com/image/default/3E0C7050C13147CE8C7AF86C75F904E9-6-2.jpg" //分享店铺预览图 |
23 | var WEHAT_MINI_PROGRAM_VERSION_TYPE = 2 //0:正式版 1:开发版 2:体验版 | 23 | var WEHAT_MINI_PROGRAM_VERSION_TYPE = 2 //0:正式版 1:开发版 2:体验版 |
24 | + | ||
25 | +var DISENABLE_MULTI_DEVICE_LOGIN = false //不允许多端登录 (注:正式环境需要为true 测试环境设为false,方便多个设备测试) | ||
26 | + | ||
24 | func init() { | 27 | func init() { |
25 | if os.Getenv("LOG_LEVEL") != "" { | 28 | if os.Getenv("LOG_LEVEL") != "" { |
26 | LOG_LEVEL = os.Getenv("LOG_LEVEL") | 29 | LOG_LEVEL = os.Getenv("LOG_LEVEL") |
@@ -7,7 +7,7 @@ var POSTGRESQL_USER = "postgres" // | @@ -7,7 +7,7 @@ var POSTGRESQL_USER = "postgres" // | ||
7 | var POSTGRESQL_PASSWORD = "eagle1010" //pgsql@123 | 7 | var POSTGRESQL_PASSWORD = "eagle1010" //pgsql@123 |
8 | var POSTGRESQL_HOST = "114.55.200.59" //127.0.0.1 | 8 | var POSTGRESQL_HOST = "114.55.200.59" //127.0.0.1 |
9 | var POSTGRESQL_PORT = "31543" //5432 | 9 | var POSTGRESQL_PORT = "31543" //5432 |
10 | -var DISABLE_CREATE_TABLE = false | 10 | +var DISABLE_CREATE_TABLE = true |
11 | var DISABLE_SQL_GENERATE_PRINT = false | 11 | var DISABLE_SQL_GENERATE_PRINT = false |
12 | 12 | ||
13 | func init() { | 13 | func init() { |
@@ -32,4 +32,7 @@ func init() { | @@ -32,4 +32,7 @@ func init() { | ||
32 | if os.Getenv("DISABLE_SQL_GENERATE_PRINT") != "" { | 32 | if os.Getenv("DISABLE_SQL_GENERATE_PRINT") != "" { |
33 | DISABLE_SQL_GENERATE_PRINT = true | 33 | DISABLE_SQL_GENERATE_PRINT = true |
34 | } | 34 | } |
35 | + if POSTGRESQL_DB_NAME == "partner" { | ||
36 | + DISENABLE_MULTI_DEVICE_LOGIN = true | ||
37 | + } | ||
35 | } | 38 | } |
@@ -3,6 +3,7 @@ package domain | @@ -3,6 +3,7 @@ package domain | ||
3 | type CompanyApplets struct { | 3 | type CompanyApplets struct { |
4 | Name string `json:"name"` | 4 | Name string `json:"name"` |
5 | URL string `json:"url"` | 5 | URL string `json:"url"` |
6 | + ImageUrl string `json:"imageUrl"` | ||
6 | Id string `json:"id"` | 7 | Id string `json:"id"` |
7 | } | 8 | } |
8 | 9 |
@@ -63,6 +63,8 @@ type OrderBase struct { | @@ -63,6 +63,8 @@ type OrderBase struct { | ||
63 | DataFrom *OrderDataFrom | 63 | DataFrom *OrderDataFrom |
64 | // 备注 | 64 | // 备注 |
65 | Remark string | 65 | Remark string |
66 | + // 订单所属合伙人类别 | ||
67 | + PartnerCategory *PartnerCategoryInfo | ||
66 | } | 68 | } |
67 | 69 | ||
68 | func (m *OrderBase) Identify() interface{} { | 70 | func (m *OrderBase) Identify() interface{} { |
@@ -154,6 +156,7 @@ type OrderQueryOption struct { | @@ -154,6 +156,7 @@ type OrderQueryOption struct { | ||
154 | SortByUpdateTime string `json:"sortByUpdateTime,omitempty"` | 156 | SortByUpdateTime string `json:"sortByUpdateTime,omitempty"` |
155 | Offset int `json:"offset,omitempty"` | 157 | Offset int `json:"offset,omitempty"` |
156 | Limit int `json:"limit,omitempty"` | 158 | Limit int `json:"limit,omitempty"` |
159 | + PartnerCategoryId int `json:"partnerCategoryId,omitempty"` | ||
157 | } | 160 | } |
158 | 161 | ||
159 | type DividendOrdersQueryOption struct { | 162 | type DividendOrdersQueryOption struct { |
@@ -13,6 +13,7 @@ type OrderStaticQuery struct { | @@ -13,6 +13,7 @@ type OrderStaticQuery struct { | ||
13 | OrderType int `json:"orderType,omitempty"` | 13 | OrderType int `json:"orderType,omitempty"` |
14 | OrderTypes []int `json:"orderTypes,omitempty"` | 14 | OrderTypes []int `json:"orderTypes,omitempty"` |
15 | //IsDisable int `json:"isDisable,omitempty"` | 15 | //IsDisable int `json:"isDisable,omitempty"` |
16 | + PartnerCategoryId int `json:"partnerCategoryId,omitempty"` | ||
16 | } | 17 | } |
17 | 18 | ||
18 | type DividendOrdersQuery struct { | 19 | type DividendOrdersQuery struct { |
@@ -30,6 +31,7 @@ type OrderBonusQuery struct { | @@ -30,6 +31,7 @@ type OrderBonusQuery struct { | ||
30 | IsDisable int `json:"isDisable,omitempty"` | 31 | IsDisable int `json:"isDisable,omitempty"` |
31 | OrderType int `json:"orderType,omitempty"` | 32 | OrderType int `json:"orderType,omitempty"` |
32 | OrderTypes []int `json:"orderTypes,omitempty"` | 33 | OrderTypes []int `json:"orderTypes,omitempty"` |
34 | + PartnerCategoryId int `json:"partnerCategoryId,omitempty"` //订单所属类型 | ||
33 | } | 35 | } |
34 | 36 | ||
35 | // 订单分红统计-应答 | 37 | // 订单分红统计-应答 |
@@ -39,6 +39,9 @@ func (dao *OrderBaseDao) OrderStatics(option *domain.OrderStaticQuery) (count in | @@ -39,6 +39,9 @@ func (dao *OrderBaseDao) OrderStatics(option *domain.OrderStaticQuery) (count in | ||
39 | if option.EndTime > 0 { | 39 | if option.EndTime > 0 { |
40 | q.Where(`"order_base".create_time <?`, time.Unix(option.EndTime/1000, 0)) | 40 | q.Where(`"order_base".create_time <?`, time.Unix(option.EndTime/1000, 0)) |
41 | } | 41 | } |
42 | + if option.PartnerCategoryId > 0 { | ||
43 | + q.Where(`"order_base".partner_category @>'{"id":?}'`, option.PartnerCategoryId) | ||
44 | + } | ||
42 | //q.Where(`"order_base".is_disable =?`, 0) | 45 | //q.Where(`"order_base".is_disable =?`, 0) |
43 | err = q.Select(&count, &amount, &orderAmount) | 46 | err = q.Select(&count, &amount, &orderAmount) |
44 | if option.OrderType == domain.OrderIntention { //意向订单值只有 order_amount order_actual_amount还未赋值 | 47 | if option.OrderType == domain.OrderIntention { //意向订单值只有 order_amount order_actual_amount还未赋值 |
@@ -74,6 +77,9 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d | @@ -74,6 +77,9 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d | ||
74 | if len(option.OrderTypes) > 0 { | 77 | if len(option.OrderTypes) > 0 { |
75 | q.Where(`"order_base".order_type in (?)`, pg.In(option.OrderTypes)) | 78 | q.Where(`"order_base".order_type in (?)`, pg.In(option.OrderTypes)) |
76 | } | 79 | } |
80 | + if option.PartnerCategoryId > 0 { | ||
81 | + q.Where(`"order_base".partner_category @>'{"id":?}'`, option.PartnerCategoryId) | ||
82 | + } | ||
77 | err = q.Select(&rsp.Total, &rsp.Bonus, &rsp.BonusExpense, &rsp.TotalOrderAmount) | 83 | err = q.Select(&rsp.Total, &rsp.Bonus, &rsp.BonusExpense, &rsp.TotalOrderAmount) |
78 | return | 84 | return |
79 | } | 85 | } |
1 | package repository | 1 | package repository |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "encoding/json" | ||
4 | "github.com/go-pg/pg/v10" | 5 | "github.com/go-pg/pg/v10" |
5 | "github.com/go-pg/pg/v10/orm" | 6 | "github.com/go-pg/pg/v10/orm" |
6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
@@ -88,6 +89,10 @@ func (repository *OrderBaseRepository) Find(queryOptions map[string]interface{}) | @@ -88,6 +89,10 @@ func (repository *OrderBaseRepository) Find(queryOptions map[string]interface{}) | ||
88 | if v, ok := queryOptions["orderTypes"]; ok { | 89 | if v, ok := queryOptions["orderTypes"]; ok { |
89 | query.Where(`"order_base".order_type in (?)`, pg.In(v)) | 90 | query.Where(`"order_base".order_type in (?)`, pg.In(v)) |
90 | } | 91 | } |
92 | + if v, ok := queryOptions["partnerCategoryId"]; ok { | ||
93 | + catId, _ := (v.(json.Number)).Int64() | ||
94 | + query.Where(`"order_base".partner_category @>'{"id":?}'`, catId) | ||
95 | + } | ||
91 | var err error | 96 | var err error |
92 | if query.AffectRow, err = query.SelectAndCount(); err != nil { | 97 | if query.AffectRow, err = query.SelectAndCount(); err != nil { |
93 | return 0, OrderBases, err | 98 | return 0, OrderBases, err |
@@ -59,6 +59,30 @@ func (this *CompanyController) Partners() { | @@ -59,6 +59,30 @@ func (this *CompanyController) Partners() { | ||
59 | msg = protocol.NewReturnResponse(data, err) | 59 | msg = protocol.NewReturnResponse(data, err) |
60 | } | 60 | } |
61 | 61 | ||
62 | +// Partners | ||
63 | +// 测试 | ||
64 | +func (this *CompanyController) PartnersV2() { | ||
65 | + var msg *protocol.ResponseMessage | ||
66 | + defer func() { | ||
67 | + this.Resp(msg) | ||
68 | + }() | ||
69 | + var request *protocolx.PartnersRequest | ||
70 | + if err := this.JsonUnmarshal(&request); err != nil { | ||
71 | + msg = protocol.BadRequestParam(1) | ||
72 | + return | ||
73 | + } | ||
74 | + if b, m := this.Valid(request); !b { | ||
75 | + msg = m | ||
76 | + return | ||
77 | + } | ||
78 | + header := this.GetRequestHeader(this.Ctx) | ||
79 | + data, err := company.PartnersV2(header, request) | ||
80 | + if err != nil { | ||
81 | + log.Error(err) | ||
82 | + } | ||
83 | + msg = protocol.NewReturnResponse(data, err) | ||
84 | +} | ||
85 | + | ||
62 | // Statistics | 86 | // Statistics |
63 | // 测试 | 87 | // 测试 |
64 | func (this *CompanyController) Statistics() { | 88 | func (this *CompanyController) Statistics() { |
@@ -25,6 +25,9 @@ func (this *DividendController) DividendStatistics() { | @@ -25,6 +25,9 @@ func (this *DividendController) DividendStatistics() { | ||
25 | return | 25 | return |
26 | } | 26 | } |
27 | header := this.GetRequestHeader(this.Ctx) | 27 | header := this.GetRequestHeader(this.Ctx) |
28 | + if request.PartnerId == 0 { | ||
29 | + request.PartnerId = header.UserId | ||
30 | + } | ||
28 | msg = protocol.NewReturnResponse(dividend.Statistics(header, request)) | 31 | msg = protocol.NewReturnResponse(dividend.Statistics(header, request)) |
29 | } | 32 | } |
30 | 33 | ||
@@ -44,5 +47,8 @@ func (this *DividendController) DividendOrders() { | @@ -44,5 +47,8 @@ func (this *DividendController) DividendOrders() { | ||
44 | return | 47 | return |
45 | } | 48 | } |
46 | header := this.GetRequestHeader(this.Ctx) | 49 | header := this.GetRequestHeader(this.Ctx) |
50 | + if request.PartnerId == 0 { | ||
51 | + request.PartnerId = header.UserId | ||
52 | + } | ||
47 | msg = protocol.NewReturnResponse(dividend.OrderList(header, request)) | 53 | msg = protocol.NewReturnResponse(dividend.OrderList(header, request)) |
48 | } | 54 | } |
@@ -31,6 +31,29 @@ func (this *OrderController) Statistics() { | @@ -31,6 +31,29 @@ func (this *OrderController) Statistics() { | ||
31 | msg = protocol.NewReturnResponse(order.Statistics(header, request)) | 31 | msg = protocol.NewReturnResponse(order.Statistics(header, request)) |
32 | } | 32 | } |
33 | 33 | ||
34 | +//OrderStatistics 订单统计 | ||
35 | +// @router /statistics [post] | ||
36 | +func (this *OrderController) StatisticsV2() { | ||
37 | + var msg *protocol.ResponseMessage | ||
38 | + defer func() { | ||
39 | + this.Resp(msg) | ||
40 | + }() | ||
41 | + var request *protocol.OrderStatisticsRequest | ||
42 | + if err := this.JsonUnmarshal(&request); err != nil { | ||
43 | + msg = protocol.BadRequestParam(1) | ||
44 | + return | ||
45 | + } | ||
46 | + if b, m := this.Valid(request); !b { | ||
47 | + msg = m | ||
48 | + return | ||
49 | + } | ||
50 | + header := this.GetRequestHeader(this.Ctx) | ||
51 | + if request.PartnerId == 0 { | ||
52 | + request.PartnerId = header.UserId | ||
53 | + } | ||
54 | + msg = protocol.NewReturnResponse(order.StatisticsV2(header, request)) | ||
55 | +} | ||
56 | + | ||
34 | //OrderDetail 订单详情 | 57 | //OrderDetail 订单详情 |
35 | // @router /orderDetail [post] | 58 | // @router /orderDetail [post] |
36 | func (this *OrderController) OrderDetail() { | 59 | func (this *OrderController) OrderDetail() { |
@@ -68,6 +91,9 @@ func (this *OrderController) OrderList() { | @@ -68,6 +91,9 @@ func (this *OrderController) OrderList() { | ||
68 | } | 91 | } |
69 | request.OrderTypes = domain.UserOrderTypes(domain.Career) | 92 | request.OrderTypes = domain.UserOrderTypes(domain.Career) |
70 | header := this.GetRequestHeader(this.Ctx) | 93 | header := this.GetRequestHeader(this.Ctx) |
94 | + if request.PartnerId == 0 { | ||
95 | + request.PartnerId = header.UserId | ||
96 | + } | ||
71 | msg = protocol.NewReturnResponse(order.List(header, request)) | 97 | msg = protocol.NewReturnResponse(order.List(header, request)) |
72 | } | 98 | } |
73 | 99 |
@@ -3,6 +3,7 @@ package middleware | @@ -3,6 +3,7 @@ package middleware | ||
3 | import ( | 3 | import ( |
4 | "github.com/astaxie/beego/context" | 4 | "github.com/astaxie/beego/context" |
5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/userAuth" | 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/userAuth" |
6 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" | ||
6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" |
7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" |
8 | "strconv" | 9 | "strconv" |
@@ -39,6 +40,7 @@ func CheckJWTToken(ctx *context.Context) { | @@ -39,6 +40,7 @@ func CheckJWTToken(ctx *context.Context) { | ||
39 | } else { | 40 | } else { |
40 | ctx.Input.SetData("UserId", u.UserId) | 41 | ctx.Input.SetData("UserId", u.UserId) |
41 | 42 | ||
43 | + if constant.DISENABLE_MULTI_DEVICE_LOGIN { | ||
42 | // valid token | 44 | // valid token |
43 | userPhone, _ := strconv.Atoi(u.Phone) | 45 | userPhone, _ := strconv.Atoi(u.Phone) |
44 | tokenAuth := userAuth.NewRedisUserAuth(userAuth.WithUserId(int64(userPhone))) | 46 | tokenAuth := userAuth.NewRedisUserAuth(userAuth.WithUserId(int64(userPhone))) |
@@ -50,5 +52,6 @@ func CheckJWTToken(ctx *context.Context) { | @@ -50,5 +52,6 @@ func CheckJWTToken(ctx *context.Context) { | ||
50 | return | 52 | return |
51 | } | 53 | } |
52 | } | 54 | } |
55 | + } | ||
53 | return | 56 | return |
54 | } | 57 | } |
@@ -45,5 +45,8 @@ func InitV2() { | @@ -45,5 +45,8 @@ func InitV2() { | ||
45 | nsV2 := beego.NewNamespace("v2") // ,, beego.NSBefore(middleware.CheckJWTToken) | 45 | nsV2 := beego.NewNamespace("v2") // ,, beego.NSBefore(middleware.CheckJWTToken) |
46 | nsV2.Router("/auth/login", &controllers.AuthController{}, "Post:LoginV2") | 46 | nsV2.Router("/auth/login", &controllers.AuthController{}, "Post:LoginV2") |
47 | nsV2.Router("/user/userInfo", &controllers.UserController{}, "Post:UserInfoV2") | 47 | nsV2.Router("/user/userInfo", &controllers.UserController{}, "Post:UserInfoV2") |
48 | + nsV2.Router("/company/partners", &controllers.CompanyController{}, "post:PartnersV2") | ||
49 | + | ||
50 | + nsV2.Router("/order/statistics", &controllers.OrderController{}, "Post:StatisticsV2") | ||
48 | beego.AddNamespace(nsV2) | 51 | beego.AddNamespace(nsV2) |
49 | } | 52 | } |
@@ -11,6 +11,7 @@ type DividendStatisticsRequest struct { | @@ -11,6 +11,7 @@ type DividendStatisticsRequest struct { | ||
11 | EndTime int64 `json:"endTime" valid:"Required"` | 11 | EndTime int64 `json:"endTime" valid:"Required"` |
12 | //分红类型(0累计分红、1分红支出) | 12 | //分红类型(0累计分红、1分红支出) |
13 | //DividendAction int `json:"dividendAction"` | 13 | //DividendAction int `json:"dividendAction"` |
14 | + PartnerId int64 `json:"partnerId"` | ||
14 | } | 15 | } |
15 | type DividendStatisticsResponse struct { | 16 | type DividendStatisticsResponse struct { |
16 | Statistics DividendStatistics `json:"statistics"` | 17 | Statistics DividendStatistics `json:"statistics"` |
@@ -39,6 +40,8 @@ type DividendOrdersRequest struct { | @@ -39,6 +40,8 @@ type DividendOrdersRequest struct { | ||
39 | 40 | ||
40 | PageIndex int `json:"pageIndex,omitempty"` | 41 | PageIndex int `json:"pageIndex,omitempty"` |
41 | PageSize int `json:"pageSize,omitempty"` | 42 | PageSize int `json:"pageSize,omitempty"` |
43 | + | ||
44 | + PartnerId int64 `json:"partnerId"` | ||
42 | } | 45 | } |
43 | type DividendOrdersResponse struct { | 46 | type DividendOrdersResponse struct { |
44 | List []*DividendOrderListItem `json:"list"` | 47 | List []*DividendOrderListItem `json:"list"` |
@@ -43,9 +43,14 @@ type Customer struct { | @@ -43,9 +43,14 @@ type Customer struct { | ||
43 | 43 | ||
44 | /*OrderStatistics */ | 44 | /*OrderStatistics */ |
45 | type OrderStatisticsRequest struct { | 45 | type OrderStatisticsRequest struct { |
46 | + PartnerId int64 `json:"partnerId"` | ||
46 | } | 47 | } |
47 | type OrderStatisticsResponse struct { | 48 | type OrderStatisticsResponse struct { |
48 | - Statistics OrderStatics `json:"statistics"` | 49 | + Statistics *OrderStatics `json:"statistics,omitempty"` |
50 | + Career OrderStatic `json:"career,omitempty"` //事业 | ||
51 | + Business OrderStatic `json:"business,omitempty"` //业务 | ||
52 | + Develop OrderStatic `json:"develop,omitempty"` //开发 | ||
53 | + App OrderStatic `json:"app,omitempty"` //业务-产品应用 | ||
49 | } | 54 | } |
50 | type OrderStatics struct { | 55 | type OrderStatics struct { |
51 | TodayIntentionQuantity int `json:"-"` //今日新增意向订单 | 56 | TodayIntentionQuantity int `json:"-"` //今日新增意向订单 |
@@ -63,6 +68,14 @@ type OrderStatics struct { | @@ -63,6 +68,14 @@ type OrderStatics struct { | ||
63 | BusinessMoney float64 `json:"businessMoney"` // 业务分红累计 | 68 | BusinessMoney float64 `json:"businessMoney"` // 业务分红累计 |
64 | } | 69 | } |
65 | 70 | ||
71 | +type OrderStatic struct { | ||
72 | + Percent float64 `json:"percent"` // 事业占比 | ||
73 | + TodayRealQuantity int `json:"todayRealQuantity"` //今日新增实发订单 | ||
74 | + TodayRealMoney float64 `json:"todayRealMoney"` //今日新增实发订单金额 | ||
75 | + CumulativeQuantity int `json:"cumulativeQuantity"` //累计实发订单 | ||
76 | + CumulativeMoney float64 `json:"cumulativeMoney"` //累计实发订单金额 | ||
77 | +} | ||
78 | + | ||
66 | /*OrderList */ | 79 | /*OrderList */ |
67 | type OrderListRequest struct { | 80 | type OrderListRequest struct { |
68 | StartTime int64 `json:"startTime"` | 81 | StartTime int64 `json:"startTime"` |
@@ -72,6 +85,9 @@ type OrderListRequest struct { | @@ -72,6 +85,9 @@ type OrderListRequest struct { | ||
72 | PageSize int `json:"pageSize" valid:"Required"` | 85 | PageSize int `json:"pageSize" valid:"Required"` |
73 | OrderType int `json:"-"` | 86 | OrderType int `json:"-"` |
74 | OrderTypes []int `json:"-"` | 87 | OrderTypes []int `json:"-"` |
88 | + | ||
89 | + PartnerId int64 `json:"partnerId"` | ||
90 | + JoinWay int `json:"joinWay"` //合伙方式(0或不传,即所有合伙方式) | ||
75 | } | 91 | } |
76 | type OrderListResponse struct { | 92 | type OrderListResponse struct { |
77 | List []*OrderListItem `json:"list"` | 93 | List []*OrderListItem `json:"list"` |
-
请 注册 或 登录 后发表评论