Arthur-Wu committed this file on 2024-11-18
This commit is contained in:
@ -63,7 +63,7 @@ class YMClientApi(object):
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
def add_retire_purchase(self, GoodsInfoData, AddPurchaseQuantity, LoginData):
|
||||
def add_cart_goods(self, GoodsInfoData, AddPurchaseQuantity, LoginData):
|
||||
logging.info("========== [加入购物车] add_retire_purchase ==========")
|
||||
payload = json.dumps({
|
||||
"addGoods":[{
|
||||
@ -82,6 +82,115 @@ class YMClientApi(object):
|
||||
response = requests.request("POST", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
def delete_cart_goods(self, GoodsInfoData):
|
||||
logging.info("========== [删除购物车商品] delete_cart_goods ==========")
|
||||
payload = json.dumps({
|
||||
"addGoods": [],
|
||||
"autoSelectCoupon": True,
|
||||
"coupons": [],
|
||||
"deleteGoods": [{
|
||||
"inputCode": "6924743915848",
|
||||
"isNormalAddPurchase": True,
|
||||
"qty": 1,
|
||||
"uuid": ["23B2363A224E4933942992F84B937D7D"],
|
||||
"weight": 0
|
||||
}],
|
||||
"existGoods": [{
|
||||
"inputCode": "6924743915848",
|
||||
"isNormalAddPurchase": True,
|
||||
"qty": 1,
|
||||
"uuid": ["23B2363A224E4933942992F84B937D7D"],
|
||||
"weight": 155
|
||||
}],
|
||||
"orderNo": "1858386778027515904"
|
||||
})
|
||||
|
||||
add_2_result = {
|
||||
"code": 0,
|
||||
"msg": "成功",
|
||||
"data": {
|
||||
"remainAmount": "13.8",
|
||||
"totalDisc": "0.0",
|
||||
"orderItemList": [{
|
||||
"uuid": ["2BEDF9C6DD954E1FB3DCD9A9F3C57D29"], #
|
||||
"qty": 1, #
|
||||
"marketPrice": "5",
|
||||
"salePrice": "5.00",
|
||||
"totalSalePrice": "5",
|
||||
"minWeight": 0,
|
||||
"weight": 0,
|
||||
"maxWeight": 0,
|
||||
"goodsPic": "https://ieemoo-storage.obs.cn-east-3.myhuaweicloud.com/lhpic/6925303796426.jpg",
|
||||
"barcode": "6925303796426",
|
||||
"inputCode": "6925303796426",
|
||||
"goodsName": "统一茄皇蕃茄牛肉面",
|
||||
"goodsPromotionTags": null,
|
||||
"measureProperty": 0,
|
||||
"shoppingBagFlag": false,
|
||||
"activityId": null,
|
||||
"activityDescription": null,
|
||||
"totalPromotionPrice": 0,
|
||||
"categoryCode": null,
|
||||
"isOneBarcodeMore": false,
|
||||
"pkgFlag": false
|
||||
},
|
||||
{
|
||||
"uuid": ["F9BBA7C9AF7944FF91C717E3D18BD682"],
|
||||
"qty": 1,
|
||||
"marketPrice": "8.8",
|
||||
"salePrice": "8.80",
|
||||
"totalSalePrice": "8.8",
|
||||
"minWeight": 0,
|
||||
"weight": 0,
|
||||
"maxWeight": 0,
|
||||
"goodsPic": "https://ieemoo-storage.obs.cn-east-3.myhuaweicloud.com/lhpic/6924743915848.jpg",
|
||||
"barcode": "6924743915848",
|
||||
"inputCode": "6924743915848",
|
||||
"goodsName": "乐事无限翡翠黄瓜味薯片",
|
||||
"goodsPromotionTags": null,
|
||||
"measureProperty": 0,
|
||||
"shoppingBagFlag": false,
|
||||
"activityId": null,
|
||||
"activityDescription": null,
|
||||
"totalPromotionPrice": 0,
|
||||
"categoryCode": null,
|
||||
"isOneBarcodeMore": false,
|
||||
"pkgFlag": false
|
||||
}],
|
||||
"bagInfoList": null,
|
||||
"couponMap": null,
|
||||
"activityGoodsList": null
|
||||
}
|
||||
}
|
||||
|
||||
del_201 = {
|
||||
"addGoods": [],
|
||||
"autoSelectCoupon": True,
|
||||
"coupons": [],
|
||||
"deleteGoods": [{
|
||||
"inputCode": "6924743915848",
|
||||
"isNormalAddPurchase": True,
|
||||
"qty": 1,
|
||||
"uuid": ["F9BBA7C9AF7944FF91C717E3D18BD682"],
|
||||
"weight": 0
|
||||
}],
|
||||
"existGoods": [{
|
||||
"inputCode": "6925303796426",
|
||||
"isNormalAddPurchase": True,
|
||||
"qty": 1,
|
||||
"uuid": ["2BEDF9C6DD954E1FB3DCD9A9F3C57D29"],
|
||||
"weight": 165 # GoodsInfoData["data"]["weight"]
|
||||
}, {
|
||||
"inputCode": "6924743915848",
|
||||
"isNormalAddPurchase": True,
|
||||
"qty": 1,
|
||||
"uuid": ["F9BBA7C9AF7944FF91C717E3D18BD682"],
|
||||
"weight": 160 # GoodsInfoData["data"]["weight"]
|
||||
}],
|
||||
"orderNo": "1858386778027515904"
|
||||
}
|
||||
|
||||
def get_coupon_list(self):
|
||||
logging.info("========== [获取优惠券列表] get_coupon_list ==========")
|
||||
@ -116,13 +225,16 @@ class YMClientApi(object):
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
def get_cart_goods_info(self, GoodsInfoData):
|
||||
def get_cart_goods_info(self, GoodsDataList):
|
||||
logging.info("========== [获取购物车商品信息] get_cart_goods_info ==========")
|
||||
payload = json.dumps({"goodsParamList":[{
|
||||
"inputCode": GoodsInfoData["data"]["inputCode"],
|
||||
"qty": GoodsInfoData["data"]["qty"],
|
||||
"weight": int(GoodsInfoData["data"]["weight"]),
|
||||
}]})
|
||||
goods_param_lList = []
|
||||
for goods_data in GoodsDataList:
|
||||
goods_dict = {}
|
||||
goods_dict["inputCode"] = goods_data["data"]["inputCode"]
|
||||
goods_dict["qty"] = goods_data["data"]["qty"]
|
||||
goods_dict["weight"] = int(goods_data["data"]["weight"])
|
||||
goods_param_lList.append(goods_dict)
|
||||
payload = json.dumps({"goodsParamList": goods_param_lList})
|
||||
url = self.Domain+"/v2/shopping/cart/goods/info"
|
||||
response = requests.request("POST", url, headers=self.headerss, data=payload)
|
||||
logging.info(f"-----------接口返回状态码:{response.status_code}")
|
||||
@ -142,12 +254,6 @@ class YMClientApi(object):
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
''' 加购购物袋
|
||||
POST
|
||||
https://api.test.yimaogo.com/cart/v2/shopping/add/retire/purchase
|
||||
|
||||
'''
|
||||
|
||||
''' 2- without sessionid '''
|
||||
def get_ads_list(self):
|
||||
logging.info("========== [获取广告列表] get_ads_list ==========")
|
||||
@ -185,7 +291,7 @@ if __name__ == '__main__':
|
||||
CouponListData = ymc.get_coupon_list() # step6:获取优惠券列表
|
||||
ymc.receive_coupon(CouponListData) # step7:领取优惠券
|
||||
ymc.query_coupon_list_user() # step8:查询用户持有的优惠券列表
|
||||
ymc.add_retire_purchase(GoodsInfoData, 1, LoginData) # step9:加购商品 ------ 6924882486100
|
||||
ymc.add_cart_goods(GoodsInfoData, 1, LoginData) # step9:加购商品 ------ 6924882486100
|
||||
ymc.get_cart_goods_info(GoodsInfoData) # step10:获取购物车商品信息
|
||||
ymc.request_order_settlement(LoginData) # step11:请求订单结算
|
||||
|
||||
|
||||
Reference in New Issue
Block a user