order_statics.go 1.9 KB
package domain

import "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"

//分洪统计
type OrderStatics struct {
	//1:待支付分红 2:已支付分红
	BonusStatus int8
	//预计的订单内货品总数
	PlanOrderCount int
	//预计的订单的总金额
	PlanOrderAmount float64
	//按需使用的订单内货品总数 (初始值=-1)
	UseOrderCount int
	//按需使用的订单内货品总数 (初始值=-1)
	UseOrderAmount float64
	//合伙人应收分红
	PlanPartnerBonus float64
	//调整后的合伙人应收分红 (初始值=-1)
	UsePartnerBonus float64
	//合伙人已收分红
	PartnerBonusHas float64
	//合伙人未收分红
	PartnerBonusNot float64
	//合伙人分红支出
	PartnerBonusExpense float64
}

//订单应收分红 = 初始分红 / 有调整 取调整后分红
func (m *OrderStatics) OrderTotalReceivable() float64 {
	if m.UseOrderCount >= 0 {
		return utils.Decimal(m.UsePartnerBonus)
	}
	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
	return m.PartnerBonusNot
}

//分红支出 = 分红支出
func (m *OrderStatics) OrderBonusOutstanding() float64 {
	return utils.Decimal(m.PartnerBonusExpense)
}

//订单被取消金额
func (m *OrderStatics) OrderAmountCancel() float64 {
	if m.UseOrderAmount < 0 {
		return 0
	}
	if m.PlanOrderAmount < m.UseOrderAmount {
		return 0
	}
	return utils.Decimal(m.PlanOrderAmount - m.UseOrderAmount)
}

//订单金额
func (m *OrderStatics) OrderAmount() float64 {
	if m.UseOrderAmount < 0 {
		return m.PlanOrderAmount
	}
	return m.UseOrderAmount
}