|
...
|
...
|
@@ -70,9 +70,11 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { |
|
|
|
}
|
|
|
|
var (
|
|
|
|
OrderDao, _ = dao.NewOrderBaseDao(svr.transactionContext)
|
|
|
|
BusinessBonusDao, _ = dao.NewBusinessBonusDao(svr.transactionContext)
|
|
|
|
PartnerCategoryInfoRepository, _ = repository.NewPartnerCategoryInfoRepository(svr.transactionContext)
|
|
|
|
companyList []*domain.Company
|
|
|
|
allPartnerCategory []*domain.PartnerCategoryInfo
|
|
|
|
BusinessBonusRepository, _ = repository.NewBusinessBonusRepository(svr.transactionContext)
|
|
|
|
)
|
|
|
|
doGetCompanyIds := func() []int64 {
|
|
|
|
var companies []int64
|
|
...
|
...
|
@@ -96,7 +98,16 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { |
|
|
|
if e != nil {
|
|
|
|
return nil, e
|
|
|
|
}
|
|
|
|
if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: doGetPartnerIds(), IsDisable: 1}); e == nil {
|
|
|
|
totalBonus.Bonus += businessBonus.Bonus
|
|
|
|
}
|
|
|
|
_, allPartnerCategory, e = PartnerCategoryInfoRepository.Find(map[string]interface{}{"sortById": domain.ASC})
|
|
|
|
var mapPartnerBussinessBonus = make(map[int64]*domain.BusinessBonus)
|
|
|
|
if _, bussinessBonus, e := BusinessBonusRepository.Find(map[string]interface{}{"inPartnerIds": doGetPartnerIds(), "isDisable": 1}); e == nil {
|
|
|
|
for _, v := range bussinessBonus {
|
|
|
|
mapPartnerBussinessBonus[v.PartnerInfoId] = v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if e != nil {
|
|
|
|
log.Error(e)
|
|
|
|
return nil, e
|
|
...
|
...
|
@@ -115,18 +126,15 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { |
|
|
|
continue
|
|
|
|
}
|
|
|
|
bonus, _ := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: partner.Id, OrderType: domain.OrderReal})
|
|
|
|
if v, ok := mapPartnerBussinessBonus[partner.Id]; ok {
|
|
|
|
bonus.Bonus += v.Bonus
|
|
|
|
}
|
|
|
|
item := &Company{
|
|
|
|
CompanyBase: newCompanyBase(c),
|
|
|
|
IncomePercent: computeBonusPercent(totalBonus.Bonus, bonus.Bonus*100),
|
|
|
|
DividendMoney: utils.Decimal(bonus.Bonus),
|
|
|
|
JoinWays: svr.GetJoinWays(allPartnerCategory, partner, bonus.Bonus),
|
|
|
|
}
|
|
|
|
//当所有公司的总收入都为0时,
|
|
|
|
//初始总收入=公司数*1
|
|
|
|
//否则计算的比例始终都为0
|
|
|
|
if totalBonus.Bonus == 0 {
|
|
|
|
item.IncomePercent = computeBonusPercent(totalBonus.Bonus+float64(len(companyList)), bonus.Bonus+1) * 100
|
|
|
|
}
|
|
|
|
companys = append(companys, item)
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|