Browse Source

订单拉取优化

ck 4 năm trước cách đây
mục cha
commit
f2f47a6d56

+ 1 - 1
dgp/tests/get_order_hourly.py

@@ -40,7 +40,7 @@ def zd(st,et):
 def run():
     print(date_util.getCurrentFormatTimeStr())
 
-    st = date_util.get_n_day(n=0, is_timestamp=1)
+    st = date_util.getTodayOrYestoday()
     et = date_util.getPreviousHourAndCurrentHourSecondTime()[1]
 
     if sys.argv.__len__() > 1:

+ 17 - 1
dgp/tests/util/date_util.py

@@ -33,6 +33,8 @@ from dateutil.relativedelta import relativedelta
 # ========== time ==========
 # ==========================
 
+
+
 def getDateLists(begin, end):
     """
     返回一个时间列表
@@ -399,8 +401,22 @@ def stamp_to_str(stamp):
     return time.strftime("%Y-%m-%d %H:%M:%S", a)
 
 
+def getTodayOrYestoday():
+    """
+    如果当天零点 则返回昨天
+    否则返回今天
+    :return:
+    """
+    if datetime.datetime.today().hour == 0:
+        return get_n_day(-1,is_timestamp=1)
+    else:
+        return get_n_day(0,is_timestamp=1)
+
+
 if __name__ == '__main__':
     # print(test())
+    # print(datetime.datetime.today().hour)
+    print(getTodayOrYestoday())
 
     # print(getTodayEnd('2020-01-01'))
-    print(stamp_to_str(get_n_day(is_timestamp=1)))
+    # print(stamp_to_str(get_n_day(is_timestamp=1)))

+ 2 - 0
dgp/tests/util/platform_order_api_util.py

@@ -314,6 +314,7 @@ def get_huasheng_order(st, et, account_list):
         }
         response_result_json = requests.post(url, params).json()
 
+
         if 'data' not in response_result_json.keys():
             print('花生账号【{apiKey}】本次请求数据异常,响应报文【{result}】'.format(apiKey=apiKey, result=response_result_json))
             continue
@@ -403,6 +404,7 @@ def get_huasheng_order_task(st, et, account, merchant):
             page = page + 1
 
         start_time = start_time + 86400  # 天数加1
+    print(f"{merchant_name}: {len(order_list)}")
 
     return order_list