CheckIn.py
7.58 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
# -*- coding: utf-8 -*-
# @Time : 2021/9/8 14:17
# @Author : Ljq
# @File : CheckIn.py
# @Software: PyCharm
"""
创建进门登记单
"""
import json,time,random,re
from commons.scripts import dealContentType as dct
from commons.scripts import jsonToUrlCode
from commons.scripts import replaceJsonData as rJD
import urllib.parse
from commons.MySession import sessionHg
host = "http://test.gateway.diligrp.com:8285"
def get_simpleInfo(session=None,host=None,ic=None):
url = host+"/card-web/accountQuery/simpleInfo.action"
headers={}
data={"cardNo":ic}
res = session.useHeadersRequests(method="GET",url=url,params=data,headers=headers)
return res
def get_tree(session=None,host=None,**kwargs):
"商品信息获取"
url = host+"/assets-service/api/cusCategory/getTree"
headers = dct.jsonCode()
data={"marketId":15,"keyword":"西瓜","state":1}
data = dict(data,**kwargs)
res = session.useHeadersRequests(method="post",url=url,data=json.dumps(data),headers=headers)
return res
def get_cityCode(session=None,host=None,allLevelKeyword="万州"):
""""""
url = host+"/assets-service/api/city/listByKeywordsWithCityCode"
headers = dct.jsonCode()
data={"allLevelKeyword":allLevelKeyword}
res = session.useHeadersRequests(method="post",url=url,data=json.dumps(data),headers=headers)
return res
def get_searchArea(session=None,host=None,**kwargs):
""""""
url = host+"/assets-service/api/district/search"
headers = dct.jsonCode()
data={"marketId":15,"nameLike":"西区"}
data = dict(data,**kwargs)
res = session.useHeadersRequests(method="post",url=url,data=json.dumps(data),headers=headers)
return res
def get_chargeItem(session=None,host=None,**kwargs):
"""获取费用项"""
url = host+"/hg-trading/api/businessChargeItem/listBusinessChargeItem"
headers = dct.jsonCode()
data={"marketId":15,"businessType":"501"}
data = dict(data,**kwargs)
res = session.useHeadersRequests(method="post",url=url,data=json.dumps(data),headers=headers)
return res
def get_queryFee(session=None,host=None,**kwargs):
"""根据费用项获取费用"""
url = host+"/dili-rule/api/chargeRule/queryFee"
headers = dct.jsonCode()
data={"businessType":"501","chargeItem":520,"marketId":15}
data = dict(data,**kwargs)
res = session.useHeadersRequests(method="post",url=url,data=json.dumps(data),headers=headers)
return res
def save_registerRecord(session=None,host=None,**kwargs):
"""生成登记单并缴费"""
url = host+"/hg-trading/api/registerRecord/save"
headers = dct.jsonCode()
data = {"accountId": 107796, "cardNo": "888800010591", "customerId": 142000, "customerCode": "00131702",
"customerName": "史东晶", "fixedphoneNumber": None, "mobilephoneNumber": "18080008020",
"identityCardAddress": "", "identityCardNo": "110101202109024587", "identityCardType": "ID",
"registerDetailDtoList": [
{"id": 0, "areaId": 272, "areaName": "西区", "quantity": 0, "productId": 754107, "registerRecordId": 0,
"remark": None, "weight": 100, "weightType": 0, "created": None, "createdById": 0,
"createdByName": None, "createdByDepartmentId": 0, "createdByDepartmentName": None,
"registerCertificateList": None, "product": None, "registerCertificateDtoList": None,
"productDto": {"id": 0, "originId": 500101, "originName": "万州区", "pieceWeight": 0,
"categoryId": 754107, "categoryCode": "754107", "categoryName": "葡萄",
"created": None}}],
"registerFeeDtoList": [
{"id": 0, "actualFee": 200.0, "receivableFee": 1300.0, "discountFee": 1100.0, "registerRecordId": 0,
"payStatus": 0, "chargeItemName": "其他收费", "chargeType": 1, "chargeItemId": 518, "registerFeeType": 999,
"created": None, "createdById": 0, "createdByName": None, "settleDate": None, "isBehalf": 0,
"registerLoadingFeeExtDto": None}], "tradePassword": "111111"}
data = rJD.replaceJsonData(json=data,data=kwargs)
print(data)
res = session.useHeadersRequests(method="post",url=url,data=json.dumps(data),headers=headers)
return res
def create_registerRecord(session=None,host=None,ic="888800010591",goodsName="葡萄",nameLike="西区",
allLevelKeyword="万州",tradePassword="111111",weight=100):
"""创建进门登记单并缴费"""
# 获取费用信息
marketId = session.userInfo["data"]["user"]["firmId"]
res = get_chargeItem(session=session,host=host,marketId=marketId)
chargeItemId = [i["id"] for i in res.json()["data"] if i["chargeItem"] == "其他收费"][0]
chargeItemIdChild = [i["id"] for i in res.json()["data"] if "parentId" in i.keys() and i["parentId"] == chargeItemId][0]
# 获取客户信息
resSimpleInfo = get_simpleInfo(session=session,host=host,ic=ic)
accountId = resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
cardNo = resSimpleInfo.json()["data"]["accountInfo"]["cardNo"]
customerId = resSimpleInfo.json()["data"]["accountInfo"]["customerId"]
customerCode = resSimpleInfo.json()["data"]["accountInfo"]["customerCode"]
customerName = resSimpleInfo.json()["data"]["accountInfo"]["customerName"]
mobilephoneNumber = resSimpleInfo.json()["data"]["accountInfo"]["customerContactsPhone"]
identityCardNo = resSimpleInfo.json()["data"]["accountInfo"]["customerCertificateNumber"]
# 获取商品信息
resTree = get_tree(session=session,host=host,keyword=goodsName,marketId=marketId)
productId = resTree.json()["data"][0]["id"]
categoryId = productId
categoryCode = productId
categoryName = resTree.json()["data"][0]["name"]
# 获取产地信息
resCity = get_cityCode(session=session,host=host,allLevelKeyword=allLevelKeyword)
originId = resCity.json()["data"][0]["id"]
originName = resCity.json()["data"][0]["name"]
# 获取区域信息
resArea = get_searchArea(session=session,host=host,nameLike=nameLike,marketId=marketId)
areaId = resArea.json()["data"][0]["id"]
areaName = resArea.json()["data"][0]["name"]
# 采用其他收费时获取应收金额,优惠金额,实际金额
receivableFee = int(get_queryFee(session=session,host=host,chargeItem=chargeItemId,marketId=marketId).json()["data"]["totalFee"])*100
discountFee = int(get_queryFee(session=session, host=host, chargeItem=chargeItemIdChild,marketId=marketId).json()["data"]["totalFee"])*100
actualFee = receivableFee - discountFee
# 创建进门登记单并缴费
resSave = save_registerRecord(session=session, host=host, weight=weight, tradePassword=tradePassword,
chargeItemId=chargeItemId, accountId=accountId, cardNo=cardNo, customerId=customerId,
customerCode=customerCode, customerName=customerName,
mobilephoneNumber=mobilephoneNumber, identityCardNo=identityCardNo,
productId=productId, categoryId=categoryId, categoryCode=categoryCode,
categoryName=categoryName, originId=originId, originName=originName, areaId=areaId,
areaName=areaName, receivableFee=receivableFee, discountFee=discountFee,
actualFee=actualFee)
return resSave
# res = create_registerRecord(session=sessionHg,ic="888800010592",host=host,goodsName="苹果",allLevelKeyword="金牛区",
# nameLike="西区",tradePassword="111111",weight="50")
# print(res.text)