作者 yangfu

增加:fix 统计

... ... @@ -167,10 +167,10 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont
}
if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderType: domain.OrderReal}); e == nil {
Statistics["careerOrdersMoney"] = bonus.TotalOrderAmount
Statistics["careerDividend"] = bonus.BonusExpense
Statistics["careerDividend"] = bonus.Bonus
}
if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, IsDisable: 1}); e == nil {
Statistics["businessDividend"] = businessBonus.BonusExpense
Statistics["businessDividend"] = businessBonus.Bonus
Statistics["businessOrdersMoney"] = businessBonus.TotalOrderAmount
}
Statistics["developDividend"] = 0
... ... @@ -251,7 +251,7 @@ func getPartners(userId int64, request *protocolx.PartnersRequest, transactionCo
mapPartners["district"] = protocolx.Districts{Id: p.RegionInfo.RegionId, Name: p.RegionInfo.RegionName}
}
mapPartners["cooperationTime"] = p.CooperateTime.Unix() * 1000
mapPartners["dividend"] = p.BonusExpense
mapPartners["dividend"] = utils.Decimal(p.Bonus)
mapPartners["ordersCount"] = p.Total
mapPartners["ordersMoney"] = utils.Decimal(p.Amount)
array = append(array, mapPartners)
... ...
... ... @@ -55,7 +55,7 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d
q.ColumnExpr("count(*) count")
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((case when use_order_count>0 then use_order_amount else plan_order_amount end)) total_order_amount")
q.ColumnExpr("sum(plan_order_amount) total_order_amount")
if option.PartnerId > 0 {
q.Where(`"order_base".partner_id =?`, option.PartnerId)
}
... ...
... ... @@ -106,11 +106,11 @@ A left join
SELECT partner_id,count(*) total,sum(amount) amount,sum(bonus) bonus,sum(bonus_expense) bonus_expense FROM
(
SELECT partner_id,
(case when use_order_count>0 then use_order_amount else plan_order_amount end) amount,
(case when use_order_count>0 then plan_order_amount else plan_order_amount end) amount,
(case when use_order_count>0 then use_partner_bonus else plan_partner_bonus end) bonus,
partner_bonus_expense bonus_expense FROM "order_base" AS "order_base"
WHERE (partner_id in (?)) and order_type =1
UNION
UNION ALL
SELECT partner_info_id partner_id,
0 amount, bonus bonus, bonus_expense bonus_expense FROM business_bonus
WHERE (partner_info_id in (?)) and is_disable=1
... ...