This commit is contained in:
gazebo
2019-01-12 10:29:58 +08:00
parent bfb0b139fa
commit fc34194835
2 changed files with 22 additions and 8 deletions

View File

@@ -93,11 +93,23 @@ func (a *API) GetStoreOrderInfo(orderId string) (storeOrderInfo map[string]inter
}
func (a *API) GetStoreOrderInfoList(fromTime, toTime string) (storeOrderList []map[string]interface{}, err error) {
retVal, err := a.AccessStorePage(fmt.Sprintf("order/newManager/tabQuery/all?o2oOrderType=10000&pageNo=1&pageSize=9999&orderBy=&desc=true&startTimeQuery=%s&endTimeQuery=%s&stationNo=", url.QueryEscape(fromTime), url.QueryEscape(toTime)))
// baseapi.SugarLogger.Debug(utils.Format4Output(retVal, false))
if err == nil {
resultList := retVal["result"].(map[string]interface{})["newOrderinfoMains"].(map[string]interface{})["resultList"].([]interface{})
return utils.Slice2MapSlice(resultList), nil
pageSize := 100
pageNo := 1
urlTemplate := "order/newManager/tabQuery/all?o2oOrderType=10000&pageNo=%d&pageSize=%d&orderBy=&desc=true&startTimeQuery=%s&endTimeQuery=%s&stationNo="
for {
retVal, err := a.AccessStorePage(fmt.Sprintf(urlTemplate, pageNo, pageSize, url.QueryEscape(fromTime), url.QueryEscape(toTime)))
// baseapi.SugarLogger.Debug(utils.Format4Output(retVal, false))
if err == nil {
newOrderinfoMains := retVal["result"].(map[string]interface{})["newOrderinfoMains"].(map[string]interface{})
resultList := newOrderinfoMains["resultList"].([]interface{})
storeOrderList = append(storeOrderList, utils.Slice2MapSlice(resultList)...)
if len(storeOrderList) >= int(utils.MustInterface2Int64(newOrderinfoMains["totalCount"])) {
return storeOrderList, nil
}
pageNo++
} else {
return nil, err
}
}
return nil, err
}

View File

@@ -21,7 +21,7 @@ func TestGetRealMobileNumber4Order(t *testing.T) {
}
func TestGetStoreOrderInfo(t *testing.T) {
orderId := "820995196000122"
orderId := "826309564000021"
// desiredMobile := "18569035610"
orderInfo, err := jdapi.GetStoreOrderInfo(orderId)
if err != nil {
@@ -31,9 +31,11 @@ func TestGetStoreOrderInfo(t *testing.T) {
}
func TestGetStoreOrderInfoList(t *testing.T) {
orderInfoList, err := jdapi.GetStoreOrderInfoList("2018-10-01 00:00:00", "2018-10-01 00:59:59")
orderInfoList, err := jdapi.GetStoreOrderInfoList("2018-05-01 12:00:00", "2018-05-01 12:59:59")
if err != nil {
t.Fatal(err)
}
baseapi.SugarLogger.Debug(utils.Format4Output(orderInfoList, false))
if true {
baseapi.SugarLogger.Debug(utils.Format4Output(orderInfoList, false))
}
}