GetStoreOrderAfterTime排除内部单
This commit is contained in:
@@ -179,6 +179,7 @@ func GetStoreOrderAfterTime(db *DaoDB, storeID int, orderTime time.Time, lastOrd
|
|||||||
FROM goods_order t1
|
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
|
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 < ?
|
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;
|
ORDER BY t1.order_created_at DESC, t1.id DESC;
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
@@ -186,6 +187,7 @@ func GetStoreOrderAfterTime(db *DaoDB, storeID int, orderTime time.Time, lastOrd
|
|||||||
orderTime,
|
orderTime,
|
||||||
lastOrderSeqID,
|
lastOrderSeqID,
|
||||||
model.OrderStatusEndBegin,
|
model.OrderStatusEndBegin,
|
||||||
|
model.OrderFlagMaskFake,
|
||||||
}
|
}
|
||||||
return orderList, GetRows(db, &orderList, sql, sqlParams...)
|
return orderList, GetRows(db, &orderList, sql, sqlParams...)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,23 +107,26 @@ func unregisterChan(storeID int, chan2Listen chan<- *ServerMsg) {
|
|||||||
<-chan2Close
|
<-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 {
|
if utils.IsTimeZero(lastOrderTime) || time.Now().Sub(lastOrderTime) > maxGetOrderTimeDuration {
|
||||||
lastOrderTime = time.Now().Add(-maxGetOrderTimeDuration)
|
lastOrderTime = time.Now().Add(-maxGetOrderTimeDuration)
|
||||||
}
|
}
|
||||||
orderList, err = dao.GetStoreOrderAfterTime(dao.GetDB(), storeID, lastOrderTime, lastOrderSeqID)
|
orderList, err := dao.GetStoreOrderAfterTime(dao.GetDB(), storeID, lastOrderTime, lastOrderSeqID)
|
||||||
return orderList, err
|
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) {
|
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 {
|
if err == nil {
|
||||||
msg = &ServerMsg{
|
msg = &ServerMsg{
|
||||||
Type: ServerMsgNewOrder,
|
Type: ServerMsgNewOrder,
|
||||||
StoreID: storeID,
|
StoreID: storeID,
|
||||||
MsgData: 0,
|
MsgData: 0,
|
||||||
}
|
}
|
||||||
if len(orderList) == 0 {
|
if len(vendorOrderIDs) == 0 {
|
||||||
chan2Listen := make(chan *ServerMsg, 1)
|
chan2Listen := make(chan *ServerMsg, 1)
|
||||||
registerChan(storeID, chan2Listen)
|
registerChan(storeID, chan2Listen)
|
||||||
pollingDuration := defPollingDuration
|
pollingDuration := defPollingDuration
|
||||||
@@ -149,7 +152,8 @@ func GetMsg(ctx *jxcontext.Context, storeID int, lastOrderTime time.Time, lastOr
|
|||||||
}
|
}
|
||||||
close(chan2Listen)
|
close(chan2Listen)
|
||||||
} else {
|
} else {
|
||||||
msg.MsgData = len(orderList)
|
globals.SugarLogger.Debugf("GetMsg vendorOrderIDs:%s", utils.Format4Output(vendorOrderIDs, true))
|
||||||
|
msg.MsgData = len(vendorOrderIDs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return msg, err
|
return msg, err
|
||||||
|
|||||||
Reference in New Issue
Block a user