Exemple #1
0
def shopping_interface(name, cost, shoppingcart):
    flg, msg = bank.consume_interface(name, cost)
    if flg:
        user_dic = db_handler.select(name)
        user_dic['shoppingcart'] = shoppingcart
        db_handler.save(user_dic)
        return True, '购买成功'
    else:
        return False, msg
Exemple #2
0
def shopping_interface(name, cost, shoppingcart):
    flg, msg = bank.consume_interface(name, cost)

    if flg:
        user_dic = db_handler.select(name)
        user_dic["shoppingcart"] = shoppingcart
        db_handler.save(user_dic)
        return True, "shop successfully"
    else:
        return False, msg
Exemple #3
0
def shopping_interface(name, cost, shoppingcar):
    flag, msg = bank.consume_interface(name, cost)
    if flag:
        user_dic = db_handler.select(name)
        user_dic['shoppingcar'] = shoppingcar
        db_handler.save(user_dic)
        shopping_logger.info('%s成功购买了商品' % name)
        return True, '购买成功!'
    else:
        return False, msg
Exemple #4
0
def shopping_interface(name, money, shoppingcart):
    '''
    购物接口.
    :param name:用户名
    :param money: 消费金额
    :param shoppingcart: 购物车清单
    :return:True,False
    '''
    flag, msg = bank.consume_interface(name, money)
    if flag:
        user_dic = db_handler.select(name)
        user_dic['shoppingcart'] = shoppingcart
        db_handler.save(user_dic)
        return True, '购买成功'
    else:
        return False, '余额不足'