86 lines
2.7 KiB
Python
86 lines
2.7 KiB
Python
import requests
|
|
from module import F6_module
|
|
import time
|
|
import pandas as pd
|
|
|
|
f6_module = F6_module()
|
|
|
|
username = "18742526670"
|
|
password = "Zy18742526670"
|
|
store_name = "F6智慧门店—全功能体验ES"
|
|
org_name = '分店测试(废弃)'
|
|
|
|
res = f6_module.login_in(username, password, store_name)
|
|
cookies = requests.utils.dict_from_cookiejar(res.cookies)
|
|
|
|
# 获取供应商列表
|
|
url = "https://yunxiu.f6car.cn/purchase/baseInfo/supplier/getSupplierList"
|
|
params = {
|
|
"currentPage": 1,
|
|
"pageSize": 100,
|
|
"keyword": "",
|
|
"isDel": "",
|
|
"payType": "",
|
|
"keepAccounts": "",
|
|
"mainContent": "",
|
|
"supplierCloudType": "",
|
|
"idSupplierGroup": ""
|
|
}
|
|
res = requests.get(url, cookies=cookies, params=params)
|
|
|
|
total = res.json().get("data").get("total")
|
|
total_pages = (total // params["pageSize"]) + (1 if total % params["pageSize"] > 0 else 0)
|
|
print(f"总计{total_pages}页")
|
|
|
|
all_suppliers = []
|
|
max_retries = 10
|
|
retry_count = 0
|
|
for page in range(1, total_pages + 1):
|
|
print(f"正在请求第 {page} 页...")
|
|
params["currentPage"] = page
|
|
|
|
while retry_count < max_retries:
|
|
response = requests.get(url, cookies=cookies, params=params)
|
|
time.sleep(1)
|
|
if response.status_code == 200:
|
|
break
|
|
else:
|
|
retry_count += 1
|
|
print(f"请求第 {page} 页失败,正在重试(第 {retry_count} 次)...")
|
|
time.sleep(3)
|
|
|
|
try:
|
|
suppliers = response.json().get("data", {}).get("list", [])
|
|
all_suppliers.extend(suppliers)
|
|
except Exception as e:
|
|
print(f"请求第 {page} 页失败,错误:", e)
|
|
continue
|
|
|
|
up_dict = [
|
|
{"供应商名称": "郑涛汽配", "操作": "停用", "修改适用门店": "全部门店"},
|
|
{"供应商名称": "奥马汽配", "操作": "启用", "修改适用门店": "全功能体验"},
|
|
{"供应商名称": "陕西畅圭商贸", "操作": "启用", "修改适用门店": "全功能别克品牌2店;全功能体验"},
|
|
]
|
|
|
|
df = pd.DataFrame(up_dict)
|
|
|
|
new_supplier_list = []
|
|
for supplier in all_suppliers:
|
|
pkId = supplier.get("pkId")
|
|
supplier_name = supplier.get("name")
|
|
new_supplier_list.append((supplier_name, pkId))
|
|
|
|
# 修改供应商适用门店
|
|
for index, row in df.iterrows():
|
|
if row["供应商名称"] == supplier_name:
|
|
# 获取供应商详细信息
|
|
json_data = {"pkId": pkId}
|
|
response = requests.get(
|
|
'https://yunxiu.f6car.cn/purchase/baseInfo/supplier/getSupplierInfo',
|
|
cookies=cookies,
|
|
params=json_data,
|
|
)
|
|
supplier_info = response.json().get("data").get("supplierInfo")
|
|
print(f"正在修改供应商 {supplier_name} 的适用门店...")
|
|
|