...
|
...
|
@@ -188,15 +188,9 @@ func (status *UnShippedStatus) Update(order *Order, data map[string]interface{}) |
|
|
if remarks, ok := data["remarks"]; ok {
|
|
|
order.Remarks = remarks.(string)
|
|
|
}
|
|
|
if createAt, ok := data["createAt"]; ok {
|
|
|
order.CreateAt = createAt.(time.Time)
|
|
|
}
|
|
|
if updateAt, ok := data["updateAt"]; ok {
|
|
|
order.UpdateAt = updateAt.(time.Time)
|
|
|
}
|
|
|
if deleteAt, ok := data["deleteAt"]; ok {
|
|
|
order.DeleteAt = deleteAt.(time.Time)
|
|
|
}
|
|
|
order.UpdateAt = time.Now()
|
|
|
|
|
|
order.ComputeDividend()
|
|
|
return nil
|
|
|
}
|
|
|
|
...
|
...
|
@@ -227,6 +221,11 @@ func (status *UnShippedStatus) Receive(order *Order) error { |
|
|
return fmt.Errorf("待发货订单不能收货")
|
|
|
}
|
|
|
|
|
|
// 待收货订单不能关闭
|
|
|
func (status *UnShippedStatus) Close(order *Order) error {
|
|
|
return fmt.Errorf("待收货订单不能关闭")
|
|
|
}
|
|
|
|
|
|
// 待收货状态
|
|
|
type TransitStatus struct{}
|
|
|
|
...
|
...
|
@@ -510,3 +509,70 @@ func (order *Order) Cancel() error { |
|
|
func (order *Order) Close() error {
|
|
|
return order.CurrentStatus.Close(order)
|
|
|
}
|
|
|
|
|
|
func (order *Order) RefreshOrderDetail() {
|
|
|
|
|
|
}
|
|
|
func (order *Order) ComputeDividend() {
|
|
|
order.computeGoodsDividend()
|
|
|
order.computeOrderDividend()
|
|
|
}
|
|
|
func (order *Order) computeOrderDividend() {
|
|
|
var totalPlanBonus float64
|
|
|
// 调整后分红
|
|
|
var totalUseBonus float64
|
|
|
// 已收分红
|
|
|
var totalBonusHas float64
|
|
|
// 未收分红
|
|
|
var totalBonusNot float64
|
|
|
// 分红支出
|
|
|
var totalBonusExpense float64
|
|
|
for _, v := range order.OrderGoods {
|
|
|
totalPlanBonus += v.GoodDividend.PlanBonus
|
|
|
totalUseBonus += v.GoodDividend.UseBonus
|
|
|
totalBonusHas += v.GoodDividend.BonusHas
|
|
|
totalBonusNot += v.GoodDividend.BonusNot
|
|
|
totalBonusExpense += v.GoodDividend.BonusExpense
|
|
|
}
|
|
|
order.OrderDividend.PlanBonus = totalPlanBonus
|
|
|
order.OrderDividend.UseBonus = totalUseBonus
|
|
|
order.OrderDividend.BonusHas = totalBonusHas
|
|
|
order.OrderDividend.BonusNot = totalBonusNot
|
|
|
order.OrderDividend.BonusExpense = totalBonusExpense
|
|
|
}
|
|
|
func (order *Order) computeGoodsDividend() {
|
|
|
for i := range order.OrderGoods {
|
|
|
good := order.OrderGoods[i]
|
|
|
bonus := good.GoodTotalPrice * float64(good.GoodNum) * (order.OrderDividend.PartnerBonusPercent / 100)
|
|
|
if good.GoodDividend == nil {
|
|
|
good.GoodDividend = &Dividend{
|
|
|
PlanBonus: bonus,
|
|
|
UseBonus: -1,
|
|
|
BonusHas: 0,
|
|
|
BonusNot: bonus,
|
|
|
BonusExpense: 0,
|
|
|
BonusStatus: Dividend_Unpaid,
|
|
|
}
|
|
|
} else {
|
|
|
/* 计算预计分红、调整后分红 */
|
|
|
if bonus != good.GoodDividend.PlanBonus {
|
|
|
if order.OrderStatus == ORDER_STATUS_UNSHIPPED {
|
|
|
good.GoodDividend.PlanBonus = bonus
|
|
|
good.GoodDividend.BonusNot = bonus
|
|
|
} else {
|
|
|
expense := good.GoodDividend.PlanBonus - bonus
|
|
|
if expense <= 0 {
|
|
|
expense = 0
|
|
|
}
|
|
|
good.GoodDividend.UseBonus = bonus
|
|
|
good.GoodDividend.BonusNot = bonus
|
|
|
good.GoodDividend.BonusExpense = expense
|
|
|
}
|
|
|
}
|
|
|
/*计算未支付分红*/
|
|
|
if good.GoodDividend.BonusHas > 0 {
|
|
|
good.GoodDividend.BonusNot = good.GoodDividend.PlanBonus - good.GoodDividend.BonusHas
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|