...
|
...
|
@@ -64,7 +64,11 @@ func Statistics(header *protocol.RequestHeader, request *protocolx.StatisticsReq |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
rsp.Statistics, err = getStatistics(header.UserId, transactionContext)
|
|
|
if err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
err = transactionContext.CommitTransaction()
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -127,3 +131,47 @@ func getJoinWays(transactionContext *transaction.TransactionContext) (joinWays [ |
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 获取公司统计
|
|
|
func getStatistics(userId int64, transactionContext *transaction.TransactionContext) (interface{}, error) {
|
|
|
var (
|
|
|
UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
|
|
|
PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext)
|
|
|
OrderBaseDao, _ = factory.CreateOrderBaseDao(transactionContext)
|
|
|
BusinessBonusDao, _ = factory.CreateBusinessBonusDao(transactionContext)
|
|
|
//user *domain.Users
|
|
|
partnerIds []int64
|
|
|
)
|
|
|
if user, e := UsersRepository.FindOne(map[string]interface{}{"id": userId}); e != nil || user == nil {
|
|
|
return struct {
|
|
|
}{}, nil
|
|
|
} else {
|
|
|
partnerIds = user.AccessPartnerIds()
|
|
|
}
|
|
|
Statistics := make(map[string]interface{})
|
|
|
if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.Career}); e == nil {
|
|
|
Statistics["careerCount"] = count
|
|
|
}
|
|
|
if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.Business}); e == nil {
|
|
|
Statistics["businessCount"] = count
|
|
|
}
|
|
|
if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.Develop}); e == nil {
|
|
|
Statistics["developCount"] = count
|
|
|
}
|
|
|
if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.App}); e == nil {
|
|
|
Statistics["appCount"] = count
|
|
|
}
|
|
|
if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds}); e == nil {
|
|
|
Statistics["careerOrdersMoney"] = bonus.TotalOrderAmount
|
|
|
Statistics["careerDividend"] = bonus.BonusExpense
|
|
|
}
|
|
|
if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, IsDisable: 1}); e == nil {
|
|
|
Statistics["businessDividend"] = businessBonus.BonusExpense
|
|
|
Statistics["businessOrdersMoney"] = businessBonus.TotalOrderAmount
|
|
|
}
|
|
|
Statistics["developDividend"] = 0
|
|
|
Statistics["developOrdersMoney"] = 0
|
|
|
Statistics["appDividend"] = 0
|
|
|
Statistics["appOrdersMoney"] = 0
|
|
|
return Statistics, nil
|
|
|
} |
...
|
...
|
|