作者 yangfu

增加:公司合伙人列表

... ... @@ -182,6 +182,7 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont
func getPartners(userId int64, request *protocolx.PartnersRequest, transactionContext *transaction.TransactionContext) (interface{}, error) {
var (
UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
PartnerInfo, _ = factory.CreatePartnerInfoDao(transactionContext)
user *domain.Users
err error
)
... ... @@ -191,5 +192,8 @@ func getPartners(userId int64, request *protocolx.PartnersRequest, transactionCo
if len(user.AccessPartnerIds()) == 0 {
return nil, nil
}
if cc, e := PartnerInfo.PartnerStatics(nil); e == nil {
return cc, nil
}
return nil, nil
}
... ...
... ... @@ -331,7 +331,7 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques
} else {
u.CooperateCompany.Salesman = map[string]interface{}{}
}
rspMap["User"] = u
rspMap["user"] = u
rsp = rspMap
}
funcManagerInfo := func() {
... ...
package domain
type PartnerStatics struct {
PartnerInfo
// 订单金额
Amount float64 `json:"amount"`
// 分红
Bonus float64 `json:"bonus"`
// 分红支出
BonusExpense float64 `json:"bonus_expense"`
}
... ...
... ... @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/go-pg/pg/v10"
"github.com/go-pg/pg/v10/orm"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction"
. "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
... ... @@ -54,12 +55,31 @@ func (dao *PartnerInfoDao) PartnerStatic(queryOptions map[string]interface{}) (c
return
}
//func(dao *PartnerInfoDao)PartnerCompanyInfo(queryOptions map[string]interface{})(values map[string]interface{},err error){
//// tx := dao.transactionContext.PgTx
//// m := new(models.PartnerInfo)
//// query := NewQuery(tx.Model(m), queryOptions)
//// query.SetWhere("status=?","status")
////}
func (dao *PartnerInfoDao) PartnerStatics(queryOptions map[string]interface{}) (statics []*domain.PartnerStatics, err error) {
tx := dao.transactionContext.PgDd
//m := new(models.PartnerInfo)
sql := fmt.Sprintf(`select A.*,
(B.amount1+C.amount2) amount,(B.bonus1+C.bonus2) bonus,(B.bonus_expense1 + C.bonus_expense2) bonus_expense
from
(
select * from partner_info
WHERE (id in (1,2))
)
A left join
(
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"
WHERE (partner_id in (1,2)) and order_type =1
GROUP BY partner_id
) B on A."id" = B.partner_id
left join
(
select partner_info_id,count(*) total2,0 amount2, sum(bonus) bonus2, sum(bonus_expense) bonus_expense2 from business_bonus
WHERE (partner_info_id in (1,2)) and is_disable=1
GROUP BY partner_info_id
) C on A."id"= C."partner_info_id"`)
tx.Query(&statics, sql)
return
}
func NewPartnerInfoDao(transactionContext *transaction.TransactionContext) (*PartnerInfoDao, error) {
if transactionContext == nil {
... ...
... ... @@ -7,6 +7,7 @@ import (
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/validation"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
"strconv"
)
... ... @@ -41,6 +42,7 @@ func (controller *BaseController) Valid(obj interface{}) (result bool, msg *prot
valid := validation.Validation{}
result, err = valid.Valid(obj)
if err != nil {
log.Error(err)
}
if !result {
msg = protocol.BadRequestParam(2)
... ...
... ... @@ -4,7 +4,7 @@ type PartnersRequest struct {
// 页码索引(0开始)
PageIndex int `json:"pageIndex"`
// 每页数量
PageSize int `json:"pageSize" valid:"required"`
PageSize int `json:"pageSize" valid:"Required"`
// 起始时间戳
StartTime int64 `json:"startTime"`
// 结束时间戳
... ...