Files
F6--/张阳脚本/F6汽车系统/批量修改会员卡固定项目价格.py
T
2026-01-30 11:28:35 +08:00

318 lines
9.8 KiB
Python

# -*- coding: utf-8 -*-
import pandas as pd
import time
import requests
import json
import datetime
import hashlib
from urllib.parse import quote, quote_plus
from module import F6_module
from tqdm import tqdm
from http.cookies import SimpleCookie
f6_module = F6_module()
username = "13818481656"
password = "Hy123456"
store_name = " 上海鸿远汽车生活馆"
# res = f6_module.login_in(username, password, store_name)
def parse_cookie_string(cookie_str):
cookie = SimpleCookie()
cookie.load(cookie_str)
return {k: v.value for k, v in cookie.items()}
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0',
"Content-Type": "application/json",
'Referer': 'https://yunxiu.f6car.cn/erp/view/index.html'
}
cookies = "marketingSESSIONID=0e4b89d5-b393-4034-8218-890b1ea14b58; Hm_lvt_25f5e7a3a5dbb293d7dd35d5f1be8d0a=1767926696,1768188627,1768897114,1768986334; HMACCOUNT=A6A0585E8C70051D; erpLanguage=zh-CN; tmall=false; prodOrg=16035098489335611406; unp=16035098491730563165; un=16035098491730563165; _up=-NillNN-qyBEJ--t3vnSknvoOF1_zvSNucUB2no4WedYUPLAoZzQjaZJ9Q3d-WrAAGgt60MgQHajHWBHMKKxj0CuWypi1JgKCFP1EPEk-HbqEvoVrIsm1gIE-fhRv-ZNHu3M-GTf3pu0FX6gquRUjugalVDAPxVqrEj9yVz78pjBPGg.; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2216035098491730563165%22%2C%22first_id%22%3A%2219b6df76a22f46-04a98afdd2a11d8-4c657b58-1327104-19b6df76a2312c7%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%7D%2C%22%24device_id%22%3A%2219b6df76a22f46-04a98afdd2a11d8-4c657b58-1327104-19b6df76a2312c7%22%7D; Hm_lpvt_25f5e7a3a5dbb293d7dd35d5f1be8d0a=1769154735"
cookies_dict = parse_cookie_string(cookies)
df = pd.read_excel(fr"C:\Users\hp_z66\OneDrive\Desktop\鸿远汽车.xlsx", sheet_name=2)
for index, row in tqdm(df.iterrows(), total=len(df)):
id = row["卡实体id"]
# step1:获取卡实体信息
params = {
'pkId': id,
}
response = requests.get(
'https://yunxiu.f6car.cn/macan/card/entity/czk/queryWithBenefit',
params=params,
cookies=cookies_dict,
headers=headers,
)
print(response.json())
info = response.json().get("info")
raw_end = info.get("entityDTO", {}).get("endDate")
if raw_end:
ts = raw_end / 1000 if raw_end > 1e10 else raw_end
end_str = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
else:
end_str = None # 或指定默认值,如 "2026-10-18 23:59:59"
print(info)
modify_json_data = {
'id': id,
'cardNo': info.get("entityDTO").get("memberCardNo"), # 车辆编号
'memo': info.get("entityDTO").get("memo"), # 卡说明
'useTerm': info.get("entityDTO").get("useTerm"), # 使用条款
'idCustomer': info.get("entityDTO").get("idCustomer"), # 用户编码
'version': info.get("entityDTO").get("version"),
'useType': info.get("entityDTO").get("useType"),
'consumeLimitFlag': info.get("entityDTO").get("consumeLimitFlag"),
'consumeLimitAmount': info.get("entityDTO").get("consumeLimitAmount"),
'permanent': info.get("entityDTO").get("permanent"),
'carList': info.get("carInfoList",[]),
'endDate': end_str,
'cardEntityBusinessList': [
{
'labelName': '维修',
'businessType': 0,
'labelId': '2754559',
},
{
'labelName': '保养',
'businessType': 0,
'labelId': '2754560',
},
{
'labelName': '美容',
'businessType': 0,
'labelId': '2754561',
},
{
'labelName': '钣喷',
'businessType': 0,
'labelId': '2754562',
},
{
'labelName': '轮胎',
'businessType': 0,
'labelId': '2754563',
},
{
'labelName': '洗车',
'businessType': 0,
'labelId': '2754564',
},
{
'labelName': '精品',
'businessType': 0,
'labelId': '2754565',
},
{
'labelName': '其他',
'businessType': 0,
'labelId': '2754566',
},
{
'labelName': '零售',
'businessType': 0,
'labelId': '2754567',
},
{
'labelName': '补胎',
'businessType': 0,
'labelId': '2754953',
},
{
'labelName': '电瓶',
'businessType': 0,
'labelId': '2755066',
},
{
'labelName': '装潢',
'businessType': 0,
'labelId': '2755262',
},
{
'labelName': '脚垫',
'businessType': 0,
'labelId': '2755263',
},
{
'labelName': '维修',
'businessType': 1,
'labelId': '2754559',
},
{
'labelName': '保养',
'businessType': 1,
'labelId': '2754560',
},
{
'labelName': '美容',
'businessType': 1,
'labelId': '2754561',
},
{
'labelName': '钣喷',
'businessType': 1,
'labelId': '2754562',
},
{
'labelName': '轮胎',
'businessType': 1,
'labelId': '2754563',
},
{
'labelName': '洗车',
'businessType': 1,
'labelId': '2754564',
},
{
'labelName': '精品',
'businessType': 1,
'labelId': '2754565',
},
{
'labelName': '其他',
'businessType': 1,
'labelId': '2754566',
},
{
'labelName': '零售',
'businessType': 1,
'labelId': '2754567',
},
{
'labelName': '补胎',
'businessType': 1,
'labelId': '2754953',
},
{
'labelName': '电瓶',
'businessType': 1,
'labelId': '2755066',
},
{
'labelName': '装潢',
'businessType': 1,
'labelId': '2755262',
},
{
'labelName': '脚垫',
'businessType': 1,
'labelId': '2755263',
},
{
'businessType': 2,
'labelId': '0',
},
], # 手动更新
'cardEntityBusinessDiscountList': info.get("valueCardBusinessDiscountInfoList"), # 项目材料折扣
'businessType': 1,
'cardEntitySkuDiscountList': [
{
'skuType': 0,
'skuId': '14582097883363530866',
'discountType': 1,
'discount': 2280,
'skuName': '1号镀晶',
},
{
'skuType': 0,
'skuId': '14582097883363530862',
'discountType': 1,
'discount': 238,
'skuName': '玻璃去污镀膜',
},
{
'skuType': 0,
'skuId': '14582097883363530859',
'discountType': 1,
'discount': 2300,
'skuName': '轻奢洗车年套餐',
},
{
'skuType': 0,
'skuId': '14582097883363530853',
'discountType': 1,
'discount': 1580,
'skuName': '外部橡塑抗污涂层',
},
{
'skuType': 0,
'skuId': '14582097883363530852',
'discountType': 1,
'discount': 328,
'skuName': '澜泰3号快速360镀膜洗车',
},
{
'skuType': 0,
'skuId': '14582097883363530847',
'discountType': 1,
'discount': 3280,
'skuName': '2号镀晶',
},
{
'skuType': 0,
'skuId': '14582097883363530846',
'discountType': 1,
'discount': 55,
'skuName': '澜泰1号特色洗车',
},
{
'skuType': 0,
'skuId': '14582097883363530845',
'discountType': 1,
'discount': 550,
'skuName': '发动机舱清洗镀膜',
},
{
'skuType': 0,
'skuId': '14582097883363530843',
'discountType': 1,
'discount': 2280,
'skuName': '1号真皮涂层',
},
{
'skuType': 0,
'skuId': '14582097883363530841',
'discountType': 1,
'discount': 2290,
'skuName': '澜•洗护年套装',
},
{
'skuType': 0,
'skuId': '14582097883363530839',
'discountType': 1,
'discount': 188,
'skuName': '澜泰2号轮胎轮毂翻新镀膜洗车',
},
{
'skuType': 0,
'skuId': '14582097883363530837',
'discountType': 1,
'discount': 500,
'skuName': '漆面去污还原',
},
{
'skuType': 0,
'skuId': '14582097883363530836',
'discountType': 1,
'discount': 750,
'skuName': '室内综合治理',
},
{
'skuType': 0,
'skuId': '14582097883363530834',
'discountType': 1,
'discount': 550,
'skuName': '负离子空调治理',
},
], # 固定价格手动更新
}
result = requests.post(
'https://yunxiu.f6car.cn/marketing/card/modifyCzkCardEntity4Gray',
cookies=cookies_dict,
headers=headers,
json=modify_json_data,
)
print(modify_json_data)
print(result.json())