作者 唐旭辉

更新注释

@@ -198,16 +198,25 @@ func (order *OrderBase) Compute() error { @@ -198,16 +198,25 @@ func (order *OrderBase) Compute() error {
198 planPartnerBonus := decimal.NewFromFloat(0) 198 planPartnerBonus := decimal.NewFromFloat(0)
199 planOrderAmount := decimal.NewFromFloat(0) 199 planOrderAmount := decimal.NewFromFloat(0)
200 var ( 200 var (
201 - planOrderCount int = 0  
202 - useOrderCount int = 0 201 + //预计的货品总数,不包含调整后的值
  202 + planOrderCount int = 0
  203 + //调整后的货品总数,混合相加计算预计值和调整值中的一个,优先取调整值计算
  204 + useOrderCount int = 0
  205 + //订单的货品列表中是否存在调整货品数量
203 HasUseOrderCount bool = false 206 HasUseOrderCount bool = false
204 ) 207 )
  208 + //调整后的合伙人分红,混合相加计算预计值和调整值中的一个,优先取调整值计算
205 usePartnerBonus := decimal.NewFromFloat(0) 209 usePartnerBonus := decimal.NewFromFloat(0)
  210 + //订单的货品列表中是否存在调整的合伙人分红
206 var hasUsePartnerBonus bool = false 211 var hasUsePartnerBonus bool = false
  212 + //调整后的订单总额,混合相加计算预计值和调整值中的一个,优先取调整值计算
207 useOrderAmount := decimal.NewFromFloat(0) 213 useOrderAmount := decimal.NewFromFloat(0)
208 var hasUseOrderAmount bool = false 214 var hasUseOrderAmount bool = false
  215 + //已支付分红
209 partnerBonusHas := decimal.NewFromFloat(0) 216 partnerBonusHas := decimal.NewFromFloat(0)
  217 + //未支付分红
210 partnerBonusNot := decimal.NewFromFloat(0) 218 partnerBonusNot := decimal.NewFromFloat(0)
  219 + //分红支出
211 partnerBonusExpense := decimal.NewFromFloat(0) 220 partnerBonusExpense := decimal.NewFromFloat(0)
212 //初始订单的支付状态 221 //初始订单的支付状态
213 order.BonusStatus = OrderGoodWaitPay 222 order.BonusStatus = OrderGoodWaitPay
@@ -215,14 +224,20 @@ func (order *OrderBase) Compute() error { @@ -215,14 +224,20 @@ func (order *OrderBase) Compute() error {
215 for i := range order.Goods { 224 for i := range order.Goods {
216 if order.Goods[i].BonusStatus == OrderGoodHasPay { 225 if order.Goods[i].BonusStatus == OrderGoodHasPay {
217 //确定订单的支付状态 226 //确定订单的支付状态
  227 + //订单的货品列表中“存在”支付状态的为已支付,则整体订单设定为已支付状态
218 order.BonusStatus = OrderGoodHasPay 228 order.BonusStatus = OrderGoodHasPay
219 } 229 }
  230 + //计算预计的合伙人分红,不含调整的值
220 planPartnerBonus = planPartnerBonus.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanPartnerBonus)) 231 planPartnerBonus = planPartnerBonus.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanPartnerBonus))
  232 + //计算预计的订单总金额,不含调整的值
221 planOrderAmount = planOrderAmount.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanAmount)) 233 planOrderAmount = planOrderAmount.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanAmount))
  234 + //计算预计的订单中货品总数,不含调整的值
222 planOrderCount += order.Goods[i].PlanGoodNumber 235 planOrderCount += order.Goods[i].PlanGoodNumber
  236 + //获取调整货品调整后(数量)的总金额,
223 goodUseAmount := decimal.NewFromFloat(order.Goods[i].GoodCompute.UseAmount) 237 goodUseAmount := decimal.NewFromFloat(order.Goods[i].GoodCompute.UseAmount)
  238 +
224 if goodUseAmount.GreaterThanOrEqual(decimal.NewFromFloat(0)) { 239 if goodUseAmount.GreaterThanOrEqual(decimal.NewFromFloat(0)) {
225 - //调整值非负值得情况 240 + //调整后货品总金额,非负值(大于等于0)的情况
226 hasUseOrderAmount = true 241 hasUseOrderAmount = true
227 useOrderAmount = useOrderAmount.Add(goodUseAmount) 242 useOrderAmount = useOrderAmount.Add(goodUseAmount)
228 } else { 243 } else {
@@ -230,12 +245,14 @@ func (order *OrderBase) Compute() error { @@ -230,12 +245,14 @@ func (order *OrderBase) Compute() error {
230 } 245 }
231 goodUsePartnerBonus := decimal.NewFromFloat(order.Goods[i].GoodCompute.UsePartnerBonus) 246 goodUsePartnerBonus := decimal.NewFromFloat(order.Goods[i].GoodCompute.UsePartnerBonus)
232 if goodUsePartnerBonus.GreaterThanOrEqual(decimal.NewFromFloat(0)) { 247 if goodUsePartnerBonus.GreaterThanOrEqual(decimal.NewFromFloat(0)) {
  248 + //货品中存在调整后的合伙人分红,即调整大于等于0
233 hasUsePartnerBonus = true 249 hasUsePartnerBonus = true
234 usePartnerBonus = usePartnerBonus.Add(goodUsePartnerBonus) 250 usePartnerBonus = usePartnerBonus.Add(goodUsePartnerBonus)
235 } else { 251 } else {
236 usePartnerBonus = usePartnerBonus.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanPartnerBonus)) 252 usePartnerBonus = usePartnerBonus.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanPartnerBonus))
237 } 253 }
238 if order.Goods[i].UseGoodNumber >= 0 { 254 if order.Goods[i].UseGoodNumber >= 0 {
  255 + //货品中存在调整后的数量,调整值大于等于0
239 HasUseOrderCount = true 256 HasUseOrderCount = true
240 useOrderCount += order.Goods[i].UseGoodNumber 257 useOrderCount += order.Goods[i].UseGoodNumber
241 } else { 258 } else {