applipatient.txt
從數(shù)據(jù)庫提取出來的
163409534007317600107111 0.01 林
163289698977816100106112 0.01 林
162633321590100200105113 0.01 晚涵
162555748524100600105114 0.01 晚涵
獲取orderId,放入列表儲存
resdata=[]
def data():
path = r'applipatient.txt'
with open(path, 'r', encoding='utf-8') as f:
for line in f:
resdata.append(line[:24])
data()
print(resdata)
將獲取到的orderId依次調(diào)用接執(zhí)行退費
import requests
import time
def returnfree(orderId):
url="http://192.168.xx.xx:xxxxorder/refundpayment" #登錄
headers = {"api-version": "6.0.0", "Content-Type": "application/json", "Connection": "keep-alive"}
data={"orderId":orderId,"type":"2","userId":"x"} #type:"1處方,2檢驗,3檢查"
html=requests.post(url,headers=headers,json=data)
print("申請單退費:"+orderId,html.json())
data=['163409534007317600107111', '163289698977816100106112'],'162633321590100200105113','162555748524100600105114'
for orderId in data:
# print(orderId)
returnfree(orderId)
time.sleep(2)
最后查看執(zhí)行結(jié)果,即可知曉是否退費成功