openCard.py
9.41 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#coding=utf-8
# @Time : 2021/7/16 14:09
# @Author : Ljq
# @File : openMasterCard.py
# @Software: PyCharm
"""
主卡开卡页面接口
"""
import requests
import json
import re
import time
from commons.scripts import dealContentType as dCT
def getCustomerInfo(gatewayHost=None,clientHeaders=None,cCNum=360101199301010275):
"""
查询输入的证件号是否有匹配客户信息
:param cardHost:
:param clientHeaders:
:param cCNum:
:return:
"""
url = gatewayHost+"/card-web/card/getCustomerInfo.action"
clientHeaders = dCT.jsonCT(clientHeaders)
data = {"customerCertificateNumber":str(cCNum)}
res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data))
return res
def getSubTypeName(gatewayHost=None,clientHeaders=None,customerId=131176):
"""
查询客户身份类型名称
:param gatewayHost:
:param clientHeaders:
:param customerId:
:return:
"""
url = gatewayHost+f"/card-web/customer/getSubTypeName.action?customerId={customerId}"
res = requests.post(url=url,headers=clientHeaders)
return res
def checkNewCardNo(gatewayHost=None,clientHeaders=None,**kwargs):
"""
校验卡与当前客户类型状态是否匹配
:param gatewayHost:
:param clientHeaders:
:param kwargs: 主卡:{"cardNo":"888810032426","cardType":10,"customerType":"in_province","customerId":131167}
副卡:{"cardNo":"888800001130","cardType":20}
:return:
"""
url = gatewayHost+"/card-web/card/checkNewCardNo.action"
clientHeaders = dCT.jsonCT(clientHeaders)
print("kwargs ------------->",kwargs)
if "cardType" not in kwargs or kwargs["cardType"]==10:
data={"cardNo":"888810032426","cardType":10,"customerType":"in_province","customerId":131167}
# elif kwargs["cardType"]==10:
# data = {"cardNo": "888810032426", "cardType": 10, "customerType": "in_province", "customerId": 131167}
else:
data={}
data = dict(data,**kwargs)
print(data)
res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data))
return res
def getOpenCardFee(gatewayHost=None,clientHeaders=None):
url = gatewayHost+"/card-web/card/getOpenCardFee.action"
res = requests.get(url=url,headers=clientHeaders)
return res
def openMasterCard(gatewayHost=None,clientHeaders=None,**kwargs):
"""
开卡接口
:param gatewayHost:
:param clientHeaders:
:param kwargs: {"customerName":"长歌园外买家自动化用户不要动","customerType":"outside_buyer","customerId":131183,
"customerOrganizationType":"individual","customerCredentialType":"ID","customerContactsPhone":"18080001015",
"loginPwd":"111111","cardNo":"888810005703","customerCertificateNumber":"230681202105267887","cardType":10,
"costFee":888,"customerCode":"00130892","name":"长歌",
"createSource":1,"holdName":"长歌园外买家自动化用户不要动","holdContactsPhone":"18080001015","customerSyncModifyHoldinfo":1}
:return:
"""
url = gatewayHost+"/card-web/card/openMasterCard.action"
clientHeaders = dCT.jsonCT(clientHeaders)
data={"customerName":"","customerType":"","customerId":None,"customerOrganizationType":"","customerCredentialType":"","customerContactsPhone":"","loginPwd":"","cardNo":"","customerCertificateNumber":"","cardType":None,"costFee":None,"customerCode":"","name":"","createSource":1,"holdName":"","holdContactsPhone":"","customerSyncModifyHoldinfo":1}
data=dict(data,**kwargs)
print("openMasterCard data ----> ",data)
res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data))
return res
def openMasterCardDef(gatewayHost=None,clientHeaders=None,cCNum=None,cardNo=None,loginPwd=111111,applyUserName=None):
# 获取手续费
costFee = getOpenCardFee(gatewayHost=gatewayHost, clientHeaders=clientHeaders).json()["data"]
print(costFee)
# 获取客户信息
resCusInfo = getCustomerInfo(gatewayHost=gatewayHost, clientHeaders=clientHeaders,
cCNum=cCNum).json()["data"]
print(resCusInfo)
# 客户信息准备
customerName = resCusInfo["name"]
customerType = resCusInfo["customerType"]
customerId = resCusInfo["id"]
customerOrganizationType = resCusInfo["organizationType"]
customerCredentialType = resCusInfo["certificateType"]
customerContactsPhone = resCusInfo["customerContactsPhone"]
customerCertificateNumber = resCusInfo["certificateNumber"]
customerCode = resCusInfo["code"]
name = applyUserName
holdName = resCusInfo["name"]
holdContactsPhone = resCusInfo["customerContactsPhone"]
# 卡片状态校验
resCheck = checkNewCardNo(gatewayHost=gatewayHost, clientHeaders=clientHeaders,
cardNo=cardNo,
customerId=customerId,
customerType=customerType)
print(resCheck.json())
# assert "200" == resCheck.json()["code"], "卡片校验失败"
# 开卡
print("开始开卡")
resOpenCard = openMasterCard(gatewayHost=gatewayHost, clientHeaders=clientHeaders,
cardNo=cardNo,
costFee=costFee, customerName=customerName, customerType=customerType,
customerId=customerId, loginPwd=loginPwd,
customerOrganizationType=customerOrganizationType,
customerCredentialType=customerCredentialType,
customerContactsPhone=customerContactsPhone,
customerCertificateNumber=customerCertificateNumber, customerCode=customerCode,
name=name, holdName=holdName, holdContactsPhone=holdContactsPhone, cardType=10)
print("resOpenCard.json()", resOpenCard.json())
return resOpenCard
def getAccountInfo(gatewayHost=None,clientHeaders=None,cardNo=None):
url = gatewayHost+"/card-web/card/getAccountInfo.action"
clientHeaders=dCT.jsonCT(clientHeaders)
data = {"cardNo":str(cardNo)}
res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data))
return res
def openSlaveCard(gatewayHost=None,clientHeaders=None,**kwargs):
"""
:param gatewayHost:
:param clientHeaders:
:param kwargs:{"customerName":"长歌一","customerType":null,"customerId":131136,"customerOrganizationType":"individual",
"customerCredentialType":"ID","customerContactsPhone":"18050005001","loginPwd":"111111","cardNo":"800000020435",
"customerCertificateNumber":"110101200803075932","cardType":20,"costFee":999,"customerCode":"00130845",
"name":"沈阳长歌","parentAccountId":104547,"createSource":1,"parentLoginPwd":"111111","holdName":"长歌一",
"holdContactsPhone":"18050005001","customerSyncModifyHoldinfo":1}
:return:
"""
url = gatewayHost+"/card-web/card/openSlaveCard.action"
clientHeaders = dCT.jsonCT(clientHeaders)
data={"customerName":"长歌一","customerType":None,"customerId":131136,"customerOrganizationType":"individual","customerCredentialType":"ID","customerContactsPhone":"18050005001","loginPwd":"111111","cardNo":"800000020435","customerCertificateNumber":"110101200803075932","cardType":20,"costFee":999,"customerCode":"00130845","name":"沈阳长歌","parentAccountId":104547,"createSource":1,"parentLoginPwd":"111111","holdName":"长歌一","holdContactsPhone":"18050005001","customerSyncModifyHoldinfo":1}
data = dict(data,**kwargs)
res = requests.post(url=url,headers=clientHeaders,data=json.dumps(data))
return res
def openSlaveCardDef(gatewayHost=None,clientHeaders=None,cardNo=None,slaveCardNo=None,loginPwd=None,applyUserName=None,parentLoginPwd=None):
costFee = getOpenCardFee(gatewayHost=gatewayHost, clientHeaders=clientHeaders).json()["data"]
print(costFee)
resGet = getAccountInfo(gatewayHost=gatewayHost, clientHeaders=clientHeaders, cardNo=cardNo).json()["data"]
print("resGet ---> ", resGet)
customerName = resGet["customerName"]
customerId = resGet["customerId"]
customerCredentialType = resGet["customerCertificateType"]
customerContactsPhone = resGet["customerContactsPhone"]
customerCertificateNumber = resGet["customerCertificateNumber"]
cardType = 20
customerCode = resGet["customerCode"]
name = applyUserName
parentAccountId = resGet["accountId"]
holdName = customerName
holdContactsPhone = customerContactsPhone
resOpenSlaveCard = openSlaveCard(gatewayHost=gatewayHost, clientHeaders=clientHeaders,
customerName=customerName,
customerId=customerId, customerContactsPhone=customerContactsPhone,
loginPwd=loginPwd, cardNo=slaveCardNo,
customerCertificateNumber=customerCertificateNumber, cardType=cardType,
costFee=costFee, customerCode=customerCode,
name=name, parentAccountId=parentAccountId, parentLoginPwd=parentLoginPwd,
holdName=holdName,
holdContactsPhone=holdContactsPhone,
customerCredentialType=customerCredentialType
)
return resOpenSlaveCard