returnCard.py 1.95 KB
#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