Commit 21bba349b5c0b02a045730d45b816fe97b9933b3

Authored by liujiqiang
1 parent 47c77a67

批号结算-测试用例新增

commons/MySession.py
@@ -146,9 +146,9 @@ class mysession(requests.Session): @@ -146,9 +146,9 @@ class mysession(requests.Session):
146 :param data:接口数据 146 :param data:接口数据
147 :kwargs:其他requests.request()支持参数可以直接传递 147 :kwargs:其他requests.request()支持参数可以直接传递
148 """ 148 """
149 - print(url)  
150 - # print(headers)  
151 - print(data) 149 + # print(url)
  150 + # # print(headers)
  151 + # print(data)
152 log.info("{0:=^86}".format('')) 152 log.info("{0:=^86}".format(''))
153 log.info("{}\n{}\n{}\n".format(url, data, kwargs)) 153 log.info("{}\n{}\n{}\n".format(url, data, kwargs))
154 if "gateway" in url: 154 if "gateway" in url:
commons/api/hg/settlement/batchSettlement.py
@@ -8,3 +8,27 @@ @@ -8,3 +8,27 @@
8 """ 8 """
9 批号结算页面 9 批号结算页面
10 """ 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 settle_query(session=None,host=None,batchCode=None):
  22 + """
  23 + 登记单状态变更
  24 + :param batchCode:等级单号
  25 + :param _t:时间戳
  26 + """
  27 + url = host+"/hg-trading/api/settle/query"
  28 + headers = {}
  29 + data = {"batchCode":str(batchCode)}
  30 + res = session.useHeadersRequests(method="GET",url=url,params=data,headers=headers)
  31 + return res
  32 +
  33 +# res = settle_query(session=sessionHg,host=host,batchCode="2109000319")
  34 +# print(res.text)
11 \ No newline at end of file 35 \ No newline at end of file
commons/api/hg/settlement/sellingGoods.py
@@ -146,6 +146,8 @@ def createAndTrade(session=None,host=None,**kwargs): @@ -146,6 +146,8 @@ def createAndTrade(session=None,host=None,**kwargs):
146 {"type": 2, "chargeItemId": 522, "chargeItemName": "卖家手续费", "amount": 610.0}, 146 {"type": 2, "chargeItemId": 522, "chargeItemName": "卖家手续费", "amount": 610.0},
147 {"type": 2, "chargeItemId": 527, "chargeItemName": "卖家仓储服务费", "amount": 522.00}]}]} 147 {"type": 2, "chargeItemId": 527, "chargeItemName": "卖家仓储服务费", "amount": 522.00}]}]}
148 data = rJD.replaceJsonData(json=data,data=kwargs) 148 data = rJD.replaceJsonData(json=data,data=kwargs)
  149 + data["orderItemList"][0]["feeItemList"]=kwargs["feeItemList"]
  150 + print("data",data)
149 res = session.useHeadersRequests(method="post",url=url,data=json.dumps(data),headers=headers) 151 res = session.useHeadersRequests(method="post",url=url,data=json.dumps(data),headers=headers)
150 return res 152 return res
151 153
report/test.log
1 -[2021-09-13 11:09:46] [INFO] : ======================================================================================  
2 -[2021-09-13 11:09:46] [INFO] : http://test.uap.diligrp.com/api/authenticationApi/loginWeb  
3 -[2021-09-13 11:09:46] [INFO] : http://10.28.12.150:80/api/authenticationApi/loginWeb  
4 -{'data': None, 'json': {'userName': '111222', 'password': 'DRocye2VphU1vrI4H1ZDG5qpLaH+J4W433PIxukTeIDZeOmpK1CN+rXZwea+mhasHAxVtB1D8Vvgr23aMl8M/iQ4fyvpDREfekEkegwMlq4xK7WgvVkMHpRCWYkf1P6kv3NoyCuOMtq+dHDJM755kXXwfTzKouXrUUOU9Nq3IcI='}, 'headers': {'Content-Type': 'text/plain;charset=utf-8', 'Host': 'test.uap.diligrp.com', 'Content-Length': '209', 'Expect': '100-continue'}}  
5 -  
6 -[2021-09-13 11:09:46] [INFO] : ======================================================================================  
7 -[2021-09-13 11:09:46] [INFO] : http://test.uap.diligrp.com/login/login.action  
8 -[2021-09-13 11:09:46] [INFO] : http://10.28.12.150:80/login/login.action 1 +[2021-09-14 11:09:05] [INFO] : ======================================================================================
  2 +[2021-09-14 11:09:05] [INFO] : http://test.uap.diligrp.com/api/authenticationApi/loginWeb
  3 +[2021-09-14 11:09:05] [INFO] : http://10.28.12.150:80/api/authenticationApi/loginWeb
  4 +{'data': None, 'json': {'userName': '111222', 'password': 'EmGtRPV6kawgKe9lnvhrzQftIM9vpxXcsnKUuZBj0L1fH+Lr270OPPUkT+YI69D87J9V/Vl/Z7XqpH9+qETijhO6mWjGDoxxqbhAAvc+fOxgPpdvSwQ7P0DE9JkOA5r4+mKbN7DhBa69i0RkO5MkOUouUbXYdoUY+3jfXaZT0jI='}, 'headers': {'Content-Type': 'text/plain;charset=utf-8', 'Host': 'test.uap.diligrp.com', 'Content-Length': '209', 'Expect': '100-continue'}}
  5 +
  6 +[2021-09-14 11:09:05] [INFO] : ======================================================================================
  7 +[2021-09-14 11:09:05] [INFO] : http://test.uap.diligrp.com/login/login.action
  8 +[2021-09-14 11:09:05] [INFO] : http://10.28.12.150:80/login/login.action
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} 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-13 11:09:46] [INFO] : ======================================================================================  
12 -[2021-09-13 11:09:46] [INFO] : http://test.gateway.diligrp.com:8285/hg-trading/api/businessChargeItem/listBusinessChargeItem 11 +[2021-09-14 11:09:05] [INFO] : ======================================================================================
  12 +[2021-09-14 11:09:05] [INFO] : http://test.gateway.diligrp.com:8285/hg-trading/api/businessChargeItem/listBusinessChargeItem
13 {"marketId": 15, "businessType": "501"} 13 {"marketId": 15, "businessType": "501"}
14 {} 14 {}
15 15
16 -[2021-09-13 11:09:46] [INFO] : ======================================================================================  
17 -[2021-09-13 11:09:46] [INFO] : http://test.gateway.diligrp.com:8285/card-web/accountQuery/simpleInfo.action 16 +[2021-09-14 11:09:05] [INFO] : ======================================================================================
  17 +[2021-09-14 11:09:05] [INFO] : http://test.gateway.diligrp.com:8285/card-web/accountQuery/simpleInfo.action
18 None 18 None
19 {'params': {'cardNo': '888800010591'}} 19 {'params': {'cardNo': '888800010591'}}
20 20
21 -[2021-09-13 11:09:46] [INFO] : ======================================================================================  
22 -[2021-09-13 11:09:46] [INFO] : http://test.gateway.diligrp.com:8285/assets-service/api/cusCategory/getTree 21 +[2021-09-14 11:09:05] [INFO] : ======================================================================================
  22 +[2021-09-14 11:09:05] [INFO] : http://test.gateway.diligrp.com:8285/assets-service/api/cusCategory/getTree
23 {"marketId": 15, "keyword": "\u8461\u8404", "state": 1} 23 {"marketId": 15, "keyword": "\u8461\u8404", "state": 1}
24 {} 24 {}
25 25
26 -[2021-09-13 11:09:46] [INFO] : ======================================================================================  
27 -[2021-09-13 11:09:46] [INFO] : http://test.gateway.diligrp.com:8285/assets-service/api/city/listByKeywordsWithCityCode 26 +[2021-09-14 11:09:06] [INFO] : ======================================================================================
  27 +[2021-09-14 11:09:06] [INFO] : http://test.gateway.diligrp.com:8285/assets-service/api/city/listByKeywordsWithCityCode
28 {"allLevelKeyword": "\u4e07\u5dde"} 28 {"allLevelKeyword": "\u4e07\u5dde"}
29 {} 29 {}
30 30
31 -[2021-09-13 11:09:46] [INFO] : ======================================================================================  
32 -[2021-09-13 11:09:46] [INFO] : http://test.gateway.diligrp.com:8285/assets-service/api/district/search 31 +[2021-09-14 11:09:06] [INFO] : ======================================================================================
  32 +[2021-09-14 11:09:06] [INFO] : http://test.gateway.diligrp.com:8285/assets-service/api/district/search
33 {"marketId": 15, "nameLike": "\u897f\u533a"} 33 {"marketId": 15, "nameLike": "\u897f\u533a"}
34 {} 34 {}
35 35
36 -[2021-09-13 11:09:46] [INFO] : ======================================================================================  
37 -[2021-09-13 11:09:46] [INFO] : http://test.gateway.diligrp.com:8285/dili-rule/api/chargeRule/queryFee 36 +[2021-09-14 11:09:06] [INFO] : ======================================================================================
  37 +[2021-09-14 11:09:06] [INFO] : http://test.gateway.diligrp.com:8285/dili-rule/api/chargeRule/queryFee
38 {"businessType": "501", "chargeItem": 518, "marketId": 15} 38 {"businessType": "501", "chargeItem": 518, "marketId": 15}
39 {} 39 {}
40 40
41 -[2021-09-13 11:09:46] [INFO] : ======================================================================================  
42 -[2021-09-13 11:09:46] [INFO] : http://test.gateway.diligrp.com:8285/dili-rule/api/chargeRule/queryFee 41 +[2021-09-14 11:09:06] [INFO] : ======================================================================================
  42 +[2021-09-14 11:09:06] [INFO] : http://test.gateway.diligrp.com:8285/dili-rule/api/chargeRule/queryFee
43 {"businessType": "501", "chargeItem": 520, "marketId": 15} 43 {"businessType": "501", "chargeItem": 520, "marketId": 15}
44 {} 44 {}
45 45
46 -[2021-09-13 11:09:47] [INFO] : ======================================================================================  
47 -[2021-09-13 11:09:47] [INFO] : http://test.gateway.diligrp.com:8285/hg-trading/api/registerRecord/save 46 +[2021-09-14 11:09:06] [INFO] : ======================================================================================
  47 +[2021-09-14 11:09:06] [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"} 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"}
49 {} 49 {}
50 50
51 -[2021-09-13 11:09:48] [INFO] : ======================================================================================  
52 -[2021-09-13 11:09:48] [INFO] : http://test.gateway.diligrp.com:8285/hg-trading/api/registerRecord/queryRegister  
53 -{"recordQueryDto": {"batchCode": "2109000298"}} 51 +[2021-09-14 11:09:08] [INFO] : ======================================================================================
  52 +[2021-09-14 11:09:08] [INFO] : http://test.gateway.diligrp.com:8285/hg-trading/api/settle/changeBatchCodeState
  53 +{"batchCode": "2109000335", "state": "2"}
54 {} 54 {}
55 55
56 -[2021-09-13 11:09:48] [INFO] : ======================================================================================  
57 -[2021-09-13 11:09:48] [INFO] : http://test.gateway.diligrp.com:8285/wms-service/api/sheet/manage/getBySheetNoAndBizNo 56 +[2021-09-14 11:09:08] [INFO] : ======================================================================================
  57 +[2021-09-14 11:09:08] [INFO] : http://test.gateway.diligrp.com:8285/hg-trading/api/settle/query
58 None 58 None
59 -{'params': {'bizNo': '2109000298'}}  
60 -  
61 -[2021-09-13 11:09:48] [INFO] : ======================================================================================  
62 -[2021-09-13 11:09:48] [INFO] : http://test.gateway.diligrp.com:8285/assets-service/api/district/search  
63 -{"id": 272, "marketId": 15, "departmentId": 177}  
64 -{}  
65 -  
66 -[2021-09-13 11:09:48] [INFO] : ======================================================================================  
67 -[2021-09-13 11:09:48] [INFO] : http://test.gateway.diligrp.com:8285/wms-service/api/sheet/manage/validateReduce  
68 -{"bizNo": "2109000298", "firmId": 15, "kid": "36", "weight": "50"}  
69 -{}  
70 -  
71 -[2021-09-13 11:09:48] [INFO] : ======================================================================================  
72 -[2021-09-13 11:09:48] [INFO] : http://test.gateway.diligrp.com:8285/assets-service/api/businessChargeItem/listByExample  
73 -{"IsEnable": 1, "MarketId": 15, "BusinessType": "hg_trading_buyer", "marketId": 15}  
74 -{}  
75 -  
76 -[2021-09-13 11:09:48] [INFO] : ======================================================================================  
77 -[2021-09-13 11:09:48] [INFO] : http://test.gateway.diligrp.com:8285/dili-rule/api/chargeRule/queryFee  
78 -{"marketId": 15, "businessType": "hg_trading_buyer", "chargeItem": 521, "calcParams": {"amount": 150.0}, "conditionParams": {"payment": 150.0, "categoryId": 754107}, "amount": 10000, "payment": 10000, "categoryId": 754107}  
79 -{}  
80 -  
81 -[2021-09-13 11:09:48] [INFO] : ======================================================================================  
82 -[2021-09-13 11:09:48] [INFO] : http://test.gateway.diligrp.com:8285/assets-service/api/businessChargeItem/listByExample  
83 -{"IsEnable": 1, "MarketId": 15, "BusinessType": "hg_trading_seller", "marketId": 15}  
84 -{}  
85 -  
86 -[2021-09-13 11:09:48] [INFO] : ======================================================================================  
87 -[2021-09-13 11:09:48] [INFO] : http://test.gateway.diligrp.com:8285/dili-rule/api/chargeRule/queryFee  
88 -{"marketId": 15, "businessType": "hg_trading_seller", "chargeItem": 522, "calcParams": {"amount": 150.0}, "conditionParams": {"payment": 150.0, "categoryId": 754107}, "amount": 10000, "payment": 10000, "categoryId": 754107}  
89 -{}  
90 -  
91 -[2021-09-13 11:09:49] [INFO] : ======================================================================================  
92 -[2021-09-13 11:09:49] [INFO] : http://test.gateway.diligrp.com:8285/dili-rule/api/chargeRule/queryFee  
93 -{"marketId": 15, "businessType": "hg_trading_seller", "chargeItem": 527, "calcParams": {"amount": 150.0}, "conditionParams": {"payment": 150.0, "categoryId": 754107}, "amount": 10000, "payment": 10000, "categoryId": 754107}  
94 -{}  
95 -  
96 -[2021-09-13 11:09:49] [INFO] : ======================================================================================  
97 -[2021-09-13 11:09:49] [INFO] : http://test.gateway.diligrp.com:8285/account-service/api/account/simpleInfo  
98 -None  
99 -{'params': {'cardNo': '888800010592'}}  
100 -  
101 -[2021-09-13 11:09:49] [INFO] : ======================================================================================  
102 -[2021-09-13 11:09:49] [INFO] : http://test.gateway.diligrp.com:8285/hg-trading/api/tradingOrder/createAndTrade  
103 -{"sellerId": 142000, "sellerName": "\u53f2\u4e1c\u6676", "sellerAccountId": 107796, "sellerCardNo": "888800010591", "buyerId": 141963, "buyerName": "\u676d\u679c\u5ba2\u6237\u957f\u6b4c\u4e00", "buyerAccountId": 107667, "buyerCardNo": "888800010592", "posCode": "123", "tradePassword": "111111", "orderItemList": [{"number": 0, "batchCode": "2109000298", "productId": "36", "productCode": "754107", "productName": "\u8461\u8404", "categoryId": 754107, "weightType": 2, "quantity": 1, "pieceWeight": null, "grossWeight": 0, "tareWeight": 0, "weight": "50", "price": 200, "PriceStr": "2", "amount": 10000, "amountStr": "100.0", "originId": 500101, "originName": "\u4e07\u5dde\u533a", "feeItemList": [{"type": 1, "chargeItemId": 521, "chargeItemName": "\u4e70\u5bb6\u624b\u7eed\u8d39", "amount": 10000}, {"type": 2, "chargeItemId": 522, "chargeItemName": "\u5356\u5bb6\u624b\u7eed\u8d39", "amount": 10000}, {"type": 2, "chargeItemId": 527, "chargeItemName": "\u5356\u5bb6\u4ed3\u50a8\u670d\u52a1\u8d39", "amount": 10000}]}]}  
104 -{} 59 +{'params': {'batchCode': '2109000335'}}
105 60
testcase/hg/test_batchSettlement/test_batchSettlement.py
@@ -9,10 +9,12 @@ @@ -9,10 +9,12 @@
9 杭果市场-结算管理-批号管理 9 杭果市场-结算管理-批号管理
10 """ 10 """
11 11
12 -from commons.MySession import sessionHg as session  
13 -from commons.api.hg.CheckIn import CheckIn 12 +
14 from commons.api.hg.settlement import batch 13 from commons.api.hg.settlement import batch
  14 +from commons.api.hg.settlement import batchSettlement
15 from commons.api.hg.settlement import sellingGoods 15 from commons.api.hg.settlement import sellingGoods
  16 +from commons.MySession import sessionHg as session
  17 +from commons.api.hg.CheckIn import CheckIn
16 from commons.scripts.readConf import rC 18 from commons.scripts.readConf import rC
17 import unittest,random 19 import unittest,random
18 20
@@ -38,14 +40,19 @@ class test_batch(unittest.TestCase): @@ -38,14 +40,19 @@ class test_batch(unittest.TestCase):
38 40
39 def test_searchState_1(self): 41 def test_searchState_1(self):
40 """ 42 """
41 - 批号管理--查询--输入【在售】状态的完整批号,查询出该批号下的相关数据 43 + 批号管理--查询--验证查询已关闭的批号自动加载批号信息
42 """ 44 """
43 # 创建初始数据 45 # 创建初始数据
44 posCode = self.posCode 46 posCode = self.posCode
  47 + state = "2"
45 resBatchCode = CheckIn.create_registerRecord(session=session, host=self.gatewayHost,ic=self.ic) 48 resBatchCode = CheckIn.create_registerRecord(session=session, host=self.gatewayHost,ic=self.ic)
46 batchCode = resBatchCode.json()["data"]["batchCode"] 49 batchCode = resBatchCode.json()["data"]["batchCode"]
47 print("test_searchState_1 --> self.batchCode:", batchCode) 50 print("test_searchState_1 --> self.batchCode:", batchCode)
48 - resCAT = sellingGoods.doCreateAndTrade(session=session,host=self.gatewayHost,batchCode=batchCode,  
49 - ic=self.ic_buyer,posCode=posCode) 51 + # 变更交易状态
  52 + resCAT = batch.changeBatchCodeState(session=session,host=self.gatewayHost,batchCode=batchCode,state=state)
50 print(resCAT.json()) 53 print(resCAT.json())
51 - assert resCAT.json()["code"]=="200","登记单交易失败"  
52 \ No newline at end of file 54 \ No newline at end of file
  55 + assert resCAT.json()["code"]=="200","登记单状态变更失败"
  56 + # 结算单查询
  57 + res = batchSettlement.settle_query(session=session,host=self.gatewayHost,batchCode=batchCode)
  58 + print(res.text)
  59 + assert "tradingOrder" in res.text,"验证查询已关闭的批号自动加载批号信息"
53 \ No newline at end of file 60 \ No newline at end of file