Просмотр исходного кода

集团推荐人数统计规则修改

时间区间生成规则修改

Signed-off-by: binren <zhangbr@elab-plus.com>
binren 4 лет назад
Родитель
Сommit
885e662a7b
2 измененных файлов с 14 добавлено и 12 удалено
  1. 1 1
      jianye_report.py
  2. 13 11
      report_public_funs_utils.py

+ 1 - 1
jianye_report.py

@@ -157,7 +157,7 @@ class JianYeReport(object):
         number_2 = 0
         for x in self.get_recommend_data(time_range):
             if str(x[0]) == str(self.brand_id):
-                number_2 = x[1]
+                number_2 += x[1]
         data_2.append(number_2)
         data_3 = []
         sql_data_3 = self.db.select(Sql.sql_10, [time_range[0], time_range[1]])

+ 13 - 11
report_public_funs_utils.py

@@ -15,27 +15,29 @@ class ReportPublicFunsUtils:
         month = str(month) if month > 9 else '0' + str(month)
         first_day_of_month = str(year) + '-' + month
         if type:
-            return [first_day_of_month + '-01 00:00:00', now_time.strftime('%Y-%m-%d %M:%I:%S')]
+            return [first_day_of_month + '-01 00:00:00', ReportPublicFunsUtils.before_day().strftime('%Y-%m-%d %M:%I:%S')]
         else:
-            return [first_day_of_month + '-01', now_time.strftime('%Y-%m-%d')]
+            return [first_day_of_month + '-01', ReportPublicFunsUtils.before_day().strftime('%Y-%m-%d')]
 
     @staticmethod
-    def get_prd_day(type=None):
+    def before_day():
         now_time = datetime.datetime.now()
         pre_time = now_time + datetime.timedelta(days=-1)
-        now_time = now_time + datetime.timedelta(days=-1)
+        return pre_time
+
+    @staticmethod
+    def get_prd_day(type=None):
         if type:
-            return [pre_time.strftime('%Y-%m-%d %M:%I:%S'), now_time.strftime('%Y-%m-%d %M:%I:%S')]
+            return [ReportPublicFunsUtils.before_day().strftime('%Y-%m-%d %M:%I:%S'), ReportPublicFunsUtils.before_day().strftime('%Y-%m-%d %M:%I:%S')]
         else:
-            return [pre_time.strftime('%Y-%m-%d'), now_time.strftime('%Y-%m-%d')]
+            return [ReportPublicFunsUtils.before_day().strftime('%Y-%m-%d'), ReportPublicFunsUtils.before_day().strftime('%Y-%m-%d')]
 
     @staticmethod
     def get_all_time_data_range(type=None):
-        now_time = datetime.datetime.now()
-        if not type:
-            return ['2020-02-18 00:00:00', now_time.strftime('%Y-%m-%d %M:%I:%S')]
+        if type:
+            return ['2020-02-18 00:00:00', ReportPublicFunsUtils.before_day().strftime('%Y-%m-%d %M:%I:%S')]
         else:
-            return ['2020-02-18', now_time.strftime('%Y-%m-%d')]
+            return ['2020-02-18', ReportPublicFunsUtils.before_day().strftime('%Y-%m-%d')]
 
     @staticmethod
     def get_montho_day():
@@ -72,4 +74,4 @@ class ReportPublicFunsUtils:
 
 
 if __name__ == '__main__':
-    print(ReportPublicFunsUtils.get_month())
+    print(ReportPublicFunsUtils.get_prd_day())