- status judge.

This commit is contained in:
gazebo
2018-08-23 11:51:20 +08:00
parent 1cb266d4d1
commit 5f10f01027
7 changed files with 77 additions and 51 deletions

View File

@@ -1,7 +1,6 @@
package basesch
import (
"errors"
"fmt"
"git.rosy.net.cn/baseapi/utils"
@@ -21,10 +20,6 @@ var (
FixedBaseScheduler *BaseScheduler
)
var (
ErrOrderStatusIsNotSuitable = errors.New("订单状态不适合当前操作")
)
func (c *BaseScheduler) Init() {
c.PurchasePlatformHandlers = make(map[int]partner.IPurchasePlatformHandler)
c.DeliveryPlatformHandlers = make(map[int]*scheduler.DeliveryPlatformHandlerInfo)
@@ -70,7 +65,8 @@ func (c *BaseScheduler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt
}, "AcceptOrRefuseOrder orderID:%s, isAcceptIt:%t", order.VendorOrderID, isAcceptIt)
}
} else {
globals.SugarLogger.Infof("AcceptOrRefuseOrder orderID:%s, status:%d is not suitable, isAcceptIt:%t", order.VendorOrderID, order.Status, isAcceptIt)
return scheduler.ErrOrderStatusAlreadySatisfyCurOperation
globals.SugarLogger.Debugf("AcceptOrRefuseOrder orderID:%s, status:%d is not suitable, isAcceptIt:%t", order.VendorOrderID, order.Status, isAcceptIt)
}
return err
}
@@ -85,9 +81,12 @@ func (c *BaseScheduler) PickupGoods(order *model.GoodsOrder, userName string) (e
}
} else {
if order.LockStatus != model.OrderStatusUnknown || order.Status < model.OrderStatusAccepted {
err = ErrOrderStatusIsNotSuitable
err = scheduler.ErrOrderStatusIsNotSuitable4CurOperation
globals.SugarLogger.Infof("PickupGoods orderID:%s, status:%d is not suitable", order.VendorOrderID, order.Status)
} else {
err = scheduler.ErrOrderStatusAlreadySatisfyCurOperation
globals.SugarLogger.Debugf("PickupGoods orderID:%s status:%d already ok", order.VendorOrderID, order.Status)
}
globals.SugarLogger.Infof("PickupGoods orderID:%s, status:%d is not suitable", order.VendorOrderID, order.Status)
}
return err
}
@@ -104,10 +103,13 @@ func (c *BaseScheduler) Swtich2SelfDeliver(order *model.GoodsOrder, userName str
}
}
} else {
if order.LockStatus != model.OrderStatusUnknown || order.Status < model.OrderStatusFinishedPickup {
err = ErrOrderStatusIsNotSuitable
if order.LockStatus != model.OrderStatusUnknown || order.Status < model.OrderStatusFinishedPickup || order.VendorID == order.WaybillVendorID {
err = scheduler.ErrOrderStatusIsNotSuitable4CurOperation
globals.SugarLogger.Infof("Swtich2SelfDeliver orderID:%s, status:%d is not suitable", order.VendorOrderID, order.Status)
} else {
err = scheduler.ErrOrderStatusAlreadySatisfyCurOperation
globals.SugarLogger.Debugf("Swtich2SelfDeliver orderID:%s status:%d already ok", order.VendorOrderID, order.Status)
}
globals.SugarLogger.Infof("Swtich2SelfDeliver orderID:%s, status:%d is not suitable", order.VendorOrderID, order.Status)
}
return err
}
@@ -121,7 +123,13 @@ func (c *BaseScheduler) Swtich2SelfDelivered(order *model.GoodsOrder, userName s
}, "Swtich2SelfDelivered orderID:%s", order.VendorOrderID)
}
} else {
globals.SugarLogger.Infof("Swtich2SelfDelivered orderID:%s, status:%d is not suitable", order.VendorOrderID, order.Status)
if order.LockStatus != model.OrderStatusUnknown || order.Status < model.OrderStatusDelivering {
err = scheduler.ErrOrderStatusIsNotSuitable4CurOperation
globals.SugarLogger.Infof("Swtich2SelfDelivered orderID:%s, status:%d is not suitable", order.VendorOrderID, order.Status)
} else {
err = scheduler.ErrOrderStatusAlreadySatisfyCurOperation
globals.SugarLogger.Debugf("Swtich2SelfDelivered orderID:%s status:%d already ok", order.VendorOrderID, order.Status)
}
}
return err
}
@@ -137,10 +145,14 @@ func (c *BaseScheduler) SelfDeliverDelievering(order *model.GoodsOrder, userName
order.Status = model.OrderStatusDelivering
}
}
} else if order.Status == model.OrderStatusDelivering {
globals.SugarLogger.Debugf("SelfDeliverDelievering orderID:%s, status:%d already ok", order.VendorOrderID, order.Status)
} else {
globals.SugarLogger.Infof("SelfDeliverDelievering orderID:%s, status:%d is not suitable", order.VendorOrderID, order.Status)
if order.LockStatus != model.OrderStatusUnknown || order.Status < model.OrderStatusFinishedPickup {
err = scheduler.ErrOrderStatusIsNotSuitable4CurOperation
globals.SugarLogger.Infof("SelfDeliverDelievering orderID:%s, status:%d is not suitable", order.VendorOrderID, order.Status)
} else {
err = scheduler.ErrOrderStatusAlreadySatisfyCurOperation
globals.SugarLogger.Debugf("SelfDeliverDelievering orderID:%s, status:%d already ok", order.VendorOrderID, order.Status)
}
}
return err
}
@@ -154,7 +166,13 @@ func (c *BaseScheduler) SelfDeliverDelievered(order *model.GoodsOrder, userName
}, "SelfDeliverDelievered orderID:%s", order.VendorOrderID)
}
} else {
globals.SugarLogger.Infof("SelfDeliverDelievered orderID:%s, status:%d is not suitable", order.VendorOrderID, order.Status)
if order.LockStatus != model.OrderStatusUnknown || order.Status < model.OrderStatusDelivering {
err = scheduler.ErrOrderStatusIsNotSuitable4CurOperation
globals.SugarLogger.Infof("SelfDeliverDelievered orderID:%s, status:%d is not suitable", order.VendorOrderID, order.Status)
} else {
err = scheduler.ErrOrderStatusAlreadySatisfyCurOperation
globals.SugarLogger.Debugf("SelfDeliverDelievered orderID:%s, status:%d already ok", order.VendorOrderID, order.Status)
}
}
return err
}