|
@@ -498,6 +498,15 @@ class SpApiRequest:
|
|
def get_orders_allShops(cls):
|
|
def get_orders_allShops(cls):
|
|
pass
|
|
pass
|
|
|
|
|
|
|
|
+ @staticmethod
|
|
|
|
+ def data_judge_secondTry(sp_api,data_type,seller_id,auth_conn):
|
|
|
|
+ try:
|
|
|
|
+ SpApiRequest.data_judge(sp_api, data_type, seller_id, auth_conn)
|
|
|
|
+ except:
|
|
|
|
+ time.sleep(3)
|
|
|
|
+ SpApiRequest.data_judge(sp_api, data_type, seller_id, auth_conn)
|
|
|
|
+
|
|
|
|
+
|
|
@staticmethod
|
|
@staticmethod
|
|
def data_judge(sp_api,data_type,seller_id,auth_conn):
|
|
def data_judge(sp_api,data_type,seller_id,auth_conn):
|
|
if data_type == "GET_FLAT_FILE_OPEN_LISTINGS_DATA":
|
|
if data_type == "GET_FLAT_FILE_OPEN_LISTINGS_DATA":
|
|
@@ -532,7 +541,7 @@ class SpApiRequest:
|
|
sp_api = SpApiRequest(aws_credentials, marketplace)
|
|
sp_api = SpApiRequest(aws_credentials, marketplace)
|
|
try:
|
|
try:
|
|
auth_conn = SpApiRequest.mysql_connect_auth()
|
|
auth_conn = SpApiRequest.mysql_connect_auth()
|
|
- cls.data_judge(sp_api, data_type, seller_id, auth_conn)
|
|
|
|
|
|
+ cls.data_judge_secondTry(sp_api, data_type, seller_id, auth_conn)
|
|
## sp_api.GET_FLAT_FILE_OPEN_LISTINGS_DATA(auth_conn, seller_id)
|
|
## sp_api.GET_FLAT_FILE_OPEN_LISTINGS_DATA(auth_conn, seller_id)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
print(e)
|
|
print(e)
|
|
@@ -545,7 +554,7 @@ class SpApiRequest:
|
|
sp_api = SpApiRequest(aws_credentials, marketplace)
|
|
sp_api = SpApiRequest(aws_credentials, marketplace)
|
|
try:
|
|
try:
|
|
auth_conn = SpApiRequest.mysql_connect_auth()
|
|
auth_conn = SpApiRequest.mysql_connect_auth()
|
|
- cls.data_judge(sp_api, data_type, seller_id, auth_conn)
|
|
|
|
|
|
+ cls.data_judge_secondTry(sp_api, data_type, seller_id, auth_conn)
|
|
## sp_api.GET_FLAT_FILE_OPEN_LISTINGS_DATA(auth_conn, seller_id)
|
|
## sp_api.GET_FLAT_FILE_OPEN_LISTINGS_DATA(auth_conn, seller_id)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
print(e)
|
|
print(e)
|
|
@@ -556,7 +565,7 @@ class SpApiRequest:
|
|
print(region_circle)
|
|
print(region_circle)
|
|
marketplace = eval(f'Marketplaces.{region_circle}')
|
|
marketplace = eval(f'Marketplaces.{region_circle}')
|
|
sp_api = SpApiRequest(aws_credentials, marketplace)
|
|
sp_api = SpApiRequest(aws_credentials, marketplace)
|
|
- cls.data_judge(sp_api, data_type, seller_id, auth_conn)
|
|
|
|
|
|
+ cls.data_judge_secondTry(sp_api, data_type, seller_id, auth_conn)
|
|
## sp_api.GET_FLAT_FILE_OPEN_LISTINGS_DATA(auth_conn, seller_id)
|
|
## sp_api.GET_FLAT_FILE_OPEN_LISTINGS_DATA(auth_conn, seller_id)
|
|
|
|
|
|
def timeDeal(self, orgTime):
|
|
def timeDeal(self, orgTime):
|
|
@@ -583,12 +592,13 @@ class SpApiRequest:
|
|
decom_df.fillna('',inplace=True)
|
|
decom_df.fillna('',inplace=True)
|
|
# decom_df.to_csv('order.csv')
|
|
# decom_df.to_csv('order.csv')
|
|
decom_df["ReportDate"] = parse(shopReportday)
|
|
decom_df["ReportDate"] = parse(shopReportday)
|
|
- decom_df['timezone'] = decom_df["purchase-date"].map(lambda x: parse(x).tzname()).fillna(method='bfill')
|
|
|
|
|
|
+ # decom_df['timezone'] = decom_df["purchase-date"].map(lambda x: parse(x).tzname()).fillna(method='bfill')
|
|
|
|
+ decom_df['timezone'] = "UTC"
|
|
print("==========================================================")
|
|
print("==========================================================")
|
|
decom_df[["purchase-date", "last-updated-date"]] = decom_df[["purchase-date", "last-updated-date"]].applymap(
|
|
decom_df[["purchase-date", "last-updated-date"]] = decom_df[["purchase-date", "last-updated-date"]].applymap(
|
|
lambda x: self.timeDeal(x) if pd.isna(x) == False or x != None else x)
|
|
lambda x: self.timeDeal(x) if pd.isna(x) == False or x != None else x)
|
|
if 'is-business-order' not in decom_df.columns:
|
|
if 'is-business-order' not in decom_df.columns:
|
|
- decom_df['is-business-order'] = '-'
|
|
|
|
|
|
+ decom_df['is-business-order'] = None
|
|
if 'purchase-order-number' not in decom_df.columns:
|
|
if 'purchase-order-number' not in decom_df.columns:
|
|
decom_df['purchase-order-number'] = '-'
|
|
decom_df['purchase-order-number'] = '-'
|
|
if 'price-designation' not in decom_df.columns:
|
|
if 'price-designation' not in decom_df.columns:
|
|
@@ -611,7 +621,7 @@ class SpApiRequest:
|
|
]
|
|
]
|
|
list_df = decom_df[reserve_columns].to_numpy().tolist()
|
|
list_df = decom_df[reserve_columns].to_numpy().tolist()
|
|
# print(list_df)
|
|
# print(list_df)
|
|
- print(list_df[0])
|
|
|
|
|
|
+ # print(list_df[0])
|
|
# tuple_data = [tuple(i) for i in list_df]
|
|
# tuple_data = [tuple(i) for i in list_df]
|
|
conn = self.mysql_connect()
|
|
conn = self.mysql_connect()
|
|
cursor = conn.cursor()
|
|
cursor = conn.cursor()
|