Arthur-Wu committed this file on 2024-11-18
This commit is contained in:
@ -7,12 +7,34 @@ import requests,json, logging
|
||||
from commons.SignatureYM import SignatureYM2
|
||||
|
||||
|
||||
|
||||
class YMClientApi(object):
|
||||
def __init__(self):
|
||||
self.Domain = "https://api.test.yimaogo.com/cart"
|
||||
self.headerss = SignatureYM2(Mac="b8:2d:28:04:c7:5c")._headers()
|
||||
|
||||
''' 1- without sessionid '''
|
||||
def get_ads_list(self):
|
||||
logging.info("========== [获取广告列表] get_ads_list ==========")
|
||||
''' method 1 '''
|
||||
payload = {}
|
||||
url = self.Domain + "/v1/ads/list?areaCode&userId&barcode&adsAreaIds=1,2,3,4,5,6"
|
||||
logging.info(f"---url: {url}---")
|
||||
logging.info(f"---headers: {self.headerss}---")
|
||||
response = requests.request("GET", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
def query_ad_detail(self, ADsId: str):
|
||||
logging.info("========== [查询广告详情] query_ad_detail ==========")
|
||||
payload = {}
|
||||
url = self.Domain + "/v1/ads/{adsId}".replace("{adsId}", str(ADsId))
|
||||
response = requests.request("GET", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
''' 2- sessionid must be started first '''
|
||||
def session_start(self):
|
||||
logging.info("========== [前置] session_start ==========")
|
||||
url = self.Domain+"/v1/session/start"
|
||||
@ -84,8 +106,28 @@ class YMClientApi(object):
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
def delete_cart_goods(self, GoodsInfoData):
|
||||
def delete_cart_goods(self, GoodsInfoData, LoginData, AddGoodsResponse):
|
||||
''' 退购
|
||||
|
||||
:param GoodsInfoData:
|
||||
:return:
|
||||
'''
|
||||
logging.info("========== [删除购物车商品] delete_cart_goods ==========")
|
||||
GoodsInfoData = ''
|
||||
LoginData = ''
|
||||
AddGoodsResponse = ''
|
||||
|
||||
existGoods = []
|
||||
for goodsinfo in AddGoodsResponse["data"]["orderItemList"]:
|
||||
good_dict = {}
|
||||
good_dict["inputCode"] = goodsinfo["inputCode"]
|
||||
good_dict["isNormalAddPurchase"] = True
|
||||
good_dict["qty"] = goodsinfo["qty"]
|
||||
good_dict["uuid"] = goodsinfo["uuid"]
|
||||
# good_dict["weight"] = goodsinfo["weight"]
|
||||
good_dict["weight"] = GoodsInfoData["data"]["weight"]
|
||||
existGoods.append(good_dict)
|
||||
|
||||
payload = json.dumps({
|
||||
"addGoods": [],
|
||||
"autoSelectCoupon": True,
|
||||
@ -114,8 +156,8 @@ class YMClientApi(object):
|
||||
"remainAmount": "13.8",
|
||||
"totalDisc": "0.0",
|
||||
"orderItemList": [{
|
||||
"uuid": ["2BEDF9C6DD954E1FB3DCD9A9F3C57D29"], #
|
||||
"qty": 1, #
|
||||
"uuid": ["2BEDF9C6DD954E1FB3DCD9A9F3C57D29"], # 下传
|
||||
"qty": 1, # 下传
|
||||
"marketPrice": "5",
|
||||
"salePrice": "5.00",
|
||||
"totalSalePrice": "5",
|
||||
@ -126,15 +168,15 @@ class YMClientApi(object):
|
||||
"barcode": "6925303796426",
|
||||
"inputCode": "6925303796426",
|
||||
"goodsName": "统一茄皇蕃茄牛肉面",
|
||||
"goodsPromotionTags": null,
|
||||
"goodsPromotionTags": None,
|
||||
"measureProperty": 0,
|
||||
"shoppingBagFlag": false,
|
||||
"activityId": null,
|
||||
"activityDescription": null,
|
||||
"shoppingBagFlag": False,
|
||||
"activityId": None,
|
||||
"activityDescription": None,
|
||||
"totalPromotionPrice": 0,
|
||||
"categoryCode": null,
|
||||
"isOneBarcodeMore": false,
|
||||
"pkgFlag": false
|
||||
"categoryCode": None,
|
||||
"isOneBarcodeMore": False,
|
||||
"pkgFlag": False
|
||||
},
|
||||
{
|
||||
"uuid": ["F9BBA7C9AF7944FF91C717E3D18BD682"],
|
||||
@ -149,19 +191,19 @@ class YMClientApi(object):
|
||||
"barcode": "6924743915848",
|
||||
"inputCode": "6924743915848",
|
||||
"goodsName": "乐事无限翡翠黄瓜味薯片",
|
||||
"goodsPromotionTags": null,
|
||||
"goodsPromotionTags": None,
|
||||
"measureProperty": 0,
|
||||
"shoppingBagFlag": false,
|
||||
"activityId": null,
|
||||
"activityDescription": null,
|
||||
"shoppingBagFlag": False,
|
||||
"activityId": None,
|
||||
"activityDescription": None,
|
||||
"totalPromotionPrice": 0,
|
||||
"categoryCode": null,
|
||||
"isOneBarcodeMore": false,
|
||||
"pkgFlag": false
|
||||
"categoryCode": None,
|
||||
"isOneBarcodeMore": False,
|
||||
"pkgFlag": False
|
||||
}],
|
||||
"bagInfoList": null,
|
||||
"couponMap": null,
|
||||
"activityGoodsList": null
|
||||
"bagInfoList": None,
|
||||
"couponMap": None,
|
||||
"activityGoodsList": None
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,11 +219,11 @@ class YMClientApi(object):
|
||||
"weight": 0
|
||||
}],
|
||||
"existGoods": [{
|
||||
"inputCode": "6925303796426",
|
||||
"inputCode": "6925303796426", # 取自 add_2_result["data"]["orderItemList"][0]["inputCode"]
|
||||
"isNormalAddPurchase": True,
|
||||
"qty": 1,
|
||||
"uuid": ["2BEDF9C6DD954E1FB3DCD9A9F3C57D29"],
|
||||
"weight": 165 # GoodsInfoData["data"]["weight"]
|
||||
"qty": 1, # 取自 add_2_result["data"]["orderItemList"][0]["qty"]
|
||||
"uuid": ["2BEDF9C6DD954E1FB3DCD9A9F3C57D29"], # 取自 add_2_result["data"]["orderItemList"][1]["uuid"]
|
||||
"weight": 165 # 取自 GoodsInfoData["data"]["weight"]
|
||||
}, {
|
||||
"inputCode": "6924743915848",
|
||||
"isNormalAddPurchase": True,
|
||||
@ -189,9 +231,10 @@ class YMClientApi(object):
|
||||
"uuid": ["F9BBA7C9AF7944FF91C717E3D18BD682"],
|
||||
"weight": 160 # GoodsInfoData["data"]["weight"]
|
||||
}],
|
||||
"orderNo": "1858386778027515904"
|
||||
"orderNo": "1858386778027515904" # 取自 LoginData["data"][0]["orderNo"]
|
||||
}
|
||||
|
||||
|
||||
def get_coupon_list(self):
|
||||
logging.info("========== [获取优惠券列表] get_coupon_list ==========")
|
||||
payload = json.dumps({
|
||||
@ -254,27 +297,6 @@ class YMClientApi(object):
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
''' 2- without sessionid '''
|
||||
def get_ads_list(self):
|
||||
logging.info("========== [获取广告列表] get_ads_list ==========")
|
||||
''' method 1 '''
|
||||
payload = {}
|
||||
url = self.Domain+"/v1/ads/list?areaCode&userId&barcode&adsAreaIds=1,2,3,4,5,6"
|
||||
logging.info(f"---url: {url}---")
|
||||
logging.info(f"---headers: {self.headerss}---")
|
||||
response = requests.request("GET", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
def query_ad_detail(self, ADsId:str):
|
||||
logging.info("========== [查询广告详情] query_ad_detail ==========")
|
||||
payload = {}
|
||||
url = self.Domain+"/v1/ads/{adsId}".replace("{adsId}", str(ADsId))
|
||||
response = requests.request("GET", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -61,6 +61,7 @@ class YMServiceApi(object):
|
||||
writeResult = Txt().append_write_txt("ScenarioTest_GoodsWhiteListID.txt", str(goodsWhiteListID))
|
||||
if not writeResult:
|
||||
logging.error(f"---写入 新建促销商品白名单ID 失败!")
|
||||
return response.json()
|
||||
|
||||
def delete_whitelist_goods(self):
|
||||
logging.info("========== [删除促销白名单商品] ==========")
|
||||
@ -96,6 +97,7 @@ class YMServiceApi(object):
|
||||
writeResult = Txt().append_write_txt("ScenarioTest_WeightWhiteListID.txt", str(weightWhiteListID))
|
||||
if not writeResult:
|
||||
logging.error(f"---写入 新建重量放通白名单ID 失败!")
|
||||
return response.json()
|
||||
|
||||
def delete_weight_whitelist_goods(self):
|
||||
logging.info("========== [删除重量放通白名单商品] ==========")
|
||||
|
Reference in New Issue
Block a user