作者 唐旭辉

更新注释

... ... @@ -198,16 +198,25 @@ func (order *OrderBase) Compute() error {
planPartnerBonus := decimal.NewFromFloat(0)
planOrderAmount := decimal.NewFromFloat(0)
var (
planOrderCount int = 0
useOrderCount int = 0
//预计的货品总数,不包含调整后的值
planOrderCount int = 0
//调整后的货品总数,混合相加计算预计值和调整值中的一个,优先取调整值计算
useOrderCount int = 0
//订单的货品列表中是否存在调整货品数量
HasUseOrderCount bool = false
)
//调整后的合伙人分红,混合相加计算预计值和调整值中的一个,优先取调整值计算
usePartnerBonus := decimal.NewFromFloat(0)
//订单的货品列表中是否存在调整的合伙人分红
var hasUsePartnerBonus bool = false
//调整后的订单总额,混合相加计算预计值和调整值中的一个,优先取调整值计算
useOrderAmount := decimal.NewFromFloat(0)
var hasUseOrderAmount bool = false
//已支付分红
partnerBonusHas := decimal.NewFromFloat(0)
//未支付分红
partnerBonusNot := decimal.NewFromFloat(0)
//分红支出
partnerBonusExpense := decimal.NewFromFloat(0)
//初始订单的支付状态
order.BonusStatus = OrderGoodWaitPay
... ... @@ -215,14 +224,20 @@ func (order *OrderBase) Compute() error {
for i := range order.Goods {
if order.Goods[i].BonusStatus == OrderGoodHasPay {
//确定订单的支付状态
//订单的货品列表中“存在”支付状态的为已支付,则整体订单设定为已支付状态
order.BonusStatus = OrderGoodHasPay
}
//计算预计的合伙人分红,不含调整的值
planPartnerBonus = planPartnerBonus.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanPartnerBonus))
//计算预计的订单总金额,不含调整的值
planOrderAmount = planOrderAmount.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanAmount))
//计算预计的订单中货品总数,不含调整的值
planOrderCount += order.Goods[i].PlanGoodNumber
//获取调整货品调整后(数量)的总金额,
goodUseAmount := decimal.NewFromFloat(order.Goods[i].GoodCompute.UseAmount)
if goodUseAmount.GreaterThanOrEqual(decimal.NewFromFloat(0)) {
//调整值非负值得情况
//调整后货品总金额,非负值(大于等于0)的情况
hasUseOrderAmount = true
useOrderAmount = useOrderAmount.Add(goodUseAmount)
} else {
... ... @@ -230,12 +245,14 @@ func (order *OrderBase) Compute() error {
}
goodUsePartnerBonus := decimal.NewFromFloat(order.Goods[i].GoodCompute.UsePartnerBonus)
if goodUsePartnerBonus.GreaterThanOrEqual(decimal.NewFromFloat(0)) {
//货品中存在调整后的合伙人分红,即调整大于等于0
hasUsePartnerBonus = true
usePartnerBonus = usePartnerBonus.Add(goodUsePartnerBonus)
} else {
usePartnerBonus = usePartnerBonus.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanPartnerBonus))
}
if order.Goods[i].UseGoodNumber >= 0 {
//货品中存在调整后的数量,调整值大于等于0
HasUseOrderCount = true
useOrderCount += order.Goods[i].UseGoodNumber
} else {
... ...