returnCard.py
1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#coding=utf-8
# @Time : 2021/5/26 16:39
# @Author : Ljq
# @File : returnCard.py
# @Software: PyCharm
"""
退还卡接口
"""
import requests
import json
import re
import time
from commons.scripts import dealContentType as dCT
def getSimpleInfo(gatewayHost=None,clientHeaders=None,cardNo=None):
"""
获取卡信息
:param gatewayHost:
:param clientHeaders:
:param cardNo:
:return:
"""
url = gatewayHost+f"/account-service/api/account/simpleInfo?cardNo={cardNo}"
res = requests.get(url=url,headers=clientHeaders)
return res
def returnCard(gatewayHost=None,clientHeaders=None,**kwargs):
"""
退卡
:param gatewayHost:
:param clientHeaders:
:param kwargs:{"loginPwd":"111111","cardNo":"888810005703","accountId":104707,"customerId":131183}
:return:
"""
url = gatewayHost+"/card-web/card/returnCard.action"
clientHeaders = dCT.jsonCT(clientHeaders)
data={"loginPwd":"111111","cardNo":"888810005703","accountId":104707,"customerId":131183}
data=dict(data,**kwargs)
# print("returnCard --- data ---> ",data)
res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data))
return res
def returnCardDef(gatewayHost=None,clientHeaders=None,cardNo=None,loginPwd="111111"):
"""
退卡不走封装
:param gatewayHost:
:param clientHeaders:
:param cardNo:
:return:
"""
# 获取卡片信息
cardInfo = getSimpleInfo(gatewayHost=gatewayHost, clientHeaders=clientHeaders, cardNo=cardNo)
# print("returnCardDef -- > cardInfo.json()",cardInfo.json())
customerId = cardInfo.json()["data"]["accountInfo"]["customerId"]
accountId = cardInfo.json()["data"]["accountInfo"]["accountId"]
# 退卡
resReturnCard = returnCard(gatewayHost=gatewayHost, clientHeaders=clientHeaders, cardNo=cardNo,
accountId=accountId, customerId=customerId,loginPwd=loginPwd)
print(resReturnCard.json())
return resReturnCard