GetStoreOrderAfterTime排除内部单

This commit is contained in:
gazebo
2019-12-03 17:52:51 +08:00
parent b25b7ebe41
commit 457bd4b0a2
2 changed files with 12 additions and 6 deletions

View File

@@ -179,6 +179,7 @@ func GetStoreOrderAfterTime(db *DaoDB, storeID int, orderTime time.Time, lastOrd
FROM goods_order t1
LEFT JOIN waybill t2 ON t1.vendor_waybill_id = t2.vendor_waybill_id AND t1.waybill_vendor_id = t2.waybill_vendor_id
WHERE IF(t1.jx_store_id <> 0, t1.jx_store_id, t1.store_id) = ? AND t1.order_created_at >= ? AND t1.id > ? AND t1.status < ?
AND (t1.flag & ?) = 0
ORDER BY t1.order_created_at DESC, t1.id DESC;
`
sqlParams := []interface{}{
@@ -186,6 +187,7 @@ func GetStoreOrderAfterTime(db *DaoDB, storeID int, orderTime time.Time, lastOrd
orderTime,
lastOrderSeqID,
model.OrderStatusEndBegin,
model.OrderFlagMaskFake,
}
return orderList, GetRows(db, &orderList, sql, sqlParams...)
}

View File

@@ -107,23 +107,26 @@ func unregisterChan(storeID int, chan2Listen chan<- *ServerMsg) {
<-chan2Close
}
func getPendingOrderList(storeID int, lastOrderTime time.Time, lastOrderSeqID int64) (orderList []*model.GoodsOrderExt, err error) {
func getPendingOrderList(storeID int, lastOrderTime time.Time, lastOrderSeqID int64) (vendorOrderIDs []string, err error) {
if utils.IsTimeZero(lastOrderTime) || time.Now().Sub(lastOrderTime) > maxGetOrderTimeDuration {
lastOrderTime = time.Now().Add(-maxGetOrderTimeDuration)
}
orderList, err = dao.GetStoreOrderAfterTime(dao.GetDB(), storeID, lastOrderTime, lastOrderSeqID)
return orderList, err
orderList, err := dao.GetStoreOrderAfterTime(dao.GetDB(), storeID, lastOrderTime, lastOrderSeqID)
for _, v := range orderList {
vendorOrderIDs = append(vendorOrderIDs, v.VendorOrderID)
}
return vendorOrderIDs, err
}
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)
vendorOrderIDs, err := getPendingOrderList(storeID, lastOrderTime, lastOrderSeqID)
if err == nil {
msg = &ServerMsg{
Type: ServerMsgNewOrder,
StoreID: storeID,
MsgData: 0,
}
if len(orderList) == 0 {
if len(vendorOrderIDs) == 0 {
chan2Listen := make(chan *ServerMsg, 1)
registerChan(storeID, chan2Listen)
pollingDuration := defPollingDuration
@@ -149,7 +152,8 @@ func GetMsg(ctx *jxcontext.Context, storeID int, lastOrderTime time.Time, lastOr
}
close(chan2Listen)
} else {
msg.MsgData = len(orderList)
globals.SugarLogger.Debugf("GetMsg vendorOrderIDs:%s", utils.Format4Output(vendorOrderIDs, true))
msg.MsgData = len(vendorOrderIDs)
}
}
return msg, err