- new field GoodsOrder.Flag
- SetOrderPrintStatus
This commit is contained in:
@@ -20,8 +20,10 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
maxGetOrderTimeDuration = 2 * time.Hour
|
||||
pollingDuration = 5 * time.Minute
|
||||
maxGetOrderTimeDuration = 24 * time.Hour
|
||||
minPollingDuration = 1 * time.Minute
|
||||
defPollingDuration = 5 * time.Minute
|
||||
maxPollingDuration = 10 * time.Minute
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -102,19 +104,28 @@ func unregisterChan(storeID int, chan2Listen chan<- *ServerMsg) {
|
||||
func getPendingOrderList(storeID int, lastOrderTime time.Time, lastOrderSeqID int64) (orderList []*model.GoodsOrderExt, err error) {
|
||||
if !jxutils.IsTimeEmpty(lastOrderTime) {
|
||||
if time.Now().Sub(lastOrderTime) > maxGetOrderTimeDuration {
|
||||
// lastOrderTime = time.Now().Add(-maxGetOrderTimeDuration)
|
||||
lastOrderTime = time.Now().Add(-maxGetOrderTimeDuration)
|
||||
}
|
||||
orderList, err = dao.GetStoreOrderAfterTime(dao.GetDB(), storeID, lastOrderTime, lastOrderSeqID)
|
||||
}
|
||||
return orderList, err
|
||||
}
|
||||
|
||||
func GetMsg(ctx *jxcontext.Context, storeID int, lastOrderTime time.Time, lastOrderSeqID int64, msgTypeList []string) (msg *ServerMsg, err error) {
|
||||
func GetMsg(ctx *jxcontext.Context, storeID int, lastOrderTime time.Time, lastOrderSeqID int64, msgTypeList []string, waitingSecond int) (msg *ServerMsg, err error) {
|
||||
orderList, err := getPendingOrderList(storeID, lastOrderTime, lastOrderSeqID)
|
||||
if err == nil {
|
||||
if len(orderList) == 0 {
|
||||
chan2Listen := make(chan *ServerMsg, 1)
|
||||
registerChan(storeID, chan2Listen)
|
||||
pollingDuration := defPollingDuration
|
||||
if waitingSecond != 0 {
|
||||
pollingDuration = time.Duration(waitingSecond) * time.Second
|
||||
if pollingDuration > maxPollingDuration {
|
||||
pollingDuration = maxPollingDuration
|
||||
} else if pollingDuration < minPollingDuration {
|
||||
pollingDuration = minPollingDuration
|
||||
}
|
||||
}
|
||||
timer := time.NewTimer(pollingDuration)
|
||||
select {
|
||||
case msg2, ok := <-chan2Listen:
|
||||
|
||||
Reference in New Issue
Block a user