Пример #1
0
def add_order():
    user_service = UserService()
    while True:
        user_id = input('请输入顾客id')
        if user_id != user_service.find_user_id(user_id):
            print("顾客不存在, 请重新输入顾客名称")
            continue
        if user_id == user_service.find_user_id(user_id):
            break
    carts = []
    item_service = ItemService()
    while True:
        item_id = input('请输入商品编号:')
        price = item_service.find_price(item_id)
        if price is None:
            print('商品不存在!')
            continue
        quantity = account_int('请输入购买数量: ')
        item = Item(id=item_id, stock=quantity, price=price, title='')
        carts.append(item)
        echo = input('是否继续?y/n')
        if echo == 'n':
            break
    order = Order(user_id, carts)
    order_service = OrderService()
    print("商品总价格: ", order_service.price(order))
    print("商品清单: ", order_service.item_order(order))
    return order_service.add(order)
Пример #2
0
def lottery():
    global current_person
    lottery = Lottery(current_person)
    lotterys = lottery.list()
    user_service = UserService()
    lottery_service = LotteryService()
    ret = lottery_service.lottery(lotterys, current_person)
    user_point = user_service.point(current_person.name)
    print(f"当前剩余积分: {user_point}")
    return ret
Пример #3
0
def user_reg():
    print("顾客注册".center(20, "="))
    name = input("请输入顾客名称: ")
    password1 = input("请输入顾客密码: ")
    password2 = input("请再次输入密码: ")
    if password2 != password1:
        return False
    user = User(name, password1)
    user_service = UserService()
    ret = user_service.reg(user)
    return ret
Пример #4
0
def user_login():
    global current_person
    print("顾客登录".center(20, "="))
    name = input("请输入顾客名称: ")
    password = input("请输入顾客密码: ")
    user = User(name, password)
    user_service = UserService()
    ret = user_service.login(user)
    if ret:
        current_person = user
    return ret
Пример #5
0
def query_user():
    user_service = UserService()
    users = user_service.query_all()
    for u in users:
        print(u)