ck 4 년 전
부모
커밋
63e8583502
4개의 변경된 파일18개의 추가작업 그리고 23개의 파일을 삭제
  1. 6 11
      data_manage/pitcher_panel.py
  2. 2 2
      handlers/HandlerBase.py
  3. 8 8
      handlers/PitcherPanelHandler.py
  4. 2 2
      model/CommonUtils.py

+ 6 - 11
data_manage/pitcher_panel.py

@@ -140,10 +140,7 @@ def get_channel_overview(channel,pitcher,start,end,page,page_size,order_by,order
        round(if(first_order_user=0,0,cost/first_order_user),2) first_cost_per_user,
        round(if(follow_user=0,0,first_order_user/follow_user),4) new_user_order_rate,
        reg_order_amount,
---        total_cost,
---        total_amount,
        round(if(cost=0,0,first_order_amount/cost),4) day_roi,
---        round(if(total_cost=0,0,total_amount/total_cost),4) all_roi,
         round(order_amount/cost,4) roi,
        round(if(total_cost=0,0,total_first_amount/total_cost),4)  avg_new_order_rate,
        round(if(reg_order_user=0,0,reg_order_user_again/reg_order_user),4)  old_user_once_order_rate, 
@@ -707,16 +704,14 @@ from order where  dt>='{start}' {channel_op}  group by formatDateTime(reg_time,'
     count= len(data)
     if count==0:
         return [],0
-    di={'cost':round(cost,2),'reg_amount':round(reg_amount,2),'roi':round(reg_amount/cost,4), 'new_follow_user':new_follow_user,
+    total_data={'cost':round(cost,2),'reg_amount':round(reg_amount,2),'roi':round(reg_amount/cost,4), 'new_follow_user':new_follow_user,
         'new_follow_per_cost':round(new_follow_per_cost/count,2),'order_user':order_user,'order_count':order_count,
         'order_user_per_cost':round(order_user_per_cost/count,2),'channel':'-','date':'总计','book':'-'
         }
-    data.reverse()
-    data.append(di)
-    data.reverse()
-    # print(data)
 
-    return data,total
+
+
+    return data,total,total_data
 
 def get_channel_summary(channel,pitcher,page,page_size,order_by,order,state,location,start,end):
     db=MysqlUtils()
@@ -835,7 +830,7 @@ def get_pitcher_trend(pitcher,start=None,end=None,page=None,page_size=None,order
     from ({sql}) a
     """
 
-    data,total=getLimitSumData(db.quchen_text,sql,sumSql,page,page_size)
+    data,total,total_data=getLimitSumData(db.quchen_text,sql,sumSql,page,page_size)
     print(data)
     def parse(str):
         li=str.split(',')
@@ -850,7 +845,7 @@ def get_pitcher_trend(pitcher,start=None,end=None,page=None,page_size=None,order
          'd11','d12','d13','d14','d15','d16','d17','d18','d19','d20','d21','d22','d23','d24','d25','d26','d27','d28','d29','d30']:
                 i[k]= parse(v) if i["cost"]!=0 else {}
 
-    return data,total
+    return data,total,total_data
 
 
 if __name__ == '__main__':

+ 2 - 2
handlers/HandlerBase.py

@@ -34,8 +34,8 @@ class BaseHandler(RequestHandler,DateUtils):
         self.set_header("Access-Control-Allow-Origin","*")
 
 
-    def write_json(self, data, status_code=200, msg='success',total=1):
-        self.write(json.dumps({'status': {'msg': msg, "RetCode": status_code},'total':total,'data': data}))
+    def write_json(self, data, status_code=200, msg='success',total=1,total_data={}):
+        self.write(json.dumps({'status': {'msg': msg, "RetCode": status_code},'total':total,'data': data,"total_data":total_data}))
 
 
 

+ 8 - 8
handlers/PitcherPanelHandler.py

@@ -39,8 +39,8 @@ class PitcherPanelDaily(BaseHandler):
             end = self.get_n_days(0)
             start = self.get_n_days(-int(args['date_range'])+1)
 
-        data,total = get_pitcher_panel_daily(pitcher, start, end, page, page_size, order_by, order)
-        self.write_json(data=data,total=total)
+        data,total,total_data = get_pitcher_panel_daily(pitcher, start, end, page, page_size, order_by, order)
+        self.write_json(data=data,total=total,total_data=total_data)
 
 
 class PitcherPanelOverview(BaseHandler):
@@ -116,8 +116,8 @@ class ChannelOrderTrend(BaseHandler):
         if 'date_range' in list(arg.keys()):
             end = self.get_n_days(0)
             start = self.get_n_days(-int(arg['date_range'])+1)
-        data,total=get_channel_order_trend(channel,pitcher,start,end,page,page_size,order_by,order)
-        self.write_json(data=data,total=total)
+        data,total,total_data=get_channel_order_trend(channel,pitcher,start,end,page,page_size,order_by,order)
+        self.write_json(data=data,total=total,total_data=total_data)
 
 
 class ChannelSummary(BaseHandler):
@@ -134,8 +134,8 @@ class ChannelSummary(BaseHandler):
         state=arg.get("state")
         start=arg.get("start")
         end=arg.get("end")
-        data,total=get_channel_summary(channel,pitcher,page,page_size,order_by,order,state,location,start,end)
-        self.write_json(data=data,total=total)
+        data,total,total_data=get_channel_summary(channel,pitcher,page,page_size,order_by,order,state,location,start,end)
+        self.write_json(data=data,total=total,total_data=total_data)
 
 
 class PitcherTrend(BaseHandler):
@@ -153,8 +153,8 @@ class PitcherTrend(BaseHandler):
         if date_range:
             start=du.get_n_days(0)
             end=du.get_n_days(-int(date_range)+1)
-        data,total=get_pitcher_trend(pitcher,start,end,page,page_size,order_by,order)
-        self.write_json(data=data,total=total)
+        data,total,total_data=get_pitcher_trend(pitcher,start,end,page,page_size,order_by,order)
+        self.write_json(data=data,total=total,total_data=total_data)
 
 
 

+ 2 - 2
model/CommonUtils.py

@@ -41,8 +41,8 @@ def getLimitData(DataBase,sql,page,page_size):
 
 def getLimitSumData(DataBase,sql,sumSql,page,page_size):
     data,total= getLimitData(DataBase,sql,page,page_size)
-    di =DataBase.getData_json(sumSql)
-    return di+data,total
+    di =DataBase.getData_json(sumSql)[0]
+    return data,total,di