Exemple #1
0
def shopping():
    print('欢迎来到购物功能')
    good_list = [
        # 商品名, 价格
        ['巨大鸡腿', 50],
        ['红烧羊排', 1000],
        ['清蒸中华鲟', 5000],
        ['西柚炖猪蹄', 1000],
        ['山药排骨汤', 500],
        ['蛋黄小龙虾', 2000],
        ['聚宝盆烧烤', 200],
    ]

    shopping_car = {}
    cost = 0
    user_balance = user_interface.check_balance_interface(user_info.get('username'))
    while True:
        for ind,goods in enumerate(good_list):
            print(ind,goods)
        choice = input('请输入商品编号退出请按q:').strip()
        if choice == 'q':
            break
        if not choice.isdigit():
            print('必须输入数字')
            continue
        choice = int(choice)
        good_name,good_price = good_list[choice]

        if user_balance >= good_price:

            if good_name in shopping_car:
                shopping_car[good_name] += 1

            else:
                shopping_car[good_name] = 1

            cost += good_price


        else:
            print('用户金额不足!')

        if not cost:
            print('没有选择商品')

        # 6.开始结算, 先调用购物车接口, 再通过购物车接口去调用支付接口
    sure = input('是否确认购买,输入y/n').strip()
    if sure == 'y':
        flag, msg = shop_interface.shopping_pay_interface(user_info.get('username'), shopping_car, cost)
        if flag:
            print(msg)

        else:
            print(msg)

    elif sure == 'n':
        # 添加购物车功能
        flag, msg = shop_interface.shopping_car_interface(user_info.get('username'), shopping_car)
Exemple #2
0
def check_balance():
    balance=user_interface.check_balance_interface(login_user)
    print(f'用户{login_user}账户余额为{balance}')
Exemple #3
0
def check_balance():
    print('欢迎来到查看余额功能')
    balance = user_interface.check_balance_interface(user_info['username'])
    print(balance)
Exemple #4
0
def check_balance():
    res_balance = user_interface.check_balance_interface(user_info["name"])
    print("余额为%s" % (res_balance,))
Exemple #5
0
def check_balance():
    balance = user_interface.check_balance_interface(login_user)
    print(f"{login_user} 用户的余额为{balance}")
Exemple #6
0
def check_balance():
    print('欢迎来到查余额界面')
    user_bal = user_interface.check_balance_interface(user_inf.get('user'))
    print(f'你的余额为{user_bal}')
Exemple #7
0
def check_balance():
    res = check_balance_interface(is_load)
    print(res)