Browse Source

优化统计订单成本利润

peng 1 year ago
parent
commit
b8c3af682f
1 changed files with 10 additions and 2 deletions
  1. 10 2
      Controller/Cron/CronTaskController.py

+ 10 - 2
Controller/Cron/CronTaskController.py

@@ -1110,9 +1110,17 @@ class CronCollectDataView(View):
     @staticmethod
     def thread_collect_operating_costs(start_time_stamp, end_time_stamp, start_time, end_time):
         try:
-            operating_costs_qs = OperatingCosts.objects.filter(time=start_time_stamp).values('order_id', 'end_time',
-                                                                                             'uid')
             create_time = int(time.time())
+            today_end_time = end_time_stamp + 86400
+            operating_costs_qs_1 = OperatingCosts.objects.filter(time=start_time_stamp).exclude(
+                created_time__gte=end_time_stamp, created_time__lt=today_end_time).values('order_id', 'end_time',
+                                                                                          'uid')
+            operating_costs_qs_2 = OperatingCosts.objects.filter(time=start_time_stamp,
+                                                                 created_time__gte=end_time_stamp,
+                                                                 created_time__lt=today_end_time, start_time=0).values(
+                'order_id', 'end_time',
+                'uid')
+            operating_costs_qs = operating_costs_qs_1.union(operating_costs_qs_2)
             storage_univalence = 0.023 / 30
             api_univalence = 0.005 / 1000
             region = '国内' if CONFIG_INFO == CONFIG_CN else '国外'