作者 yangfu

修改:分红统计修改

... ... @@ -53,7 +53,7 @@ func AllBonusStatics(orders []*domain.OrderBase, action int) (bonus protocol.Bon
o := orders[i]
bonus.Received = utils.Decimal(bonus.Received + o.OrderBonusReceive())
bonus.Outstanding = utils.Decimal(bonus.Outstanding + o.OrderBonusWait())
bonus.Receivable = utils.Decimal(bonus.Receivable + o.PlanPartnerBonus)
bonus.Receivable = utils.Decimal(bonus.Receivable + o.OrderTotalBonus())
}
return
}
... ... @@ -64,7 +64,7 @@ func QuartersBonusStatics(orders []*domain.OrderBase, action int) (bonus []proto
for i := range orders {
o := orders[i]
quarter := quarter(o.CreateTime)
bonus[quarter].Receivable = utils.Decimal(bonus[quarter].Receivable + o.PlanPartnerBonus)
bonus[quarter].Receivable = utils.Decimal(bonus[quarter].Receivable + o.OrderTotalBonus())
bonus[quarter].Received = utils.Decimal(bonus[quarter].Received + o.OrderBonusReceive())
bonus[quarter].Outstanding = utils.Decimal(bonus[quarter].Outstanding + o.OrderBonusWait())
//bonus[quarter].Expend = utils.Decimal(bonus[quarter].Expend + o.OrderBonusOutstanding())
... ... @@ -122,11 +122,12 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR
for i := range orders {
o := orders[i]
s := o.OrderBonusStatic()
item := &protocol.DividendOrderListItem{
Id: o.Id,
DeliveryNo: o.DeliveryCode,
OrderAmount: o.PlanOrderAmount,
DividendReceivable: utils.Decimal(o.OrderTotalBonus()),
OrderAmount: s.PlanOrderAmount, //s.OrderAmount(),
DividendReceivable: utils.Decimal(s.OrderTotalBonus()),
}
rsp.List = append(rsp.List, item)
}
... ...
... ... @@ -76,15 +76,16 @@ func orderProducts(order *domain.OrderBase) interface{} {
var products []map[string]interface{}
for i := range order.OrderGood {
good := order.OrderGood[i]
static := good.OrderBonusStatic()
item := make(map[string]interface{})
item["productName"] = good.GoodName
item["orderCount"] = good.PlanGoodNumber
item["orderAmount"] = good.PlanAmount
item["dividendPercent"] = good.PartnerBonusPercent
item["dividendReceivable"] = good.PlanPartnerBonus //应收分红
item["dividendReceived"] = good.PartnerBonusHas //已收分红
item["dividendUnReceive"] = good.PartnerBonusNot // 未收分红
item["dividendExpend"] = good.PartnerBonusExpense //分红支出
item["dividendReceivable"] = static.OrderTotalBonus() //应收分红
item["dividendReceived"] = static.OrderBonusReceive() //已收分红
item["dividendUnReceive"] = static.OrderBonusWait() // 未收分红
item["dividendExpend"] = static.OrderBonusOutstanding() //分红支出
if len(good.Remark) > 0 {
item["orderUpdateReason"] = good.Remark
}
... ... @@ -148,6 +149,8 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic
}); err != nil {
return
}
rsp.Statistics.TodayRealMoney = utils.Decimal(rsp.Statistics.TodayRealMoney)
rsp.Statistics.CumulativeMoney = utils.Decimal(rsp.Statistics.CumulativeMoney)
err = transactionContext.CommitTransaction()
return
}
... ...
... ... @@ -72,6 +72,21 @@ func (m *OrderGood) Identify() interface{} {
return m.Id
}
func (m *OrderGood) OrderBonusStatic() *OrderStatics {
return &OrderStatics{
BonusStatus: int8(m.BonusStatus),
PlanOrderCount: m.PlanGoodNumber,
PlanOrderAmount: m.PlanAmount,
UseOrderCount: m.UseGoodNumber,
UseOrderAmount: m.UseAmount,
PlanPartnerBonus: m.PlanPartnerBonus,
UsePartnerBonus: m.UsePartnerBonus,
PartnerBonusHas: m.PartnerBonusHas,
PartnerBonusNot: m.PartnerBonusNot,
PartnerBonusExpense: m.PartnerBonusExpense,
}
}
type OrderGoodRepository interface {
Save(dm *OrderGood) (*OrderGood, error)
Remove(dm *OrderGood) (*OrderGood, error)
... ...
... ... @@ -26,29 +26,31 @@ type OrderStatics struct {
PartnerBonusExpense float64
}
//订单应收分红
//订单应收分红 = 已收分红 + 未收分红
func (m *OrderStatics) OrderTotalBonus() float64 {
if m.UseOrderCount >= 0 {
return utils.Decimal(m.UsePartnerBonus + m.PartnerBonusExpense)
}
return utils.Decimal(m.PlanPartnerBonus)
//if m.UseOrderCount >= 0 {
// return utils.Decimal(m.UsePartnerBonus + m.PartnerBonusExpense)
//}
//return utils.Decimal(m.PlanPartnerBonus)
return utils.Decimal(m.PartnerBonusHas + m.PartnerBonusNot)
}
//订单已收分红
//订单已收分红 = 已收分红
func (m *OrderStatics) OrderBonusReceive() float64 {
return utils.Decimal(m.PartnerBonusHas)
}
//订单未收分红
//订单未收分红 = 未收分红
func (m *OrderStatics) OrderBonusWait() float64 {
bonusWait := m.OrderTotalBonus() - m.OrderBonusReceive()
if bonusWait < 0 {
return 0
}
return bonusWait
//bonusWait := m.OrderTotalBonus() - m.OrderBonusReceive()
//if bonusWait < 0 {
// return 0
//}
//return bonusWait
return m.PartnerBonusNot
}
//分红支出
//分红支出 = 分红支出
func (m *OrderStatics) OrderBonusOutstanding() float64 {
return utils.Decimal(m.PartnerBonusExpense)
}
... ... @@ -58,10 +60,10 @@ func (m *OrderStatics) OrderAmountCancel() float64 {
if m.UseOrderAmount < 0 {
return 0
}
if m.PlanOrderAmount > m.UseOrderAmount {
if m.PlanOrderAmount < m.UseOrderAmount {
return 0
}
return utils.Decimal(m.UseOrderAmount - m.PlanOrderAmount)
return utils.Decimal(m.PlanOrderAmount - m.UseOrderAmount)
}
//订单金额
... ...