|
@@ -21,6 +21,7 @@ from retry import retry
|
|
import requests
|
|
import requests
|
|
from urllib import request
|
|
from urllib import request
|
|
import json
|
|
import json
|
|
|
|
+from clickhouse_connect import get_client
|
|
|
|
|
|
try:
|
|
try:
|
|
from ..settings import MYSQL_AUTH_CONF, MYSQL_DATA_CONF
|
|
from ..settings import MYSQL_AUTH_CONF, MYSQL_DATA_CONF
|
|
@@ -161,11 +162,15 @@ class SpApiRequest:
|
|
df = pd.read_table(rp_table.payload.get("url"),encoding='Shift-JIS')
|
|
df = pd.read_table(rp_table.payload.get("url"),encoding='Shift-JIS')
|
|
return df
|
|
return df
|
|
elif reportId_info.payload.get("processingStatus") in [ProcessingStatus.CANCELLED,ProcessingStatus.FATAL]:
|
|
elif reportId_info.payload.get("processingStatus") in [ProcessingStatus.CANCELLED,ProcessingStatus.FATAL]:
|
|
- print(reportId_info)
|
|
|
|
- reportDocumentId = reportId_info.payload.get("reportDocumentId")
|
|
|
|
- rp_table = report.get_report_document(reportDocumentId=reportDocumentId, download=True)
|
|
|
|
- print("取消或失败",rp_table)
|
|
|
|
- return pd.DataFrame()
|
|
|
|
|
|
+ try:
|
|
|
|
+ print(reportId_info)
|
|
|
|
+ reportDocumentId = reportId_info.payload.get("reportDocumentId")
|
|
|
|
+ rp_table = report.get_report_document(reportDocumentId=reportDocumentId, download=True)
|
|
|
|
+ print("取消或失败",rp_table)
|
|
|
|
+ return pd.DataFrame()
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(e)
|
|
|
|
+ return pd.DataFrame()
|
|
time.sleep(15)
|
|
time.sleep(15)
|
|
print("please wait...")
|
|
print("please wait...")
|
|
|
|
|
|
@@ -671,15 +676,15 @@ class SpApiRequest:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- def GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE(self,seller_id,days=-2): # not be used,退货报告,空数据
|
|
|
|
- shopReportday = (datetime.now() + timedelta(days=days)).strftime("%Y-%m-%d")
|
|
|
|
- # print(shopReportday)
|
|
|
|
- para = {"reportType": ReportType.GET_SELLER_FEEDBACK_DATA,
|
|
|
|
- "dataStartTime": shopReportday, "dataEndTime": shopReportday,
|
|
|
|
- }
|
|
|
|
- reportid = self.create_report(**para) # {"ShowSalesChannel":"true"}
|
|
|
|
- decom_df = self.decompression(reportid)
|
|
|
|
- print(decom_df)
|
|
|
|
|
|
+ # def GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE(self,seller_id,days=-2): # not be used,退货报告,空数据
|
|
|
|
+ # shopReportday = (datetime.now() + timedelta(days=days)).strftime("%Y-%m-%d")
|
|
|
|
+ # # print(shopReportday)
|
|
|
|
+ # para = {"reportType": ReportType.GET_SELLER_FEEDBACK_DATA,
|
|
|
|
+ # "dataStartTime": shopReportday, "dataEndTime": shopReportday,
|
|
|
|
+ # }
|
|
|
|
+ # reportid = self.create_report(**para) # {"ShowSalesChannel":"true"}
|
|
|
|
+ # decom_df = self.decompression(reportid)
|
|
|
|
+ # print(decom_df)
|
|
# print(decom_df.columns)
|
|
# print(decom_df.columns)
|
|
|
|
|
|
|
|
|
|
@@ -1230,45 +1235,205 @@ class SpApiRequest:
|
|
def BRAND_ANALYTICS_TEXT_deal(self,text):
|
|
def BRAND_ANALYTICS_TEXT_deal(self,text):
|
|
pass
|
|
pass
|
|
|
|
|
|
- def GET_SELLER_FEEDBACK_DATA(self,**kwargs):
|
|
|
|
- shopReportday = "2024-11-04"
|
|
|
|
- shopReportday_E = "2024-11-04"
|
|
|
|
|
|
+ def GET_SELLER_FEEDBACK_DATA(self,refresh_token,seller_id,days,**a_kw):
|
|
|
|
+ kwargs = a_kw
|
|
|
|
+ country_code = str(self.marketplace)[-2:]
|
|
|
|
+ if country_code == 'GB':
|
|
|
|
+ country_code = "UK"
|
|
|
|
+ insert_time = datetime.now()
|
|
|
|
+ shopReportday = (datetime.now().date() + timedelta(days=days)).strftime("%Y-%m-%d")
|
|
|
|
+ shopReportday_E = (datetime.now().date() + timedelta(days=days)).strftime("%Y-%m-%d")
|
|
print(shopReportday)
|
|
print(shopReportday)
|
|
- para = {"reportType": ReportType.GET_SELLER_FEEDBACK_DATA,# GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE |GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA
|
|
|
|
|
|
+ para = {"reportType": ReportType.GET_SELLER_FEEDBACK_DATA,#GET_SELLER_FEEDBACK_DATA,# GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE |GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA
|
|
"dataStartTime": shopReportday,
|
|
"dataStartTime": shopReportday,
|
|
"dataEndTime": shopReportday_E, "reportOptions":{"reportPeriod": "DAY"}}
|
|
"dataEndTime": shopReportday_E, "reportOptions":{"reportPeriod": "DAY"}}
|
|
- reportid = self.create_report(**para)
|
|
|
|
- print(reportid)
|
|
|
|
|
|
+ try:
|
|
|
|
+ reportid = self.create_report(**para)
|
|
|
|
+ decom_df = self.decompression(reportid)
|
|
|
|
+ except:
|
|
|
|
+ return pd.DataFrame()
|
|
|
|
+ if len(decom_df) == 0:
|
|
|
|
+ return reportid
|
|
|
|
+ decom_df[decom_df.select_dtypes(float).columns] = decom_df[decom_df.select_dtypes(float).columns].applymap(
|
|
|
|
+ lambda x: str(x) if not pd.isna(x) else '')
|
|
|
|
+ decom_df[decom_df.select_dtypes(int).columns] = decom_df[decom_df.select_dtypes(int).columns].applymap(
|
|
|
|
+ lambda x: str(x) if not pd.isna(x) else '')
|
|
|
|
+ decom_df[decom_df.select_dtypes(datetime).columns] = decom_df[
|
|
|
|
+ decom_df.select_dtypes(datetime).columns].applymap(lambda x: str(x) if not pd.isna(x) else '')
|
|
|
|
+ decom_df.fillna('', inplace=True)
|
|
|
|
+ # decom_df.to_csv('order.csv')
|
|
|
|
+ decom_df["ReportDate"] = parse(shopReportday)
|
|
|
|
+ # decom_df['timezone'] = decom_df["purchase-date"].map(lambda x: parse(x).tzname()).fillna(method='bfill')
|
|
|
|
+ decom_df['timezone'] = "UTC"
|
|
|
|
+ # print("==========================================================")
|
|
|
|
+ decom_df['seller_id'] = seller_id
|
|
|
|
+ decom_df['country_code'] = country_code
|
|
|
|
+ decom_df['insert_time'] = datetime.now()
|
|
|
|
+ df_feedback = decom_df.copy()
|
|
|
|
+ df_feedback[["date", "rating", "comment", "order_id"]] = df_feedback[["Date", "Rating", "Comments", "Order ID"]]
|
|
|
|
+ df_feedback['isFeedback'] = 1
|
|
|
|
+
|
|
|
|
+ df_feedback['date'] = df_feedback['date'].map(lambda x: pd.to_datetime(x).date())
|
|
|
|
+ df_feedback['seller_id'] = seller_id
|
|
|
|
+ df_feedback['country_code'] = country_code
|
|
|
|
+ client = get_client(host='3.93.43.158', port=8123, username='root',
|
|
|
|
+ password='6f0eyLuiVn3slzbGWpzI')
|
|
|
|
+ try:
|
|
|
|
+ client.insert_df(table='ams.performance', df=df_feedback[
|
|
|
|
+ ["date", "rating", "comment", "order_id", "isFeedback", 'seller_id', 'country_code','insert_time']],
|
|
|
|
+ column_names=["date", "rating", "comment", "order_id", "isFeedback", 'seller_id',
|
|
|
|
+ 'country_code','insert_time'])
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(e)
|
|
|
|
+ client.close()
|
|
|
|
+ # print(decom_df.columns)
|
|
|
|
+ # print(decom_df)
|
|
return reportid
|
|
return reportid
|
|
-
|
|
|
|
- def GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENTS_DATA(self,**kwargs):
|
|
|
|
- shopReportday = "2024-11-04"
|
|
|
|
- shopReportday_E = "2024-11-04"
|
|
|
|
- print(shopReportday)
|
|
|
|
- para = {"reportType": ReportType.GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA,
|
|
|
|
- # GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE |GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA
|
|
|
|
- "dataStartTime": shopReportday,
|
|
|
|
- "dataEndTime": shopReportday_E, "reportOptions": {"reportPeriod": "DAY"}}
|
|
|
|
- reportid = self.create_report(**para)
|
|
|
|
- print(reportid)
|
|
|
|
|
|
+ def GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA(self,refresh_token,seller_id,days,**a_kw):
|
|
|
|
+ kwargs = a_kw
|
|
|
|
+ country_code = str(self.marketplace)[-2:]
|
|
|
|
+ if country_code == 'GB':
|
|
|
|
+ country_code = "UK"
|
|
|
|
+ insert_time = datetime.now()
|
|
|
|
+ shopReportday = (datetime.now().date() + timedelta(days=days)).strftime("%Y-%m-%d")
|
|
|
|
+ shopReportday_E = (datetime.now().date() + timedelta(days=days)).strftime("%Y-%m-%d")
|
|
|
|
+ # print(shopReportday)
|
|
|
|
+ # print("1"*50)
|
|
|
|
+ para = {"reportType": ReportType.GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA,#GET_SELLER_FEEDBACK_DATA,# GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE |GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA
|
|
|
|
+ "dataStartTime": shopReportday,
|
|
|
|
+ "dataEndTime": shopReportday_E, "reportOptions":{"reportPeriod": "DAY"}}
|
|
|
|
+ try:
|
|
|
|
+ reportid = self.create_report(**para)
|
|
|
|
+ decom_df = self.decompression(reportid)
|
|
|
|
+ except:
|
|
|
|
+ return pd.DataFrame()
|
|
|
|
+ if len(decom_df) == 0:
|
|
|
|
+ return reportid
|
|
|
|
+ # print("2"*100)
|
|
|
|
+ decom_df[decom_df.select_dtypes(float).columns] = decom_df[decom_df.select_dtypes(float).columns].applymap(
|
|
|
|
+ lambda x: str(x) if not pd.isna(x) else '')
|
|
|
|
+ decom_df[decom_df.select_dtypes(int).columns] = decom_df[decom_df.select_dtypes(int).columns].applymap(
|
|
|
|
+ lambda x: str(x) if not pd.isna(x) else '')
|
|
|
|
+ decom_df[decom_df.select_dtypes(datetime).columns] = decom_df[
|
|
|
|
+ decom_df.select_dtypes(datetime).columns].applymap(lambda x: str(x) if not pd.isna(x) else '')
|
|
|
|
+ decom_df.fillna('', inplace=True)
|
|
|
|
+ # decom_df.to_csv('order.csv')
|
|
|
|
+ decom_df["ReportDate"] = parse(shopReportday)
|
|
|
|
+ # decom_df['timezone'] = decom_df["purchase-date"].map(lambda x: parse(x).tzname()).fillna(method='bfill')
|
|
|
|
+ decom_df['timezone'] = "UTC"
|
|
|
|
+ print("==========================================================")
|
|
|
|
+ decom_df['seller_id'] = seller_id
|
|
|
|
+ decom_df['country_code'] = country_code
|
|
|
|
+ decom_df['insert_time'] = datetime.now()
|
|
|
|
+ df_fbaR = decom_df.copy()
|
|
|
|
+ df_fbaR[['date', 'order_id', 'product_name', 'detailed_disposition', 'comment']] = df_fbaR[
|
|
|
|
+ ['return-date', 'order-id', 'product-name', 'detailed-disposition', 'customer-comments']]
|
|
|
|
+ # df_fbaR[['return-date','order-id','sku','asin','fnsku','product-name','quantity','reason','detailed-disposition','customer-comments']]
|
|
|
|
+ df_fbaR['isFeedback'] = 0
|
|
|
|
+ df_fbaR['date'] = df_fbaR['date'].map(lambda x: pd.to_datetime(x).date())
|
|
|
|
+ df_fbaR['comment'].fillna("", inplace=True)
|
|
|
|
+ # df_fbaR[['order_id','sku','asin','fnsku','detailed_disposition','product_name','isFeedback','date']]
|
|
|
|
+
|
|
|
|
+ client = get_client(host='3.93.43.158', port=8123, username='root',
|
|
|
|
+ password='6f0eyLuiVn3slzbGWpzI')
|
|
|
|
+ try:
|
|
|
|
+ client.insert_df(table='ams.performance', df=df_fbaR[
|
|
|
|
+ ['order_id', 'sku', 'asin', 'fnsku', 'detailed_disposition', 'product_name', 'isFeedback', 'date',
|
|
|
|
+ 'comment', 'seller_id', 'country_code','insert_time']],
|
|
|
|
+ column_names=['order_id', 'sku', 'asin', 'fnsku', 'detailed_disposition', 'product_name',
|
|
|
|
+ 'isFeedback', 'date', 'comment', 'seller_id', 'country_code','insert_time'])
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(e)
|
|
|
|
+ client.close()
|
|
|
|
+ # print(decom_df.columns)
|
|
|
|
+ # print(decom_df)
|
|
return reportid
|
|
return reportid
|
|
|
|
|
|
- def GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE(self, refresh_token,seller_id,days=-1,**kwargs):
|
|
|
|
- countryCode = None if kwargs.get("countryCode") == None else kwargs.get("countryCode")
|
|
|
|
- shopReportday = (datetime.now() + timedelta(days=days)).strftime("%Y-%m-%d")
|
|
|
|
- print(shopReportday)
|
|
|
|
- para = {"reportType": ReportType.GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL,
|
|
|
|
- "dataStartTime": shopReportday, "dataEndTime": shopReportday,
|
|
|
|
- "reportOptions": {"ShowSalesChannel": "true"}}
|
|
|
|
- reportid = self.create_report(**para) # {"ShowSalesChannel":"true"}
|
|
|
|
- decom_df = self.decompression(reportid)
|
|
|
|
- decom_df['seller_id'] = seller_id
|
|
|
|
|
|
+ def GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE(self, refresh_token, seller_id, days, **a_kw):
|
|
|
|
+ kwargs = a_kw
|
|
country_code = str(self.marketplace)[-2:]
|
|
country_code = str(self.marketplace)[-2:]
|
|
if country_code == 'GB':
|
|
if country_code == 'GB':
|
|
country_code = "UK"
|
|
country_code = "UK"
|
|
- # decom_df['country_code'] = "UK"
|
|
|
|
|
|
+ insert_time = datetime.now()
|
|
|
|
+ shopReportday = (datetime.now() + timedelta(days=days)).strftime("%Y-%m-%d")
|
|
|
|
+ shopReportday_E = (datetime.now() + timedelta(days=days)).strftime("%Y-%m-%d")
|
|
|
|
+
|
|
|
|
+ para = {"reportType": ReportType.GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE,
|
|
|
|
+ # GET_SELLER_FEEDBACK_DATA,# GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE |GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA
|
|
|
|
+ "dataStartTime": shopReportday,
|
|
|
|
+ "dataEndTime": shopReportday_E, "reportOptions": {"reportPeriod": "DAY"}}
|
|
|
|
+ try:
|
|
|
|
+ reportid = self.create_report(**para)
|
|
|
|
+ decom_df = self.decompression(reportid)
|
|
|
|
+ except:
|
|
|
|
+ return pd.DataFrame()
|
|
|
|
+ if len(decom_df) == 0:
|
|
|
|
+ return reportid
|
|
|
|
+ decom_df[decom_df.select_dtypes(float).columns] = decom_df[decom_df.select_dtypes(float).columns].applymap(lambda x: str(x) if not pd.isna(x) else '')
|
|
|
|
+ decom_df[decom_df.select_dtypes(int).columns] = decom_df[decom_df.select_dtypes(int).columns].applymap(lambda x: str(x) if not pd.isna(x) else '')
|
|
|
|
+ decom_df[decom_df.select_dtypes(datetime).columns] = decom_df[decom_df.select_dtypes(datetime).columns].applymap(lambda x: str(x) if not pd.isna(x) else '')
|
|
|
|
+ decom_df.fillna('', inplace=True)
|
|
|
|
+ # decom_df.to_csv('order.csv')
|
|
|
|
+ decom_df["ReportDate"] = parse(shopReportday)
|
|
|
|
+ # decom_df['timezone'] = decom_df["purchase-date"].map(lambda x: parse(x).tzname()).fillna(method='bfill')
|
|
|
|
+ decom_df['timezone'] = "UTC"
|
|
|
|
+
|
|
|
|
+ decom_df['seller_id'] = seller_id
|
|
decom_df['country_code'] = country_code
|
|
decom_df['country_code'] = country_code
|
|
decom_df['insert_time'] = datetime.now()
|
|
decom_df['insert_time'] = datetime.now()
|
|
|
|
+ client = get_client(host='3.93.43.158', port=8123, username='root',
|
|
|
|
+ password='6f0eyLuiVn3slzbGWpzI')
|
|
|
|
+
|
|
|
|
+ # print(decom_df.dtypes)
|
|
|
|
+ # print("======================-------------==================")
|
|
|
|
+ # decom_df['SafeT claim reimbursement amount'] = decom_df['SafeT claim reimbursement amount'].map(str)
|
|
|
|
+ # decom_df['Refunded Amount'] = decom_df['Refunded Amount'].map(str)
|
|
|
|
+ # decom_df['Label cost'] = decom_df['Label cost'].astype('string')
|
|
|
|
+ # print(decom_df.dtypes)
|
|
|
|
+
|
|
|
|
+ print("="*100)
|
|
|
|
+ try:
|
|
|
|
+ client.insert_df('ams.return_record',df=decom_df[['Order ID', 'Order date', 'Return request date',
|
|
|
|
+ 'Return request status', 'Amazon RMA ID', 'Merchant RMA ID',
|
|
|
|
+ 'Label type', 'Label cost', 'Currency code', 'Return carrier',
|
|
|
|
+ 'Tracking ID', 'Label to be paid by', 'A-to-Z Claim', 'Is prime',
|
|
|
|
+ 'ASIN', 'Merchant SKU', 'Item Name', 'Return quantity', 'Return Reason',
|
|
|
|
+ 'In policy', 'Return type', 'Resolution', 'Invoice number',
|
|
|
|
+ 'Return delivery date', 'Order Amount', 'Order quantity',
|
|
|
|
+ 'SafeT Action reason', 'SafeT claim id', 'SafeT claim state',
|
|
|
|
+ 'SafeT claim creation time', 'SafeT claim reimbursement amount',
|
|
|
|
+ 'Refunded Amount', 'ReportDate', 'timezone', 'seller_id',
|
|
|
|
+ 'country_code', 'insert_time']],column_names=['Order_ID', 'Order_date', 'Return_request_date','Return_request_status',
|
|
|
|
+ 'Amazon_RMA_ID', 'Merchant_RMA_ID','Label_type', 'Label_cost', 'Currency_code',
|
|
|
|
+ 'Return_carrier','Tracking_ID', 'Label_to_be_paid_by', 'A-to-Z_Claim', 'Is_prime',
|
|
|
|
+ 'ASIN', 'Merchant_SKU', 'Item_Name', 'Return_quantity', 'Return_Reason',
|
|
|
|
+ 'In_policy', 'Return_type', 'Resolution', 'Invoice_number','Return_delivery_date',
|
|
|
|
+ 'Order_Amount', 'Order_quantity','SafeT_Action_reason', 'SafeT_claim_id',
|
|
|
|
+ 'SafeT_claim_state','SafeT_claim_creation_time', 'SafeT_claim_reimbursement_amount',
|
|
|
|
+ 'Refunded_Amount', 'ReportDate', 'timezone', 'seller_id','country_code', 'insert_time'])
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(e)
|
|
|
|
+ client.close()
|
|
|
|
+ # print(decom_df.columns)
|
|
|
|
+ # print(decom_df)
|
|
|
|
+ return reportid
|
|
|
|
+
|
|
|
|
+ # def GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE(self, refresh_token,seller_id,days=-1,**kwargs):
|
|
|
|
+ # countryCode = None if kwargs.get("countryCode") == None else kwargs.get("countryCode")
|
|
|
|
+ # shopReportday = (datetime.now() + timedelta(days=days)).strftime("%Y-%m-%d")
|
|
|
|
+ # print(shopReportday)
|
|
|
|
+ # para = {"reportType": ReportType.GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL,
|
|
|
|
+ # "dataStartTime": shopReportday, "dataEndTime": shopReportday,
|
|
|
|
+ # "reportOptions": {"ShowSalesChannel": "true"}}
|
|
|
|
+ # reportid = self.create_report(**para) # {"ShowSalesChannel":"true"}
|
|
|
|
+ # decom_df = self.decompression(reportid)
|
|
|
|
+ # decom_df['seller_id'] = seller_id
|
|
|
|
+ # country_code = str(self.marketplace)[-2:]
|
|
|
|
+ # if country_code == 'GB':
|
|
|
|
+ # country_code = "UK"
|
|
|
|
+ # # decom_df['country_code'] = "UK"
|
|
|
|
+ # decom_df['country_code'] = country_code
|
|
|
|
+ # decom_df['insert_time'] = datetime.now()
|
|
# shopReportday = "2024-11-04"
|
|
# shopReportday = "2024-11-04"
|
|
# shopReportday_E = "2024-11-04"
|
|
# shopReportday_E = "2024-11-04"
|
|
# print(shopReportday)
|
|
# print(shopReportday)
|
|
@@ -1278,7 +1443,7 @@ class SpApiRequest:
|
|
# "dataEndTime": shopReportday_E, "reportOptions": {"reportPeriod": "DAY"}}
|
|
# "dataEndTime": shopReportday_E, "reportOptions": {"reportPeriod": "DAY"}}
|
|
# reportid = self.create_report(**para)
|
|
# reportid = self.create_report(**para)
|
|
# print(reportid)
|
|
# print(reportid)
|
|
- return reportid
|
|
|
|
|
|
+ # return reportid
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
def data_judge_secondTry(refresh_token,sp_api,data_type,seller_id,auth_conn,days=-1,**kwargs): # Main-retry, 重试函数,重试次数2次
|
|
def data_judge_secondTry(refresh_token,sp_api,data_type,seller_id,auth_conn,days=-1,**kwargs): # Main-retry, 重试函数,重试次数2次
|
|
@@ -1307,8 +1472,8 @@ class SpApiRequest:
|
|
# for day_ in range(31,1):
|
|
# for day_ in range(31,1):
|
|
# sp_api.GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL(seller_id,days=day_*-1)
|
|
# sp_api.GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL(seller_id,days=day_*-1)
|
|
return sp_api.GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL(refresh_token,seller_id,days,**a_kw)
|
|
return sp_api.GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL(refresh_token,seller_id,days,**a_kw)
|
|
- elif data_type =="GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE":
|
|
|
|
- return sp_api.GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE(refresh_token,seller_id,days)
|
|
|
|
|
|
+ # elif data_type =="GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE":
|
|
|
|
+ # return sp_api.GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE(refresh_token,seller_id,days)
|
|
elif data_type =="GET_SALES_AND_TRAFFIC_REPORT":
|
|
elif data_type =="GET_SALES_AND_TRAFFIC_REPORT":
|
|
return sp_api.GET_SALES_AND_TRAFFIC_REPORT(refresh_token,seller_id,days,**a_kw)
|
|
return sp_api.GET_SALES_AND_TRAFFIC_REPORT(refresh_token,seller_id,days,**a_kw)
|
|
elif data_type == "GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA":
|
|
elif data_type == "GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA":
|
|
@@ -1317,8 +1482,8 @@ class SpApiRequest:
|
|
return sp_api.GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT(refresh_token,seller_id,days,**a_kw)
|
|
return sp_api.GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT(refresh_token,seller_id,days,**a_kw)
|
|
elif data_type=="GET_SELLER_FEEDBACK_DATA":
|
|
elif data_type=="GET_SELLER_FEEDBACK_DATA":
|
|
return sp_api.GET_SELLER_FEEDBACK_DATA(refresh_token,seller_id,days,**a_kw)
|
|
return sp_api.GET_SELLER_FEEDBACK_DATA(refresh_token,seller_id,days,**a_kw)
|
|
- elif data_type=="GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENTS_DATA":
|
|
|
|
- return sp_api.GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENTS_DATA(refresh_token,seller_id,days,**a_kw)
|
|
|
|
|
|
+ elif data_type=="GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA":
|
|
|
|
+ return sp_api.GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA(refresh_token,seller_id,days,**a_kw)
|
|
elif data_type=="GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE":
|
|
elif data_type=="GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE":
|
|
return sp_api.GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE(refresh_token,seller_id,days,**a_kw)
|
|
return sp_api.GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE(refresh_token,seller_id,days,**a_kw)
|
|
else:
|
|
else:
|
|
@@ -1358,6 +1523,7 @@ class SpApiRequest:
|
|
try:
|
|
try:
|
|
print("refresh_token:",refresh_token,'data_type:',data_type,'seller_id:',seller_id,'marketplace:',marketplace.marketplace_id,'country_code:',a_kw['countryCode'],sep='\n')
|
|
print("refresh_token:",refresh_token,'data_type:',data_type,'seller_id:',seller_id,'marketplace:',marketplace.marketplace_id,'country_code:',a_kw['countryCode'],sep='\n')
|
|
auth_conn = SpApiRequest.Token_auth()
|
|
auth_conn = SpApiRequest.Token_auth()
|
|
|
|
+ print("CHECK>>>>>>>>>>>>>>>>>>>>>>>>>")
|
|
# print(a_kw)
|
|
# print(a_kw)
|
|
cls.data_judge_secondTry(refresh_token,sp_api, data_type, seller_id, auth_conn,days,**a_kw)
|
|
cls.data_judge_secondTry(refresh_token,sp_api, data_type, seller_id, auth_conn,days,**a_kw)
|
|
## sp_api.GET_FLAT_FILE_OPEN_LISTINGS_DATA(auth_conn, seller_id)
|
|
## sp_api.GET_FLAT_FILE_OPEN_LISTINGS_DATA(auth_conn, seller_id)
|
|
@@ -1394,32 +1560,39 @@ class SpApiRequest:
|
|
return base_product.get_product_pricing_for_asins(asin)
|
|
return base_product.get_product_pricing_for_asins(asin)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
- # for days in range(35,45):
|
|
|
|
- # SpApiRequest.get_allShops("GET_SALES_AND_TRAFFIC_REPORT",days=-days,**{"level":"SKU"})
|
|
|
|
|
|
+ # for days in range(-35,-2):
|
|
|
|
+ days=2
|
|
|
|
+ SpApiRequest.get_allShops("GET_SELLER_FEEDBACK_DATA",days=-days,**{})
|
|
# SpApiRequest.listing_infoTable()
|
|
# SpApiRequest.listing_infoTable()
|
|
# rel = SpApiRequest.get_catelog(account_name='AM-ZOSI-US',country=Marketplaces.US,asin='B0B8CPHSL4')
|
|
# rel = SpApiRequest.get_catelog(account_name='AM-ZOSI-US',country=Marketplaces.US,asin='B0B8CPHSL4')
|
|
# print(rel)
|
|
# print(rel)
|
|
# SpApiRequest
|
|
# SpApiRequest
|
|
- df = SpApiRequest.auth_info()
|
|
|
|
- print(df)
|
|
|
|
- zosi = df.query("account_name=='AM-ZOSI-US'")['refresh_token'].to_numpy().tolist()
|
|
|
|
- # print(zosi)
|
|
|
|
- refreshtoken_list = df.query("account_name!='AM-ZOSI-US'")['refresh_token'].to_numpy().tolist()
|
|
|
|
- zosi.extend(refreshtoken_list)
|
|
|
|
- refreshtoken_list = zosi.copy()
|
|
|
|
- aws_credentials = {
|
|
|
|
- 'refresh_token': refreshtoken_list[0],
|
|
|
|
- 'lwa_app_id': 'amzn1.application-oa2-client.1f9d3d4747e14b22b4b598e54e6b922e', # 卖家中心里面开发者资料LWA凭证
|
|
|
|
- 'lwa_client_secret': 'amzn1.oa2-cs.v1.13ebfa8ea7723b478215a2b61f4dbf5ca6f6927fa097c2dd0941a66d510aca7f',
|
|
|
|
- 'aws_access_key': 'AKIARBAGHTGOZC7544GN',
|
|
|
|
- 'aws_secret_key': 'OSbkKKjShvDoWGBwRORSUqDryBtKWs8AckzwNMzR',
|
|
|
|
- 'role_arn': 'arn:aws:iam::070880041373:role/Amazon_SP_API_ROLE'
|
|
|
|
- }
|
|
|
|
- sp_api = SpApiRequest(aws_credentials, Marketplaces.US)
|
|
|
|
- id = sp_api.GET_SELLER_FEEDBACK_DATA()
|
|
|
|
- df= sp_api.decompression(str(id))
|
|
|
|
- print(df)
|
|
|
|
- df.to_csv('GET_S.csv')
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ ###TEST
|
|
|
|
+ # df = SpApiRequest.auth_info()
|
|
|
|
+ # print(df)
|
|
|
|
+ # zosi = df.query("account_name=='AM-ZOSI-US'")['refresh_token'].to_numpy().tolist()
|
|
|
|
+ # # print(zosi)
|
|
|
|
+ # refreshtoken_list = df.query("account_name!='AM-ZOSI-US'")['refresh_token'].to_numpy().tolist()
|
|
|
|
+ # zosi.extend(refreshtoken_list)
|
|
|
|
+ # refreshtoken_list = zosi.copy()
|
|
|
|
+ # aws_credentials = {
|
|
|
|
+ # 'refresh_token': refreshtoken_list[0],
|
|
|
|
+ # 'lwa_app_id': 'amzn1.application-oa2-client.1f9d3d4747e14b22b4b598e54e6b922e', # 卖家中心里面开发者资料LWA凭证
|
|
|
|
+ # 'lwa_client_secret': 'amzn1.oa2-cs.v1.13ebfa8ea7723b478215a2b61f4dbf5ca6f6927fa097c2dd0941a66d510aca7f',
|
|
|
|
+ # 'aws_access_key': 'AKIARBAGHTGOZC7544GN',
|
|
|
|
+ # 'aws_secret_key': 'OSbkKKjShvDoWGBwRORSUqDryBtKWs8AckzwNMzR',
|
|
|
|
+ # 'role_arn': 'arn:aws:iam::070880041373:role/Amazon_SP_API_ROLE'
|
|
|
|
+ # }
|
|
|
|
+ # sp_api = SpApiRequest(aws_credentials, Marketplaces.US)
|
|
|
|
+ # id = sp_api.GET_SELLER_FEEDBACK_DATA()
|
|
|
|
+ # print(id)
|
|
|
|
+ # df= sp_api.decompression(str(id))
|
|
|
|
+ # print(df)
|
|
|
|
+ # df.to_csv('GET_SELLER_FEEDBACK_DATA.csv')
|
|
|
|
+ #### END
|
|
|
|
+
|
|
# print(sp_api.price_tracker(['B00L3W2QJ2']))
|
|
# print(sp_api.price_tracker(['B00L3W2QJ2']))
|
|
# shopReportday = "2024-08-25"
|
|
# shopReportday = "2024-08-25"
|
|
# shopReportday_E = "2024-08-31"
|
|
# shopReportday_E = "2024-08-31"
|