import pandas as pd import time import requests import json import xlrd cookies_str = 'stockSESSIONID=4e48c8e9-6aad-41d0-9c40-ec0e67c5419e; sensorsdata2015jssdkcross={"distinct_id":"10691192243902595917","first_id":"1750b4690af1f6-089dd3a4874eb8-3d634f03-1327104-1750b4690b09d0","props":{"$latest_traffic_source_type":"直接流量","$latest_search_keyword":"未取到值_直接打开","$latest_referrer":""},"$device_id":"1750b4690af1f6-089dd3a4874eb8-3d634f03-1327104-1750b4690b09d0"}; gr_user_id=408fef1a-77ed-4e74-8f1e-31dde3446f2e; prodOrg=11240984669917337122; unp=15531725281298481155; un=15531725281298481155; _up=-NillNN-qyBEJ--t3vnSknvoOF56zvCKssgH23o9U-9ZXvDAopzQjaZJ9Q3d-WrAAGgt60MgQHajHWBHMKKxj0CuWypi1JgKCFP1EPEk-HbrEPodqY8j1wUI-_dRv-ZNHu3M-GTc25uwEnWtrOVUi-ISlF7CPxZqrEj9k0rY98uxN2Q.; currMenu=下载中心; sensorsdata2015jssdkcross={"distinct_id":"15531725281298481155","first_id":"1750b4690af1f6-089dd3a4874eb8-3d634f03-1327104-1750b4690b09d0","props":{"$latest_traffic_source_type":"直接流量","$latest_search_keyword":"未取到值_直接打开","$latest_referrer":""},"$device_id":"1750b4690af1f6-089dd3a4874eb8-3d634f03-1327104-1750b4690b09d0"}' cookies_str = cookies_str.encode('utf-8').decode('latin-1') cookie_dict = {item.split('=')[0]: item.split('=')[1] for item in cookies_str.split('; ')} headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 Edg/95.0.1020.40', "Content-Type": "application/json", 'origin': 'https://yunxiu.f6car.cn' } #读取excel文件 data = xlrd.open_workbook(r"C:\Users\admin\Desktop\Python脚本\图形界面自动化脚本\F6系统常用脚本\怡康街店.xls") table = data.sheet_by_index(0) # 通过索引顺序获取 h = table.nrows l = table.ncols print(u"表数据的行数为%s,列数为%s"%(h,l)) for i in range(1,h): idMember =table.cell(i, 0).value #卡id idMember1 =table.cell(i, 1).value #退款金额 idMember2 =table.cell(i, 2).value #退款金额 #读取cardVersion信息并配置退卡data url = 'https://yunxiu.f6car.cn/marketing/tkdBill/baseInfo?pkId={}'.format(idMember) resget = requests.get(url,cookies=cookie_dict) resget = json.loads(resget.text) cardVersion = resget['data']['cardVersion'] data = { "cardId": idMember, # 退卡实体id "cardVersion": cardVersion, "employeeId": "10979894419857291646", # 退卡服务顾问ID 手动更新 "idOwnOrg": "11240984669917132579", # 门店ID 手动更新 "refundAmount": idMember1, # 退卡金额 "remark": "" # 备注 } #生成退卡单 res = requests.post(f'https://yunxiu.f6car.cn/marketing/tkdBill/add', headers=headers,cookies=cookie_dict, json=data) resdata = res.json().get('data') #完成收款 data = { "idOwnOrg": "11240984669917132579",# 门店ID 手动更新 "idOperationOrg": "11240984669917132579",# 退卡门店ID 手动更新 "idSourceBill": resdata,# 退卡单ID "sourceBillType": "TKD",#类型 "receiptMemo": "",# 备注 "version": cardVersion, "favourableList": [], "gatheringFavourable": 0, "paymentTypeGroupId": "", "czkList": [], "paymentList": [ { "paymentTypeId": "9876312",# 各门店不同 手动更新 "paymentType": "现金", "paymentAmount": idMember2, "gatheringType": 0, "kind": "normal" } ], "pkId": 0, "billType": "YSF", "domainCode": "SAAS" } res = requests.post(f'https://yunxiu.f6car.cn/financial/advance/payment/singleGathering', headers=headers,cookies=cookie_dict, json=data) print("打印出响应信息:",res.text)