Ejemplo n.º 1
0
Archivo: scr.py Proyecto: surpassL/ATM
 def inner(*args, **kwargs):
     if user_info:
         res = func(*args, **kwargs)
         return res
     while True:
         user_name = input('请输入您的账号')
         per_info = load_dump.get_info(user_name, power)  # 读取文件数据
         if not per_info:
             print('用户不存在')
             continue
         if per_info['state'] == 1:
             print('该账号已被冻结')
             continue
         count = 0
         while count < 3:
             password = input('请输入您的密码')
             password_res = common.check_password(per_info,
                                                  password)  # 验证密码
             if not password_res:
                 print('密码错误')
                 count += 1
                 continue
             user_info.update(per_info)  # 将拿到的信息更新到全局的字典
             global per_logger, atm_logger
             per_logger = make_diary.per_logger()
             atm_logger = make_diary.atm_logger()
             func_res = func(*args, **kwargs)
             return func_res
         print('错误三次,账号冻结!')
         per_info['state'] = 1
         load_dump.save_info(per_info)  # 将修改后的的数据存到文件
         return False
Ejemplo n.º 2
0
Archivo: scr.py Proyecto: surpassL/ATM
def transfer():  # 转账
    while True:
        money = input('请输入您想要转账的金额')
        int_money = common.check_digit(money)
        if not int_money:
            print('请输入整数')
            continue
        info = common.check_balance(user_info, int_money)
        if not info:
            print('余额不足')
            continue
        break
    while True:
        target = input('请输入目标账户')
        target_info = load_dump.get_info(target, 'user')
        if not target_info:
            print('账户不存在')
            continue
        target_info = common.add_money(target_info, int_money)
        load_dump.save_info(target_info)
        load_dump.save_info(info)
        print('转账成功')
        per_logger.info('%s转账给%s %s元' % (user_info['name'], target, int_money))
        atm_logger.info('%s转账给%s %s元' % (user_info['name'], target, int_money))
        break
Ejemplo n.º 3
0
Archivo: scr.py Proyecto: surpassL/ATM
def thaw_account():  # 解冻账号
    while True:
        target = input('请输入您想要解冻的账号')
        info = load_dump.get_info(target, 'user')
        if not info:
            print('该账户不存在')
            continue
        info['state'] = 0
        load_dump.save_info(info)
        print('解冻成功')
        per_logger.info('%s解冻了账户%s' % (user_info['name'], target))
        atm_logger.info('%s解冻了账户%s' % (user_info['name'], target))
        break
Ejemplo n.º 4
0
Archivo: scr.py Proyecto: surpassL/ATM
def freezing_account():  # 冻结账号
    while True:
        target = input('请输入您想要冻结的账号')
        info = load_dump.get_info(target, 'user')
        if not info:
            print('该账户不存在')
            continue
        info['state'] = 1
        load_dump.save_info(info)
        print('冻结成功')
        per_logger.info('%s冻结了账户%s' % (user_info['name'], target))
        atm_logger.info('%s冻结了账户%s' % (user_info['name'], target))
        break
Ejemplo n.º 5
0
Archivo: scr.py Proyecto: surpassL/ATM
def repay():  # 还款
    while True:
        should_repay = user_info['quota'] - user_info['balance']
        print('您还欠款%s元' % should_repay)
        money = input('请输入您想要还款的金额')
        int_money = common.check_digit(money)
        if not int_money:
            print('请输入整数')
            continue
        info = common.add_money(user_info, int_money)
        load_dump.save_info(info)
        print('还款成功')
        per_logger.info('%s还款%s元' % (user_info['name'], int_money))
        atm_logger.info('%s还款%s元' % (user_info['name'], int_money))
        break
Ejemplo n.º 6
0
Archivo: scr.py Proyecto: surpassL/ATM
def withdraw():  # 提现
    while True:
        money = input('请输入您想要提现的金额')
        int_money = common.check_digit(money)
        if not int_money:
            print('请输入整数')
            continue
        take_off = int_money * 1.05
        info = common.check_balance(user_info, take_off)
        if not info:
            print('余额不足')
            continue
        load_dump.save_info(info)
        print('提现成功')
        per_logger.info('%s提现%s元' % (user_info['name'], int_money))
        atm_logger.info('%s提现%s元' % (user_info['name'], int_money))
        break
Ejemplo n.º 7
0
Archivo: scr.py Proyecto: surpassL/ATM
def register():  # 注册功能
    while True:
        user_name = input('请输入您的账号')
        res = load_dump.get_info(user_name, 'user')
        if res:
            print('注册失败,账户已存在')
            continue
        break
    while True:
        password1 = input('请输入您的密码')
        password2 = input('请确认密码')
        if password1 == password2:
            info = common.set_info(user_name, password1, 'user')
            load_dump.save_info(info)
            print('注册成功')
            return
        else:
            print('两次密码不一致')
Ejemplo n.º 8
0
Archivo: scr.py Proyecto: surpassL/ATM
def shopping():  # 购物
    shopping_car = {}
    product_list = [
        ['Iphone7', 5800],
        ['Coffee', 30],
        ['疙瘩汤', 10],
        ['Python Book', 99],
        ['Bike', 199],
        ['ViVo X9', 2499],
    ]
    while True:
        for index, product in enumerate(product_list):
            print(index, product[0], product[1])
        choose = input('请输入与您想要购买的商品,b结账,q退出')
        if choose == 'b':
            total, info = common.check_out(user_info, shopping_car)  # 结账
            if not info:
                print('余额不足')
                continue
            load_dump.save_info(info)
            per_logger.info('%s购物花费%s元' % (user_info['name'], total))
            atm_logger.info('%s购物花费%s元' % (user_info['name'], total))
            print('购买成功')
            return
        if choose == 'q':
            print('放弃购买')
            return
        int_choose = common.check_digit(choose)
        if not int_choose and int_choose != 0:
            print('请输入整数或b结账,q退出')
            continue
        if int_choose >= len(product_list):
            print('商品超出范围')
            continue
        while True:
            count = input('请输入购买数量')
            int_count = common.check_digit(count)
            if not int_count:
                print('请输入整数')
                continue
            shopping_car = common.updata_shopping_car(product_list,
                                                      shopping_car, int_choose,
                                                      int_count)  # 更新购物车
            break
Ejemplo n.º 9
0
Archivo: scr.py Proyecto: surpassL/ATM
def add_admin():  # 添加管理员账户
    while True:
        user_name = input('请输入您的账号')
        res = load_dump.get_info(user_name, 'admin')
        if res:
            print('注册失败,账户已存在')
            continue
        break
    while True:
        password1 = input('请输入您的密码')
        password2 = input('请确认密码')
        if password1 == password2:
            info = common.set_info(user_name, password1, 'admin')
            load_dump.save_info(info)
            print('注册成功')
            per_logger.info('%s添加了管理员账户%s' % (user_info['name'], user_name))
            atm_logger.info('%s添加了管理员账户%s' % (user_info['name'], user_name))
            return
        else:
            print('两次密码不一致')
Ejemplo n.º 10
0
Archivo: scr.py Proyecto: surpassL/ATM
def quota():  # 提升额度
    while True:
        money = input('请输入想要提升的额度')
        int_money = common.check_digit(money)
        if not int_money:
            print('请输入整数')
            continue
        break
    while True:
        target = input('请输入需要提升额度的账户')
        info = load_dump.get_info(target, 'user')
        if not info:
            print('该账户不存在')
            continue
        info = common.add_quota(info, int_money)
        load_dump.save_info(info)
        print('提升额度成功')
        per_logger.info('%s为%s提升了%s额度' %
                        (user_info['name'], target, int_money))
        atm_logger.info('%s为%s提升了%s额度' %
                        (user_info['name'], target, int_money))
        break