entranceFeeBillList.py 17.7 KB
# -*- coding: utf-8 -*-

# @Time    : 2021/7/29 16:48
# @Author  : Ljq
# @File    : entranceFeeBillList.py
# @Software: PyCharm

"""
进门单列表接口封装
"""

import json,time,random,re
from commons.scripts import dealContentType as dct
from commons.scripts import jsonToUrlcode
from commons.MySession import my
from bs4 import BeautifulSoup

def listPage(host="",attrName="收费单号",attrValue=None,**kwargs):
    """
    进门单列表查询接口
    :param kwargs:
                rows=10
                page=1
                sort=et.created
                order=desc
                attr=number
                attrValue=11
                carTypeId=53
                categoryId=14152
                productName=1
                status=2
                tradeTypeId=70
                tareOperatorName=11
                startTime=2021-07-29 00:00:00
                endTime=2021-07-29 23:59:59
                startPayTime=2021-07-29 00:00:00
                endPayTime=2021-07-29 23:59:59
                startRefundTime=2021-07-29 00:00:00
                endRefundTime=2021-07-29 23:59:59
    """

    headers = dct.urlCode()
    url = host + "/entranceFeeBill/listPage.action"
    attr_list = {"收费单号": "number", "车号": "likePlate", "商品": "goods", "收费员": "pay", "客户姓名": "cname",
            "客户卡号": "ic", "手机号码": "phone"}
    data = {"rows": "10", "page": "1", "sort": "et.created", "order": "desc",
            "metadata[created]": {"provider": "datetimeProvider", "index": 10, "field": "created"},
            "metadata[totalPrice]": {"provider": "moneyProvider", "index": 20, "field": "totalPrice"},
            "metadata[paymentTime]": {"provider": "datetimeProvider", "index": 30, "field": "paymentTime"},
            "metadata[type]": {"provider": "entranceFeeBillTypeProvider", "index": 40, "field": "type"},
            "metadata[status]": {"provider": "entranceFeeBillStateProvider", "index": 50, "field": "status"},
            "attr": "number"}

    # 查询类型处理
    attr = attr_list[attrName]
    data["attr"] = attr
    if attrValue != None:
        data["attrValue"]=attrValue

    # 参数替换与部分参数数据格式处理
    data = dict(data, **kwargs)
    data["metadata[created]"] = json.dumps(data["metadata[created]"])
    data["metadata[totalPrice]"] = json.dumps(data["metadata[totalPrice]"])
    data["metadata[paymentTime]"] = json.dumps(data["metadata[paymentTime]"])
    data["metadata[type]"] = json.dumps(data["metadata[type]"])
    data["metadata[status]"] = json.dumps(data["metadata[status]"])

    # 请求接口
    res = my.useHeadersRequests(method="POST", url=url, data=data, headers=headers)
    return res

def get_OrderDetails(host="",orderId=None):
    """获取订单详情"""
    headers = dct.urlCode()
    url = host + f"/entranceFeeBill/pay/{orderId}.action"
    res = my.useHeadersRequests("get", url=url, headers=headers)
    return res

def get_icCheck(host="",ic=None):
    """进门缴费单详情页面刷卡刷卡"""
    headers = dct.urlCode()
    url = host + f"/api/jmsf/ajax/icCheck?ic={ic}"
    res = my.useHeadersRequests("get", url=url,headers=headers)
    return res

def get_city(host="",name=None):
    """进门缴费单缴费金额计算"""
    headers = dct.urlCode()
    url = host + f"/api/jmsf/ajax/city/?name={name}&query={name}"
    res = my.useHeadersRequests("get", url=url,headers=headers)
    return res

def get_calculateRes(host="",autocompletecartype=None,**kwargs):
    """缴费金额获取
    :params kwargs:
                protocolId:
pwd:
clientRedirectTag:
viewType:pay
optType:${optType}
optUrl:
correctInfo:${correctInfo}
weightType:${weightType}
id:${orderId}
goodsId:${goodsId}
number:${number}
modified:${__time(yyyy-MM-dd HH:mm:ss,)}
status:${status}
source:${source}
updateFeeItems:
correctDiscount:${correctDiscount}
totalAmount:
customerId:0
fundAccount:
ic:
customerName:
customerPhone:
payway:刷卡
plate:${plate}
autocomplete-cartype:${carTypeCode}(${carTypeName})
carTypeName:${carTypeName}
carTypeCode:${carTypeCode}
carTypeId:${carTypeId}
carTypeWeight:${carTypeWeight}
storeTareWeight:
proveType:${proveTypeCode}
grossWeight:${grossWeight}
tareWeight:${tareWeight}
weight:${grossWeight}
goodsNum:
itemWeight:
productPrice:1
unitPrice:${unitPrice}
depName:${feeDepName}
calcDepId:${feeDepId}
regionName:
regionId:0
productName:${productName}
productId:${productId}
productArea:万州区
parentId:
levelType:
originId:${originId}
tradeTypeId:${tradeTypeId}
chargeTotalAmount:
chargeTotalAmountYuan:
freezeMoneySymbol:
comparisonFreezeAmount:
created:${created}
remark:
goodsTagIds:${goodsTagIds}
shareRatio:${shareRatio}
handlingTeam:
handlingRatio:
handActualAmount:
handManageAmount:
handCollectionAmount:
receivableAmount:
categoryName:${productName}
categoryId:${productId}
driverTel:
grossWeightDate:${grossWeightDate}
tareWeightDate:${tareWeightDate}
grossPathName:
grossPathId:
tarePathId:
goodsRemark:
inGreeterName:
inGreeterId:0
outGreeterId:
sumPrice:${sumPrice}
shipperName:
shipperId:
shipperPhone:
feeDepName:
calcFeeDepId:
    """
    url = host + "/calculate/index.action"
    headers = dct.urlCode()

    data = {"protocolId": "", "pwd": "", "clientRedirectTag": "", "viewType": "pay", "optType": "optType", "optUrl": "",
            "correctInfo": "correctInfo", "weightType": "weightType", "id": "orderId", "goodsId": "goodsId",
            "number": "number", "modified": "time", "status": "status", "source": "source", "updateFeeItems": "",
            "correctDiscount": "correctDiscount", "totalAmount": "", "customerId": "0", "fundAccount": "", "ic": "",
            "customerName": "", "customerPhone": "", "payway": "刷卡", "plate": "plate",
            "autocomplete-cartype": "carTypeCode(carTypeName)", "carTypeName": "carTypeName",
            "carTypeCode": "carTypeCode", "carTypeId": "carTypeId", "carTypeWeight": "carTypeWeight",
            "storeTareWeight": "", "proveType": "proveTypeCode", "grossWeight": "grossWeight",
            "tareWeight": "tareWeight", "weight": "grossWeight", "goodsNum": "", "itemWeight": "",
            "productPrice": "1.00000", "unitPrice": "unitPrice", "depName": "feeDepName", "calcDepId": "feeDepId",
            "regionName": "", "regionId": "0", "productName": "productName", "productId": "productId",
            "productArea": "万州区", "parentId": "", "levelType": "", "originId": "originId", "tradeTypeId": "tradeTypeId",
            "chargeTotalAmount": "", "chargeTotalAmountYuan": "", "freezeMoneySymbol": "", "comparisonFreezeAmount": "",
            "created": "created", "remark": "false", "goodsTagIds": "goodsTagIds", "shareRatio": "shareRatio",
            "handlingTeam": "", "handlingRatio": "", "handActualAmount": "", "handManageAmount": "",
            "handCollectionAmount": "", "receivableAmount": "", "categoryName": "productName",
            "categoryId": "productId", "driverTel": "", "grossWeightDate": "grossWeightDate",
            "tareWeightDate": "tareWeightDate", "grossPathName": "", "grossPathId": "", "tarePathId": "",
            "goodsRemark": "", "inGreeterName": "", "inGreeterId": "0", "outGreeterId": "", "sumPrice": "sumPrice",
            "shipperName": "", "shipperId": "", "shipperPhone": "", "feeDepName": "", "calcFeeDepId": ""}
    data["autocomplete-cartype"]=autocompletecartype
    data = dict(data,**kwargs)
    print("get_calculateRes",data)
    res = my.useHeadersRequests("post", url=url,data=data,headers=headers)
    return res

def do_doPay(host="",autocompletecartype=None,fee_str="",**kwargs):
    """进门单缴费"""
    url = host + "/entranceTrade/doPay.action"
    headers = dct.urlCode()

    data = {"protocolId": "", "pwd": "{pwd}", "clientRedirectTag": "", "viewType": "pay", "optType": "{optType}",
            "optUrl": "", "correctInfo": "{correctInfo}", "weightType": "{weightType}", "id": "{orderId}",
            "goodsId": "{goodsId}", "number": "{number}", "modified": "{created}", "status": "{status}",
            "source": "{source}", "updateFeeItems": "", "correctDiscount": "{correctDiscount}",
            "totalAmount": "{totalMoney}", "customerId": "{customerId}", "fundAccount": "{accountId}", "ic": "{ic}",
            "customerName": "{customerName}", "customerPhone": "{mobile}", "payway": "刷卡", "plate": "{plate}",
            "autocomplete-cartype": "{carTypeCode}({carTypeName})", "carTypeName": "{carTypeName}",
            "carTypeCode": "{carTypeCode}", "carTypeId": "{carTypeId}", "carTypeWeight": "{carTypeWeight}",
            "storeTareWeight": "", "proveType": "{proveTypeCode}", "grossWeight": "{grossWeight}",
            "tareWeight": "{tareWeight}", "weight": "{newWeight}", "goodsNum": "", "itemWeight": "",
            "productPrice": "{productPrice}", "unitPrice": "{unitPrice}", "depName": "{feeDepName}",
            "calcDepId": "{feeDepId}", "dep": "{feeDepId}", "regionName": "{regionName}", "regionId": "{regionId}",
            "productName": "{productName}", "productId": "{productId}", "productArea": "{origin}", "parentId": "",
            "levelType": "", "originId": "{originId}", "tradeTypeId": "{tradeTypeId}",
            "chargeTotalAmount": "{totalMoney}", "chargeTotalAmountYuan": "{chargeTotalAmountYuan}",
            "freezeMoneySymbol": "{chargeTotalAmountYuan}", "comparisonFreezeAmount": "{chargeTotalAmountYuan}",
            "created": "{created}", "remark": "", "goodsTagIds": "{goodsTagIds}", "marketFlag": "{firmCode}",
            "totalMoney": "{totalMoney}", "receivable": "{receivable}", "collectionPrice": "{discountAmount}",
            "discountAmount": "{discountAmount}", "handReceivableAmount": "{handReceivableAmount}",
            "itemReceivableAmount": "{receivable}", "correctDiscount": "{correctDiscount}",  "shareRatio": "0",
            "handlingTeam": "", "handActualAmount": "0", "handManageAmount": "0", "handCollectionAmount": "0",
            "receivableAmount": "{receivable}", "categoryName": "{productName}", "categoryId": "{productId}",
            "driverTel": "", "grossWeightDate": "{grossWeightDate}", "tareWeightDate": "{tareWeightDate}",
            "grossPathName": "", "grossPathId": "", "tarePathId": "", "goodsRemark": "", "inGreeterName": "",
            "inGreeterId": "0", "outGreeterId": "", "sumPrice": "{sumPrice}", "shipperName": "", "shipperId": "",
            "shipperPhone": "", "feeDepName": "", "calcFeeDepId": "", "feeDepId": "","accountId":""}
    data["autocomplete-cartype"] = autocompletecartype
    data = dict(data, **kwargs)
    print("get_calculateRes", data)
    data_uc = jsonToUrlcode.jsonToUrlcode(data_json=data)+fee_str
    print(data_uc)
    print("================开始请求================")
    res = my.useHeadersRequests("post", url=url, data=data_uc, headers=headers)
    return res



a = listPage(host="http://test.jmsf.diligrp.com:8385",attrName="收费单号",attrValue="202108040900002")
print("listPage",a.json())
orderId = a.json()["rows"][0]["id"]
number = a.json()["rows"][0]["number"]
created = a.json()["rows"][0]["created"]
print(orderId)

# # 订单详情获取
# orderId = 3674
res = get_OrderDetails(host="http://test.jmsf.diligrp.com:8385",orderId=orderId)
# print(res.text)
unitPrice = re.findall('name="unitPrice" value="(.*?)" id',res.text)[0]

goodsId = re.findall('id="goodsId" value="(.*?)">',res.text)[0]
status = re.findall('"status" name="status" value="(.*?)">',res.text)[0]
source = re.findall('id="source" name="source" value="(.*?)">',res.text)[0]

optType = re.findall('id="optType" name="optType" value="(.*?)">',res.text)[0]
correctInfo = re.findall('d="correctInfo" name="correctInfo" value="(.*?)">',res.text)[0]
weightType = re.findall('name="weightType" id="weightType" value="(.*?)">',res.text)[0]
correctDiscount = re.findall('id="correctDiscount" name="correctDiscount" value="(.*?)">',res.text)[0]
regionId = re.findall('<option value="(.*?)" bind-name="',res.text)[0]
goodsTagIds = re.findall('<input name="goodsTagIds" type="radio" value="(.*?)" readonly  checked>',res.text)[0]
sumPrice = re.findall('<input type="hidden" name="sumPrice" value="(.*?)" id="sumPrice">',res.text)[0]
calcFeeDepId = re.findall('<input type="hidden"  name="calcFeeDepId" value="(.*?)">',res.text)[0]
tradeTypeId = re.findall('input type="hidden" class="form-control" name="tradeTypeId"  value="(.*?)" >',res.text)[0]
shareRatio = re.findall('input type="hidden" id="shareRatioVal" name="shareRatio" value="(.*?)"',res.text)[0]
regionName = re.findall('" bind-name="(.*?)"',res.text)[0]

# 用户信息获取
ic=888810032426
res = get_icCheck(host="http://test.jmsf.diligrp.com:8385",ic=ic)
print(res.text)
customerId = res.json()["data"]["aInfo"]["customerId"]
customerName = res.json()["data"]["aInfo"]["customerName"]
accountId = res.json()["data"]["aInfo"]["accountId"]
mobile = res.json()["data"]["aInfo"]["mobile"]

# 省市区获取
res = get_city(host="http://test.jmsf.diligrp.com:8385",name="万州")
print(res.text)
originId = res.json()["suggestions"][0]["id"]
parentId = res.json()["suggestions"][0]["parentId"]
value = res.json()["suggestions"][0]["value"]

# 获取缴费金额
plate="川B00002"
host="http://test.jmsf.diligrp.com:8385"
modified=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
carTypeName="板车"
carTypeCode = "003"
carTypeId = "53"
carTypeWeight = "333"
proveTypeCode = "665"
proveType = proveTypeCode
grossWeight="353"
newWeight="20"
tareWeight="333"
depName="水果部"
feeDepId="53"
productName="蔬菜"
productId="14152"
grossWeightDate=created
tareWeightDate=created
weight=grossWeight
weight=weight
calcDepId=feeDepId
categoryName=productName
categoryId=productId

autocompletecartype = f"{carTypeCode}({carTypeName})"
print(autocompletecartype)

res = get_calculateRes(host=host,autocompletecartype=autocompletecartype,optType=optType,correctInfo=correctInfo,
                       weightType=weightType,id=orderId,goodsId=goodsId,number=number,modified=modified,status=status,
                       source=source,correctDiscount=correctDiscount,plate=plate,carTypeName=carTypeName,carTypeCode=carTypeCode,
                       carTypeId=carTypeId,carTypeWeight=carTypeWeight,proveType=proveType,grossWeight=grossWeight,
                       newWeight=newWeight,tareWeight=tareWeight,unitPrice=unitPrice,depName=depName,productName=productName,
                       productId=productId,originId=originId,tradeTypeId=tradeTypeId,created=created,goodsTagIds=goodsTagIds,
                       shareRatio=shareRatio,categoryName=categoryName,categoryId=categoryId,grossWeightDate=grossWeightDate,
                       tareWeightDate=tareWeightDate,sumPrice=sumPrice,calcDepId=calcDepId,weight=weight)
# print(res.text)
# backSkinTwo = re.findall('name="backSkinTwo" value="(.*?)" >',res.text)[0]
# 缴费信息
totalMoney = re.findall('name="totalMoney" value="(.*?)">',res.text)[0]
discountAmount = re.findall('name="discountAmount" value="(.*?)">',res.text)[0]
collectionPrice = re.findall('" name="collectionPrice" value="(.*?)">',res.text)[0]
handReceivableAmount = re.findall('name="handReceivableAmount" value="(.*?)">',res.text)[0]
correctDiscount = re.findall('id="correctDiscount" name="correctDiscount" value="(.*?)">',res.text)[0]
billItemCheckIds = re.findall('" name="billItemCheckIds" value="(.*?)" ',res.text)[0]
billItemCheckIdsV = re.findall('" maxlength="15" data-old="(.*?)"',res.text)[0]
receivable = re.findall('id="creceivableLong" name="receivable" value="(.*?)">',res.text)[0]


soup = BeautifulSoup(res.text, "html.parser")
# 查找dl标签class为包含'ui-font-'字符的所有dl标签
fee_str = "correctDiscount=1&billItems=&billItemsDic="
for tag in soup.findAll("div", class_="d-flex align-items-center"):
    print("=============================================")
    c = tag.findAll("input")
    for i in c:
        print(i)
        print(i.get("name"))
        if i.get("name") != None:
            fee_str = fee_str + "&" + i.get("name") + "=" + i.get("value")
print(fee_str)

pwd = "111111"
id = orderId
totalAmount = totalMoney
customerPhone=mobile
productPrice="1.00000"
dep=feeDepId
productArea = "重庆,重庆市,万州区"
chargeTotalAmount = totalMoney
chargeTotalAmountYuan = "9"
chargeTotalAmountYuan= chargeTotalAmountYuan
freezeMoneySymbol =chargeTotalAmountYuan
comparisonFreezeAmount = chargeTotalAmountYuan
modified = created
firmCode = "9"
marketFlag=firmCode
collectionPrice=discountAmount
itemReceivableAmount=receivable
receivableAmount=receivable
tareWeightDate=tareWeightDate
aa = do_doPay(host=host,autocompletecartype=autocompletecartype,fee_str=fee_str,pwd=pwd,optType=optType,
              weightType=weightType,id=id,goodsId=goodsId,number=number,created=created,status=status,source=source,
              correctDiscount=correctDiscount,totalAmount=totalAmount,customerId=customerId,fundAccount=accountId,
              accountId=accountId,ic=ic,customerName=customerName,customerPhone=customerPhone,plate=plate,
              carTypeName=carTypeName,carTypeCode=carTypeCode,carTypeId=carTypeId,carTypeWeight=carTypeWeight,
              proveType=proveType,grossWeight=grossWeight,tareWeight=tareWeight,weight=weight,productPrice=productPrice,
              unitPrice=unitPrice,depName=depName,calcDepId=calcDepId,dep=dep,regionName=regionName,regionId=regionId,
              productName=productName,productId=productId,productArea=productArea,originId=originId,
              tradeTypeId=tradeTypeId,correctInfo=correctInfo,chargeTotalAmount=chargeTotalAmount,
              freezeMoneySymbol=freezeMoneySymbol,comparisonFreezeAmount=comparisonFreezeAmount,modified=modified,
              goodsTagIds=goodsTagIds,marketFlag=marketFlag,totalMoney=totalMoney,receivable=receivable,
              collectionPrice=collectionPrice,discountAmount=discountAmount,handReceivableAmount=handReceivableAmount,
              itemReceivableAmount=itemReceivableAmount,receivableAmount=receivableAmount,categoryName=categoryName,
              categoryId=carTypeId,grossWeightDate=grossWeightDate,tareWeightDate=tareWeightDate,sumPrice=sumPrice)

print(res.text)