Arthur-Wu committed this file on 2024-11-18
This commit is contained in:
@ -63,13 +63,13 @@ class YMClientApi(object):
|
||||
logging.info(f"-----------接口返回数据:{response.json()}\n\n")
|
||||
return response.json()
|
||||
|
||||
def add_retire_purchase(self, GoodsInfoData, LoginData):
|
||||
def add_retire_purchase(self, GoodsInfoData, AddPurchaseQuantity, LoginData):
|
||||
logging.info("========== [加入购物车] add_retire_purchase ==========")
|
||||
payload = json.dumps({
|
||||
"addGoods":[{
|
||||
"inputCode": GoodsInfoData["data"]["inputCode"],
|
||||
"isNormalAddPurchase": True,
|
||||
"qty": GoodsInfoData["data"]["qty"],
|
||||
"qty": int(AddPurchaseQuantity), # AddPurchaseQuantity,GoodsInfoData["data"]["qty"]
|
||||
"weight": int(GoodsInfoData["data"]["weight"]),
|
||||
}],
|
||||
"autoSelectCoupon": True,
|
||||
@ -146,11 +146,8 @@ class YMClientApi(object):
|
||||
POST
|
||||
https://api.test.yimaogo.com/cart/v2/shopping/add/retire/purchase
|
||||
|
||||
payload = {"addGoods":[{"inputCode":"6942728414063","isNormalAddPurchase":true,"qty":1,"weight":0}],"autoSelectCoupon":true,"coupons":[],"deleteGoods":[],"existGoods":[],"orderNo":"1857003957307801600"}
|
||||
'''
|
||||
|
||||
|
||||
|
||||
''' 2- without sessionid '''
|
||||
def get_ads_list(self):
|
||||
logging.info("========== [获取广告列表] get_ads_list ==========")
|
||||
@ -174,25 +171,23 @@ class YMClientApi(object):
|
||||
return response.json()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
ym = YMClientApi()
|
||||
ymc = YMClientApi()
|
||||
''' 01- '''
|
||||
ym.session_start() # step1:session开始
|
||||
ymc.session_start() # step1:session开始
|
||||
Payload01 = {"action": 0, "isAnon": True}
|
||||
LoginData = ym.login_app_v2(Payload01) # step2:匿名登录
|
||||
ym.get_login_type() # step3:获取登录方式
|
||||
LoginData = ymc.login_app_v2(Payload01) # step2:匿名登录
|
||||
|
||||
ymc.get_login_type() # step3:获取登录方式
|
||||
Payload02 = {"action": 1, "code": "18052753212", "isAnon": False}
|
||||
ym.login_app_v2(Payload02) # step4:切换会员登录
|
||||
GoodsInfoData = ym.get_goods_info(InputCode=6924882486100) # step5:获取商品信息
|
||||
CouponListData = ym.get_coupon_list() # step6:获取优惠券列表
|
||||
ym.receive_coupon(CouponListData) # step7:领取优惠券
|
||||
ym.query_coupon_list_user() # step8:查询用户持有的优惠券列表
|
||||
ym.add_retire_purchase(GoodsInfoData, LoginData) # step9:加购商品
|
||||
ym.get_cart_goods_info(GoodsInfoData) # step10:获取购物车商品信息
|
||||
ym.request_order_settlement(LoginData) # step11:请求订单结算
|
||||
ymc.login_app_v2(Payload02) # step4:切换会员登录
|
||||
GoodsInfoData = ymc.get_goods_info(InputCode=6924882486100) # step5:获取商品信息 ------ 6924882486100
|
||||
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.get_cart_goods_info(GoodsInfoData) # step10:获取购物车商品信息
|
||||
ymc.request_order_settlement(LoginData) # step11:请求订单结算
|
||||
|
||||
ym.session_end()
|
||||
ymc.session_end()
|
||||
|
||||
|
Reference in New Issue
Block a user