正在显示
6 个修改的文件
包含
45 行增加
和
8 行删除
@@ -182,6 +182,7 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont | @@ -182,6 +182,7 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont | ||
182 | func getPartners(userId int64, request *protocolx.PartnersRequest, transactionContext *transaction.TransactionContext) (interface{}, error) { | 182 | func getPartners(userId int64, request *protocolx.PartnersRequest, transactionContext *transaction.TransactionContext) (interface{}, error) { |
183 | var ( | 183 | var ( |
184 | UsersRepository, _ = factory.CreateUsersRepository(transactionContext) | 184 | UsersRepository, _ = factory.CreateUsersRepository(transactionContext) |
185 | + PartnerInfo, _ = factory.CreatePartnerInfoDao(transactionContext) | ||
185 | user *domain.Users | 186 | user *domain.Users |
186 | err error | 187 | err error |
187 | ) | 188 | ) |
@@ -191,5 +192,8 @@ func getPartners(userId int64, request *protocolx.PartnersRequest, transactionCo | @@ -191,5 +192,8 @@ func getPartners(userId int64, request *protocolx.PartnersRequest, transactionCo | ||
191 | if len(user.AccessPartnerIds()) == 0 { | 192 | if len(user.AccessPartnerIds()) == 0 { |
192 | return nil, nil | 193 | return nil, nil |
193 | } | 194 | } |
195 | + if cc, e := PartnerInfo.PartnerStatics(nil); e == nil { | ||
196 | + return cc, nil | ||
197 | + } | ||
194 | return nil, nil | 198 | return nil, nil |
195 | } | 199 | } |
@@ -331,7 +331,7 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques | @@ -331,7 +331,7 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques | ||
331 | } else { | 331 | } else { |
332 | u.CooperateCompany.Salesman = map[string]interface{}{} | 332 | u.CooperateCompany.Salesman = map[string]interface{}{} |
333 | } | 333 | } |
334 | - rspMap["User"] = u | 334 | + rspMap["user"] = u |
335 | rsp = rspMap | 335 | rsp = rspMap |
336 | } | 336 | } |
337 | funcManagerInfo := func() { | 337 | funcManagerInfo := func() { |
pkg/domain/partner_statics.go
0 → 100644
@@ -4,6 +4,7 @@ import ( | @@ -4,6 +4,7 @@ import ( | ||
4 | "fmt" | 4 | "fmt" |
5 | "github.com/go-pg/pg/v10" | 5 | "github.com/go-pg/pg/v10" |
6 | "github.com/go-pg/pg/v10/orm" | 6 | "github.com/go-pg/pg/v10/orm" |
7 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | ||
7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" |
8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" | 9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" |
9 | . "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | 10 | . "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" |
@@ -54,12 +55,31 @@ func (dao *PartnerInfoDao) PartnerStatic(queryOptions map[string]interface{}) (c | @@ -54,12 +55,31 @@ func (dao *PartnerInfoDao) PartnerStatic(queryOptions map[string]interface{}) (c | ||
54 | return | 55 | return |
55 | } | 56 | } |
56 | 57 | ||
57 | -//func(dao *PartnerInfoDao)PartnerCompanyInfo(queryOptions map[string]interface{})(values map[string]interface{},err error){ | ||
58 | -//// tx := dao.transactionContext.PgTx | ||
59 | -//// m := new(models.PartnerInfo) | ||
60 | -//// query := NewQuery(tx.Model(m), queryOptions) | ||
61 | -//// query.SetWhere("status=?","status") | ||
62 | -////} | 58 | +func (dao *PartnerInfoDao) PartnerStatics(queryOptions map[string]interface{}) (statics []*domain.PartnerStatics, err error) { |
59 | + tx := dao.transactionContext.PgDd | ||
60 | + //m := new(models.PartnerInfo) | ||
61 | + sql := fmt.Sprintf(`select A.*, | ||
62 | +(B.amount1+C.amount2) amount,(B.bonus1+C.bonus2) bonus,(B.bonus_expense1 + C.bonus_expense2) bonus_expense | ||
63 | +from | ||
64 | +( | ||
65 | + select * from partner_info | ||
66 | + WHERE (id in (1,2)) | ||
67 | +) | ||
68 | +A left join | ||
69 | +( | ||
70 | + SELECT partner_id,count(*) total1,sum(plan_order_amount) amount1, sum(plan_partner_bonus) bonus1, sum(partner_bonus_expense) bonus_expense1 FROM "order_base" AS "order_base" | ||
71 | + WHERE (partner_id in (1,2)) and order_type =1 | ||
72 | + GROUP BY partner_id | ||
73 | +) B on A."id" = B.partner_id | ||
74 | +left join | ||
75 | +( | ||
76 | + select partner_info_id,count(*) total2,0 amount2, sum(bonus) bonus2, sum(bonus_expense) bonus_expense2 from business_bonus | ||
77 | + WHERE (partner_info_id in (1,2)) and is_disable=1 | ||
78 | + GROUP BY partner_info_id | ||
79 | +) C on A."id"= C."partner_info_id"`) | ||
80 | + tx.Query(&statics, sql) | ||
81 | + return | ||
82 | +} | ||
63 | 83 | ||
64 | func NewPartnerInfoDao(transactionContext *transaction.TransactionContext) (*PartnerInfoDao, error) { | 84 | func NewPartnerInfoDao(transactionContext *transaction.TransactionContext) (*PartnerInfoDao, error) { |
65 | if transactionContext == nil { | 85 | if transactionContext == nil { |
@@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
7 | "github.com/astaxie/beego/context" | 7 | "github.com/astaxie/beego/context" |
8 | "github.com/astaxie/beego/validation" | 8 | "github.com/astaxie/beego/validation" |
9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | 9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" |
10 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" | ||
10 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | 11 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" |
11 | "strconv" | 12 | "strconv" |
12 | ) | 13 | ) |
@@ -41,6 +42,7 @@ func (controller *BaseController) Valid(obj interface{}) (result bool, msg *prot | @@ -41,6 +42,7 @@ func (controller *BaseController) Valid(obj interface{}) (result bool, msg *prot | ||
41 | valid := validation.Validation{} | 42 | valid := validation.Validation{} |
42 | result, err = valid.Valid(obj) | 43 | result, err = valid.Valid(obj) |
43 | if err != nil { | 44 | if err != nil { |
45 | + log.Error(err) | ||
44 | } | 46 | } |
45 | if !result { | 47 | if !result { |
46 | msg = protocol.BadRequestParam(2) | 48 | msg = protocol.BadRequestParam(2) |
@@ -4,7 +4,7 @@ type PartnersRequest struct { | @@ -4,7 +4,7 @@ type PartnersRequest struct { | ||
4 | // 页码索引(0开始) | 4 | // 页码索引(0开始) |
5 | PageIndex int `json:"pageIndex"` | 5 | PageIndex int `json:"pageIndex"` |
6 | // 每页数量 | 6 | // 每页数量 |
7 | - PageSize int `json:"pageSize" valid:"required"` | 7 | + PageSize int `json:"pageSize" valid:"Required"` |
8 | // 起始时间戳 | 8 | // 起始时间戳 |
9 | StartTime int64 `json:"startTime"` | 9 | StartTime int64 `json:"startTime"` |
10 | // 结束时间戳 | 10 | // 结束时间戳 |
-
请 注册 或 登录 后发表评论