|
@@ -0,0 +1,124 @@
|
|
|
|
+# Author renyupeng
|
|
|
|
+# coding=utf-8
|
|
|
|
+# @Time : 2024/1/4 上午9:55
|
|
|
|
+# @Site :
|
|
|
|
+# @File : PromoterOrderList.py
|
|
|
|
+# @Software: PyCharm
|
|
|
|
+# @contact: renyupeng@c-top.com.cn
|
|
|
|
+# @Tel 1501435553
|
|
|
|
+import json
|
|
|
|
+import time
|
|
|
|
+from datetime import datetime, timedelta
|
|
|
|
+from math import ceil
|
|
|
|
+import requests
|
|
|
|
+
|
|
|
|
+from utils.mysql_helper import batch_insertPro
|
|
|
|
+from utils.mysql_utils_pro import MysqlProUtils
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+class PromoterOrderList:
|
|
|
|
+ conn = MysqlProUtils()
|
|
|
|
+
|
|
|
|
+ @staticmethod
|
|
|
|
+ def HandlerRequest(startDate, endDate, cookie, name):
|
|
|
|
+ url = "https://cps.kwaixiaodian.com/distribute/pc/promoter/order/list?offset=0&limit=1&startTime={startDate}&endTime={endDate}&cpsType=0&status=0&searchDelivered=0".format(
|
|
|
|
+ startDate=startDate, endDate=endDate)
|
|
|
|
+
|
|
|
|
+ payload = {}
|
|
|
|
+ headers = {
|
|
|
|
+ 'Cookie': cookie,
|
|
|
|
+ 'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
|
|
|
|
+ 'Accept': '*/*',
|
|
|
|
+ 'Host': 'cps.kwaixiaodian.com',
|
|
|
|
+ 'Connection': 'keep-alive'
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ response = requests.request("GET", url, headers=headers, data=payload)
|
|
|
|
+ data = json.loads(response.text)["data"]
|
|
|
|
+ total_num = data["total"]
|
|
|
|
+ page = ceil(total_num / 200)
|
|
|
|
+ for i in range(page):
|
|
|
|
+ if i != 0:
|
|
|
|
+ url = "https://cps.kwaixiaodian.com/distribute/pc/promoter/order/list?offset={offset}&limit={total_num}&startTime={startDate}&endTime={endDate}&cpsType=0&status=0&searchDelivered=0".format(
|
|
|
|
+ startDate=startDate, endDate=endDate, total_num=20 * i, offset=20 * (i - 1))
|
|
|
|
+ response = requests.request("GET", url, headers=headers, data=payload)
|
|
|
|
+ print(json.loads(response.text))
|
|
|
|
+ if json.loads(response.text)["result"] != 1:
|
|
|
|
+ return
|
|
|
|
+ else:
|
|
|
|
+ total_list = json.loads(response.text)["data"]["list"]
|
|
|
|
+ dataInfoList = []
|
|
|
|
+ try:
|
|
|
|
+ for dataInfo in total_list:
|
|
|
|
+ oid = dataInfo["oid"]
|
|
|
|
+ order_status = dataInfo["status"]
|
|
|
|
+ order_create_time = dataInfo["orderCreateTime"]
|
|
|
|
+ send_status = dataInfo["sendStatus"]
|
|
|
|
+ settlement_biz_type = dataInfo["settlementBizType"]
|
|
|
|
+ settlement_biz_type_desc = dataInfo["settlementBizTypeDesc"]
|
|
|
|
+ send_time = dataInfo["sendTime"]
|
|
|
|
+ recv_time = dataInfo["recvTime"]
|
|
|
|
+ order_amount = dataInfo["orderTradeAmount"]
|
|
|
|
+ regimental_promotion_rate = None
|
|
|
|
+ share_rate = dataInfo["shareRate"]
|
|
|
|
+ base_amount = dataInfo["baseAmount"]
|
|
|
|
+ for item in dataInfo["cpsOrderProductViewList"]:
|
|
|
|
+ item_id = item["itemId"]
|
|
|
|
+ item_title = item["itemTitle"]
|
|
|
|
+ reserve_price = None
|
|
|
|
+ image_url = item["itemPicUrl"]
|
|
|
|
+ seller_id = item["sellerId"]
|
|
|
|
+ promotion_id = None
|
|
|
|
+ promotion_nick_name = None
|
|
|
|
+ clip_user_id = item["distributorId"]
|
|
|
|
+ clip_nick_name = name
|
|
|
|
+ activity_id = None
|
|
|
|
+ pay_amount = item["paymentFee"]
|
|
|
|
+ service_amount = item["serviceAmount"]
|
|
|
|
+ commission_rate = item["commissionRate"]
|
|
|
|
+ regimental_promotion_amount = None
|
|
|
|
+ total_regimental_settle_amount = None
|
|
|
|
+ mcn_promotion_amount = item["estimatedIncome"]
|
|
|
|
+ mcn_settlement_amount = item["finalEstimatedIncome"]
|
|
|
|
+ stat_date = datetime.fromtimestamp(order_create_time / 1000).strftime("%Y%m%d")
|
|
|
|
+ stat_hour = datetime.fromtimestamp(order_create_time / 1000).strftime("%H")
|
|
|
|
+ account_type = 2
|
|
|
|
+ dataItem = {
|
|
|
|
+ "oid": oid,
|
|
|
|
+ "order_status": order_status,
|
|
|
|
+ "order_create_time": order_create_time,
|
|
|
|
+ "send_status": send_status,
|
|
|
|
+ "settlement_biz_type": settlement_biz_type,
|
|
|
|
+ "settlement_biz_type_desc": settlement_biz_type_desc,
|
|
|
|
+ "send_time": send_time,
|
|
|
|
+ "recv_time": recv_time,
|
|
|
|
+ "order_amount": order_amount,
|
|
|
|
+ "regimental_promotion_rate": regimental_promotion_rate,
|
|
|
|
+ "share_rate": share_rate,
|
|
|
|
+ "base_amount": base_amount,
|
|
|
|
+ "item_id": item_id,
|
|
|
|
+ "item_title": item_title,
|
|
|
|
+ "reserve_price": reserve_price,
|
|
|
|
+ "image_url": image_url,
|
|
|
|
+ "seller_id": seller_id,
|
|
|
|
+ "promotion_id": promotion_id,
|
|
|
|
+ "promotion_nick_name": promotion_nick_name,
|
|
|
|
+ "clip_user_id": clip_user_id,
|
|
|
|
+ "clip_nick_name": clip_nick_name,
|
|
|
|
+ "activity_id": activity_id,
|
|
|
|
+ "pay_amount": pay_amount,
|
|
|
|
+ "service_amount": service_amount,
|
|
|
|
+ "commission_rate": commission_rate,
|
|
|
|
+ "regimental_promotion_amount": regimental_promotion_amount,
|
|
|
|
+ "total_regimental_settle_amount": total_regimental_settle_amount,
|
|
|
|
+ "mcn_promotion_amount": mcn_promotion_amount,
|
|
|
|
+ "mcn_settlement_amount": mcn_settlement_amount,
|
|
|
|
+ "stat_date": stat_date,
|
|
|
|
+ "stat_hour": stat_hour,
|
|
|
|
+ "account_type": account_type
|
|
|
|
+ }
|
|
|
|
+ dataInfoList.append(dataItem)
|
|
|
|
+ batch_insertPro(item_list=dataInfoList, table_name='jy_order_list')
|
|
|
|
+ time.sleep(3)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(e)
|