Commit ba77adfe2f1f4762305739e0579b6a22d89dbe82

Authored by liujiqiang
1 parent 7f4d4cfe

批号创建脚本

commons/api/hg/CheckIn/CheckInMoreGoods.py 0 → 100644
  1 +# -*- coding: utf-8 -*-
  2 +
  3 +# @Time : 2021/9/8 14:17
  4 +# @Author : Ljq
  5 +# @File : CheckIn.py
  6 +# @Software: PyCharm
  7 +
  8 +"""
  9 +创建进门登记单
  10 +"""
  11 +
  12 +import json,time,random,re
  13 +from commons.scripts import dealContentType as dct
  14 +from commons.scripts import jsonToUrlCode
  15 +from commons.scripts import replaceJsonData as rJD
  16 +import urllib.parse
  17 +from commons.MySession import sessionHg
  18 +
  19 +host = "http://test.gateway.diligrp.com:8285"
  20 +
  21 +def get_simpleInfo(session=None,host=None,ic=None):
  22 + url = host+"/card-web/accountQuery/simpleInfo.action"
  23 + headers={}
  24 + data={"cardNo":ic}
  25 + res = session.useHeadersRequests(method="GET",url=url,params=data,headers=headers)
  26 + return res
  27 +
  28 +
  29 +def get_tree(session=None,host=None,**kwargs):
  30 + "商品信息获取"
  31 + url = host+"/assets-service/api/cusCategory/getTree"
  32 + headers = dct.jsonCode()
  33 + data={"marketId":15,"keyword":"西瓜","state":1}
  34 + data = dict(data,**kwargs)
  35 + res = session.useHeadersRequests(method="post",url=url,data=json.dumps(data),headers=headers)
  36 + return res
  37 +
  38 +
  39 +def get_cityCode(session=None,host=None,allLevelKeyword="万州"):
  40 + """"""
  41 + url = host+"/assets-service/api/city/listByKeywordsWithCityCode"
  42 + headers = dct.jsonCode()
  43 + data={"allLevelKeyword":allLevelKeyword}
  44 + res = session.useHeadersRequests(method="post",url=url,data=json.dumps(data),headers=headers)
  45 + return res
  46 +
  47 +
  48 +def get_searchArea(session=None,host=None,**kwargs):
  49 + """"""
  50 + url = host+"/assets-service/api/district/search"
  51 + headers = dct.jsonCode()
  52 + data={"marketId":15,"nameLike":"西区"}
  53 + data = dict(data,**kwargs)
  54 + res = session.useHeadersRequests(method="post",url=url,data=json.dumps(data),headers=headers)
  55 + return res
  56 +
  57 +
  58 +def get_chargeItem(session=None,host=None,**kwargs):
  59 + """获取费用项"""
  60 + url = host+"/hg-trading/api/businessChargeItem/listBusinessChargeItem"
  61 + headers = dct.jsonCode()
  62 + data={"marketId":15,"businessType":"501"}
  63 + data = dict(data,**kwargs)
  64 + res = session.useHeadersRequests(method="post",url=url,data=json.dumps(data),headers=headers)
  65 + return res
  66 +
  67 +
  68 +def get_queryFee(session=None,host=None,**kwargs):
  69 + """根据费用项获取费用"""
  70 + url = host+"/dili-rule/api/chargeRule/queryFee"
  71 + headers = dct.jsonCode()
  72 + data={"businessType":"501","chargeItem":520,"marketId":15}
  73 + data = dict(data,**kwargs)
  74 + res = session.useHeadersRequests(method="post",url=url,data=json.dumps(data),headers=headers)
  75 + return res
  76 +
  77 +def returnDetailChild(**kwargs):
  78 + child_template = {"id": 0, "areaId": 272, "areaName": "西区", "quantity": 0, "productId": 754107, "registerRecordId": 0,
  79 + "remark": None, "weight": 100, "weightType": 0, "created": None, "createdById": 0,
  80 + "createdByName": None, "createdByDepartmentId": 0, "createdByDepartmentName": None,
  81 + "registerCertificateList": None, "product": None, "registerCertificateDtoList": None,
  82 + "productDto": {"id": 0, "originId": 500101, "originName": "万州区", "pieceWeight": 0,
  83 + "categoryId": 754107, "categoryCode": "754107", "categoryName": "葡萄",
  84 + "created": None}}
  85 + child_template = rJD.replaceJsonData(json=child_template, data=kwargs)
  86 + return child_template
  87 +
  88 +
  89 +
  90 +def save_registerRecord(session=None,host=None,registerDetailDtoList=None,**kwargs):
  91 + """生成登记单并缴费"""
  92 + url = host+"/hg-trading/api/registerRecord/save"
  93 + headers = dct.jsonCode()
  94 + data = {"accountId": 107796, "cardNo": "888800010591", "customerId": 142000, "customerCode": "00131702",
  95 + "customerName": "史东晶", "fixedphoneNumber": None, "mobilephoneNumber": "18080008020",
  96 + "identityCardAddress": "", "identityCardNo": "110101202109024587", "identityCardType": "ID",
  97 + "registerDetailDtoList": [
  98 + {"id": 0, "areaId": 272, "areaName": "西区", "quantity": 0, "productId": 754107, "registerRecordId": 0,
  99 + "remark": None, "weight": 100, "weightType": 0, "created": None, "createdById": 0,
  100 + "createdByName": None, "createdByDepartmentId": 0, "createdByDepartmentName": None,
  101 + "registerCertificateList": None, "product": None, "registerCertificateDtoList": None,
  102 + "productDto": {"id": 0, "originId": 500101, "originName": "万州区", "pieceWeight": 0,
  103 + "categoryId": 754107, "categoryCode": "754107", "categoryName": "葡萄",
  104 + "created": None}}],
  105 + "registerFeeDtoList": [
  106 + {"id": 0, "actualFee": 200.0, "receivableFee": 1300.0, "discountFee": 1100.0, "registerRecordId": 0,
  107 + "payStatus": 0, "chargeItemName": "其他收费", "chargeType": 1, "chargeItemId": 518, "registerFeeType": 999,
  108 + "created": None, "createdById": 0, "createdByName": None, "settleDate": None, "isBehalf": 0,
  109 + "registerLoadingFeeExtDto": None}], "tradePassword": "111111"}
  110 + data = rJD.replaceJsonData(json=data,data=kwargs)
  111 + data["registerDetailDtoList"] = registerDetailDtoList
  112 + print(data)
  113 + res = session.useHeadersRequests(method="post",url=url,data=json.dumps(data),headers=headers)
  114 + return res
  115 +
  116 +def create_registerRecord(session=None,host=None,ic="888800010591",goodsName="葡萄",nameLike="西区",
  117 + allLevelKeyword="万州",tradePassword="111111",weight=100):
  118 + """创建进门登记单并缴费"""
  119 + # 获取费用信息
  120 + marketId = session.userInfo["data"]["user"]["firmId"]
  121 + res = get_chargeItem(session=session,host=host,marketId=marketId)
  122 + chargeItemId = [i["id"] for i in res.json()["data"] if i["chargeItem"] == "其他收费"][0]
  123 + chargeItemIdChild = [i["id"] for i in res.json()["data"] if "parentId" in i.keys() and i["parentId"] == chargeItemId][0]
  124 +
  125 + # 获取客户信息
  126 + resSimpleInfo = get_simpleInfo(session=session,host=host,ic=ic)
  127 + accountId = resSimpleInfo.json()["data"]["accountInfo"]["accountId"]
  128 + cardNo = resSimpleInfo.json()["data"]["accountInfo"]["cardNo"]
  129 + customerId = resSimpleInfo.json()["data"]["accountInfo"]["customerId"]
  130 + customerCode = resSimpleInfo.json()["data"]["accountInfo"]["customerCode"]
  131 + customerName = resSimpleInfo.json()["data"]["accountInfo"]["customerName"]
  132 + mobilephoneNumber = resSimpleInfo.json()["data"]["accountInfo"]["customerContactsPhone"]
  133 + identityCardNo = resSimpleInfo.json()["data"]["accountInfo"]["customerCertificateNumber"]
  134 +
  135 + # # 获取商品信息
  136 + # resTree = get_tree(session=session,host=host,keyword=goodsName,marketId=marketId)
  137 + # productId = resTree.json()["data"][0]["id"]
  138 + # categoryId = productId
  139 + # categoryCode = productId
  140 + # categoryName = resTree.json()["data"][0]["name"]
  141 +
  142 + # 获取产地信息
  143 + resCity = get_cityCode(session=session,host=host,allLevelKeyword=allLevelKeyword)
  144 + originId = resCity.json()["data"][0]["id"]
  145 + originName = resCity.json()["data"][0]["name"]
  146 +
  147 + # 获取区域信息
  148 + resArea = get_searchArea(session=session,host=host,nameLike=nameLike,marketId=marketId)
  149 + areaId = resArea.json()["data"][0]["id"]
  150 + areaName = resArea.json()["data"][0]["name"]
  151 +
  152 + registerDetailDtoList = []
  153 +
  154 + for i in [a for a in goodsName.split(",") if a != None and a != ""]:
  155 + # 获取商品信息
  156 + resTree = get_tree(session=session, host=host, keyword=i, marketId=marketId)
  157 + print(resTree.json())
  158 + productId = resTree.json()["data"][0]["id"]
  159 + categoryId = productId
  160 + categoryCode = productId
  161 + categoryName = resTree.json()["data"][0]["name"]
  162 + child_item = returnDetailChild(productId=productId,categoryId=categoryId,categoryCode=categoryCode,
  163 + categoryName=categoryName,areaId=areaId,areaName=areaName,weight=weight,
  164 + originId=originId,originName=originName)
  165 + registerDetailDtoList.append(child_item)
  166 +
  167 + # 采用其他收费时获取应收金额,优惠金额,实际金额
  168 + receivableFee = int(get_queryFee(session=session,host=host,chargeItem=chargeItemId,marketId=marketId).json()["data"]["totalFee"])*100
  169 + discountFee = int(get_queryFee(session=session, host=host, chargeItem=chargeItemIdChild,marketId=marketId).json()["data"]["totalFee"])*100
  170 + actualFee = receivableFee - discountFee
  171 +
  172 + # 创建进门登记单并缴费
  173 + resSave = save_registerRecord(session=session, host=host, registerDetailDtoList=registerDetailDtoList,weight=weight, tradePassword=tradePassword,
  174 + chargeItemId=chargeItemId, accountId=accountId, cardNo=cardNo, customerId=customerId,
  175 + customerCode=customerCode, customerName=customerName,
  176 + mobilephoneNumber=mobilephoneNumber, identityCardNo=identityCardNo,originId=originId, originName=originName, areaId=areaId,
  177 + areaName=areaName, receivableFee=receivableFee, discountFee=discountFee,
  178 + actualFee=actualFee)
  179 + return resSave
  180 +
  181 +
  182 +# res = create_registerRecord(session=sessionHg,ic="888800010592",host=host,goodsName="苹果,葡萄",allLevelKeyword="万州",
  183 +# nameLike="东区",tradePassword="111111",weight=51)
  184 +# print(res.text)
  185 +# print(res.json()["data"]["batchCode"])
0 186 \ No newline at end of file
... ...
report/test.log
1   -[2021-09-15 10:33:33] [INFO] : ======================================================================================
2   -[2021-09-15 10:33:33] [INFO] : http://test.uap.diligrp.com/api/authenticationApi/loginWeb
3   -[2021-09-15 10:33:33] [INFO] : http://10.28.12.150:80/api/authenticationApi/loginWeb
4   -{'data': None, 'json': {'userName': '111222', 'password': 'DQXEjlThXAkerQ5AdTWgzBb+S7lpE99qU2rcDnKgA4TPFIMi5uBo7qCC9W+F+/+LbFOIYcdDPrNR5qfdDDb5B7cZaVfqDT4HnJcGk0O2iI44pPAEVicie2h3neKfDfgwmAaSiynHplT/C2AHNWqeY47/Q49d0VEWtgqwdCRy9bQ='}, 'headers': {'Content-Type': 'text/plain;charset=utf-8', 'Host': 'test.uap.diligrp.com', 'Content-Length': '209', 'Expect': '100-continue'}}
5   -
6   -[2021-09-15 10:33:34] [INFO] : ======================================================================================
7   -[2021-09-15 10:33:34] [INFO] : http://test.uap.diligrp.com/login/login.action
8   -[2021-09-15 10:33:34] [INFO] : http://10.28.12.150:80/login/login.action
  1 +[2021-09-29 10:29:40] [INFO] : ======================================================================================
  2 +[2021-09-29 10:29:40] [INFO] : http://test.uap.diligrp.com/api/authenticationApi/loginWeb
  3 +[2021-09-29 10:29:40] [INFO] : http://10.28.12.150:80/api/authenticationApi/loginWeb
  4 +{'data': None, 'json': {'userName': '111222', 'password': 'IWOpywOAiznF9DG4JYfr8AYelY4t93yAuXw4eepmGh2+Ydd5atUFcrSiqKfA8d1VmVDUsTRUyvZ4D/mqtyGmwCTPPfdFwaNVk6a6nB+jLGL3IZI79UrSwb5II8s86lLX7CXMTK1VYugQkL1Rm+GaQ5xZo95+aVPSLl0vq8460iQ='}, 'headers': {'Content-Type': 'text/plain;charset=utf-8', 'Host': 'test.uap.diligrp.com', 'Content-Length': '209', 'Expect': '100-continue'}}
  5 +
  6 +[2021-09-29 10:29:40] [INFO] : ======================================================================================
  7 +[2021-09-29 10:29:40] [INFO] : http://test.uap.diligrp.com/login/login.action
  8 +[2021-09-29 10:29:40] [INFO] : http://10.28.12.150:80/login/login.action
9 9 {'data': b'userName=111222&password=111111', 'json': None, 'headers': {'Host': 'test.uap.diligrp.com', 'Connection': 'keep-alive', 'Content-Length': '33', 'Cache-Control': 'max-age=0', 'Upgrade-Insecure-Requests': '1', 'Origin': 'http://test.uap.diligrp.com', 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/90.0.4430.212Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'Referer': 'http://test.uap.diligrp.com/login/index.html', 'Accept-Encoding': 'gzip,deflate', 'Accept-Language': 'zh-CN,zh-TW;q=0.9,zh;q=0.8,en;q=0.7', 'Cookie': 'UAP_accessToken=;UAP_refreshToken=;UAP_loginPath='}, 'allow_redirects': False}
10 10  
11   -[2021-09-15 10:33:34] [INFO] : ======================================================================================
12   -[2021-09-15 10:33:34] [INFO] : http://test.gateway.diligrp.com:8285/hg-trading/api/businessChargeItem/listBusinessChargeItem
  11 +[2021-09-29 10:29:41] [INFO] : ======================================================================================
  12 +[2021-09-29 10:29:41] [INFO] : http://test.gateway.diligrp.com:8285/hg-trading/api/businessChargeItem/listBusinessChargeItem
13 13 {"marketId": 15, "businessType": "501"}
14 14 {}
15 15  
16   -[2021-09-15 10:33:34] [INFO] : ======================================================================================
17   -[2021-09-15 10:33:34] [INFO] : http://test.gateway.diligrp.com:8285/card-web/accountQuery/simpleInfo.action
  16 +[2021-09-29 10:29:41] [INFO] : ======================================================================================
  17 +[2021-09-29 10:29:41] [INFO] : http://test.gateway.diligrp.com:8285/card-web/accountQuery/simpleInfo.action
18 18 None
19 19 {'params': {'cardNo': '888800010591'}}
20 20  
21   -[2021-09-15 10:33:34] [INFO] : ======================================================================================
22   -[2021-09-15 10:33:34] [INFO] : http://test.gateway.diligrp.com:8285/assets-service/api/cusCategory/getTree
23   -{"marketId": 15, "keyword": "\u8461\u8404", "state": 1}
24   -{}
25   -
26   -[2021-09-15 10:33:34] [INFO] : ======================================================================================
27   -[2021-09-15 10:33:34] [INFO] : http://test.gateway.diligrp.com:8285/assets-service/api/city/listByKeywordsWithCityCode
  21 +[2021-09-29 10:29:41] [INFO] : ======================================================================================
  22 +[2021-09-29 10:29:41] [INFO] : http://test.gateway.diligrp.com:8285/assets-service/api/city/listByKeywordsWithCityCode
28 23 {"allLevelKeyword": "\u4e07\u5dde"}
29 24 {}
30 25  
31   -[2021-09-15 10:33:34] [INFO] : ======================================================================================
32   -[2021-09-15 10:33:34] [INFO] : http://test.gateway.diligrp.com:8285/assets-service/api/district/search
  26 +[2021-09-29 10:29:41] [INFO] : ======================================================================================
  27 +[2021-09-29 10:29:41] [INFO] : http://test.gateway.diligrp.com:8285/assets-service/api/district/search
33 28 {"marketId": 15, "nameLike": "\u897f\u533a"}
34 29 {}
35 30  
36   -[2021-09-15 10:33:34] [INFO] : ======================================================================================
37   -[2021-09-15 10:33:34] [INFO] : http://test.gateway.diligrp.com:8285/dili-rule/api/chargeRule/queryFee
  31 +[2021-09-29 10:29:41] [INFO] : ======================================================================================
  32 +[2021-09-29 10:29:41] [INFO] : http://test.gateway.diligrp.com:8285/assets-service/api/cusCategory/getTree
  33 +{"marketId": 15, "keyword": "\u8461\u8404", "state": 1}
  34 +{}
  35 +
  36 +[2021-09-29 10:29:41] [INFO] : ======================================================================================
  37 +[2021-09-29 10:29:41] [INFO] : http://test.gateway.diligrp.com:8285/dili-rule/api/chargeRule/queryFee
38 38 {"businessType": "501", "chargeItem": 518, "marketId": 15}
39 39 {}
40 40  
41   -[2021-09-15 10:33:34] [INFO] : ======================================================================================
42   -[2021-09-15 10:33:34] [INFO] : http://test.gateway.diligrp.com:8285/dili-rule/api/chargeRule/queryFee
  41 +[2021-09-29 10:29:41] [INFO] : ======================================================================================
  42 +[2021-09-29 10:29:41] [INFO] : http://test.gateway.diligrp.com:8285/dili-rule/api/chargeRule/queryFee
43 43 {"businessType": "501", "chargeItem": 520, "marketId": 15}
44 44 {}
45 45  
46   -[2021-09-15 10:33:34] [INFO] : ======================================================================================
47   -[2021-09-15 10:33:34] [INFO] : http://test.gateway.diligrp.com:8285/hg-trading/api/registerRecord/save
48   -{"accountId": 107796, "cardNo": "888800010591", "customerId": 142000, "customerCode": "00131702", "customerName": "\u53f2\u4e1c\u6676", "fixedphoneNumber": null, "mobilephoneNumber": "18080008020", "identityCardAddress": "", "identityCardNo": "110101202109024587", "identityCardType": "ID", "registerDetailDtoList": [{"id": 0, "areaId": 272, "areaName": "\u897f\u533a", "quantity": 0, "productId": 754107, "registerRecordId": 0, "remark": null, "weight": 100, "weightType": 0, "created": null, "createdById": 0, "createdByName": null, "createdByDepartmentId": 0, "createdByDepartmentName": null, "registerCertificateList": null, "product": null, "registerCertificateDtoList": null, "productDto": {"id": 0, "originId": 500101, "originName": "\u4e07\u5dde\u533a", "pieceWeight": 0, "categoryId": 754107, "categoryCode": 754107, "categoryName": "\u8461\u8404", "created": null}}], "registerFeeDtoList": [{"id": 0, "actualFee": 200, "receivableFee": 1300, "discountFee": 1100, "registerRecordId": 0, "payStatus": 0, "chargeItemName": "\u5176\u4ed6\u6536\u8d39", "chargeType": 1, "chargeItemId": 518, "registerFeeType": 999, "created": null, "createdById": 0, "createdByName": null, "settleDate": null, "isBehalf": 0, "registerLoadingFeeExtDto": null}], "tradePassword": "111111"}
  46 +[2021-09-29 10:29:41] [INFO] : ======================================================================================
  47 +[2021-09-29 10:29:41] [INFO] : http://test.gateway.diligrp.com:8285/hg-trading/api/registerRecord/save
  48 +{"accountId": 107796, "cardNo": "888800010591", "customerId": 142000, "customerCode": "00131702", "customerName": "\u53f2\u4e1c\u6676", "fixedphoneNumber": null, "mobilephoneNumber": "18080008020", "identityCardAddress": "", "identityCardNo": "110101202109024587", "identityCardType": "ID", "registerDetailDtoList": [{"id": 0, "areaId": 272, "areaName": "\u897f\u533a", "quantity": 0, "productId": 754107, "registerRecordId": 0, "remark": null, "weight": "50", "weightType": 0, "created": null, "createdById": 0, "createdByName": null, "createdByDepartmentId": 0, "createdByDepartmentName": null, "registerCertificateList": null, "product": null, "registerCertificateDtoList": null, "productDto": {"id": 0, "originId": 500101, "originName": "\u4e07\u5dde\u533a", "pieceWeight": 0, "categoryId": 754107, "categoryCode": 754107, "categoryName": "\u8461\u8404", "created": null}}], "registerFeeDtoList": [{"id": 0, "actualFee": 1500, "receivableFee": 1500, "discountFee": 0, "registerRecordId": 0, "payStatus": 0, "chargeItemName": "\u5176\u4ed6\u6536\u8d39", "chargeType": 1, "chargeItemId": 518, "registerFeeType": 999, "created": null, "createdById": 0, "createdByName": null, "settleDate": null, "isBehalf": 0, "registerLoadingFeeExtDto": null}], "tradePassword": "111111"}
49 49 {}
50 50  
... ...
testcase/hg/createBatch/__init__.py 0 → 100644
  1 +# -*- coding: utf-8 -*-
  2 +
  3 +# @Time : 2021/9/29 10:09
  4 +# @Author : Ljq
  5 +# @File : __init__.py.py
  6 +# @Software: PyCharm
  7 +
  8 +"""
  9 +
  10 +"""
... ...
testcase/hg/createBatch/createBatch.py 0 → 100644
  1 +# -*- coding: utf-8 -*-
  2 +
  3 +# @Time : 2021/9/29 10:11
  4 +# @Author : Ljq
  5 +# @File : createBatch.py
  6 +# @Software: PyCharm
  7 +
  8 +"""
  9 +
  10 +"""
  11 +
  12 +import sys
  13 +from commons.api.hg.CheckIn import CheckInMoreGoods as CIMG
  14 +from commons.MySession import sessionHg
  15 +
  16 +
  17 +
  18 +class createBat(object):
  19 + def __init__(self):
  20 + self.host = "http://test.gateway.diligrp.com:8285"
  21 + data = {i.split("=")[0]: i.split("=")[1] for i in sys.argv if "=" in i}
  22 + if "ic" not in data.keys() or data["ic"] == "":
  23 + self.ic = "888800010591"
  24 + if "goodsName" not in data.keys() or data["goodsName"] == "":
  25 + self.goodsName = "葡萄"
  26 + if "allLevelKeyword" not in data.keys() or data["allLevelKeyword"] == "":
  27 + self.allLevelKeyword = "万州"
  28 + if "nameLike" not in data.keys() or data["nameLike"] == "":
  29 + self.nameLike = "西区"
  30 + if "tradePassword" not in data.keys() or data["tradePassword"] == "":
  31 + self.tradePassword = "111111"
  32 + if "weight" not in data.keys() or data["weight"] == "":
  33 + self.weight = "50"
  34 +
  35 + def main(self):
  36 + res = CIMG.create_registerRecord(session=sessionHg,ic=self.ic,host=self.host,goodsName=self.goodsName,
  37 + allLevelKeyword=self.allLevelKeyword,nameLike=self.nameLike,
  38 + tradePassword=self.tradePassword,weight=self.weight)
  39 + print(res.text)
  40 + print(res.json()["data"]["batchCode"])
  41 +
  42 +
  43 +createBat = createBat().main()
0 44 \ No newline at end of file
... ...