优化mtwm.ListOrders
This commit is contained in:
@@ -3,6 +3,7 @@ package mtwm
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -571,19 +572,29 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, parentTask tasksch.
|
|||||||
vendorStoreID := batchItemList[0].(string)
|
vendorStoreID := batchItemList[0].(string)
|
||||||
var orderIDs []string
|
var orderIDs []string
|
||||||
seqStart := 1
|
seqStart := 1
|
||||||
|
i := 0
|
||||||
for {
|
for {
|
||||||
seqEnd := seqStart + mtwmapi.MaxGap4GetOrderIdByDaySeq - 1
|
batchSize := int(math.Min(math.Pow(2, float64(i)), float64(mtwmapi.MaxGap4GetOrderIdByDaySeq)))
|
||||||
tmpOrderIDs, err2 := api.MtwmAPI.GetOrderIdByDaySeq(vendorStoreID, queryDate, seqStart, seqEnd)
|
seqEnd := seqStart + batchSize - 1
|
||||||
|
var tmpOrderIDs []int64
|
||||||
|
if seqStart == seqEnd {
|
||||||
|
if vendorOderID, err2 := api.MtwmAPI.GetOrderIdByDaySeqSingle(vendorStoreID, queryDate, seqStart); err2 == nil {
|
||||||
|
tmpOrderIDs = []int64{vendorOderID}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tmpOrderIDs, err = api.MtwmAPI.GetOrderIdByDaySeq(vendorStoreID, queryDate, seqStart, seqEnd)
|
||||||
|
}
|
||||||
if len(tmpOrderIDs) > 0 {
|
if len(tmpOrderIDs) > 0 {
|
||||||
for _, v := range tmpOrderIDs {
|
for _, v := range tmpOrderIDs {
|
||||||
orderIDs = append(orderIDs, utils.Int64ToStr(v))
|
orderIDs = append(orderIDs, utils.Int64ToStr(v))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err = err2; err != nil || len(tmpOrderIDs) < mtwmapi.MaxGap4GetOrderIdByDaySeq {
|
if err != nil || len(tmpOrderIDs) < batchSize {
|
||||||
err = nil
|
err = nil
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
seqStart = seqEnd + 1
|
seqStart = seqEnd + 1
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
retVal = orderIDs
|
retVal = orderIDs
|
||||||
return retVal, nil
|
return retVal, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user