作者 yangfu

1.review code

... ... @@ -152,9 +152,7 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont
UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext)
OrderBaseDao, _ = factory.CreateOrderBaseDao(transactionContext)
//BusinessBonusDao, _ = factory.CreateBusinessBonusDao(transactionContext)
//user *domain.Users
partnerIds []int64
partnerIds []int64
)
if user, e := UsersRepository.FindOne(map[string]interface{}{"id": userId}); e != nil || user == nil {
return struct {
... ... @@ -163,10 +161,7 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont
partnerIds = user.AccessPartnerIds()
}
Statistics := make(map[string]interface{})
//Statistics["developDividend"] = 0
//Statistics["developOrdersMoney"] = 0
//Statistics["appDividend"] = 0
//Statistics["appOrdersMoney"] = 0
// TODO:分组统计
if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.Career}); e == nil {
Statistics["careerCount"] = count
}
... ... @@ -195,11 +190,6 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont
Statistics["appOrdersMoney"] = bonus.TotalOrderAmount
Statistics["appDividend"] = bonus.Bonus
}
//if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, IsDisable: 1}); e == nil {
// Statistics["businessDividend"] = businessBonus.Bonus
// Statistics["businessOrdersMoney"] = businessBonus.TotalOrderAmount
//}
Statistics["totalCount"] = len(partnerIds)
return Statistics, nil
}
... ...
... ... @@ -32,6 +32,7 @@ type OrderBonusQuery struct {
OrderType int `json:"orderType,omitempty"`
OrderTypes []int `json:"orderTypes,omitempty"`
PartnerCategoryId int `json:"partnerCategoryId,omitempty"` //订单所属类型
//IsGroupByPartnerCategoryId bool `json:"isGroupByPartnerCategoryId,omitempty"`
}
// 订单分红统计-应答
... ... @@ -44,4 +45,5 @@ type OrderBonusResponse struct {
BonusExpense float64 `json:"bonusExpense,omitempty"`
// 订单金额
TotalOrderAmount float64 `json:"totalOrderAmount"`
//PartnerCategory *PartnerCategoryInfo
}
... ...
... ... @@ -62,6 +62,7 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d
q.ColumnExpr("sum((case when use_order_count>=0 then use_partner_bonus else plan_partner_bonus end)) bonus")
q.ColumnExpr("sum(partner_bonus_expense) bonus_expense")
q.ColumnExpr("sum(plan_order_amount) total_order_amount")
//q.ColumnExpr("partner_category")
if option.PartnerId > 0 {
q.Where(`"order_base".partner_id =?`, option.PartnerId)
}
... ... @@ -80,6 +81,9 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d
if option.PartnerCategoryId > 0 {
q.Where(`"order_base".partner_category @>'{"id":?}'`, option.PartnerCategoryId)
}
//if option.IsGroupByPartnerCategoryId{
// q.Group(`partner_category`)
//}
err = q.Select(&rsp.Total, &rsp.Bonus, &rsp.BonusExpense, &rsp.TotalOrderAmount)
return
}
... ...