def public_user_system(user, quit_user_system=False, log_file=None): while not quit_user_system: user_database = user_info["user_bank"] print("""欢迎使用 中国建都银行 用户[%s]已登陆 =============================================== 个人信息(1) 修改密码(2) 转账(3) 取现(4) 还款(5) 交易记录(6) 操作日志(7) 账单查询(8) 注销(b) 退出(q) =============================================== """ % user) wait_choose = str(input("请选择操作:")).strip() if wait_choose == "1": show_account_info(user_database, user, is_admin=False, log_file=log_file) elif wait_choose == "2": get_database = for_owner_change_password(user_database, user, log_file=log_file) if type(get_database) == dict: user_info["user_bank"] = get_database update_info(user_info) elif wait_choose == "3": get_database = transfer_cash(user_database, user, log_file=log_file, sold_log=sold_log_file) if type(get_database) == dict: user_info["user_bank"] = get_database update_info(user_info) elif wait_choose == "4": get_database = for_admin_withdraw_money(user_database, user, log_file=log_file, sold_log= sold_log_file) if type(get_database) == dict: user_info["user_bank"] = get_database update_info(user_info) elif wait_choose == "6": search_history_log(user, log_file=log_file, sold_log=sold_log_file, is_sold=True) elif wait_choose == "7": search_history_log(user, log_file=log_file) elif str(wait_choose).lower() in ['q', 'quit', ]: quit_user_system = True print("谢谢使用,再见 !") Logger(log_file).write_log(user=user, status=True, event="退出") break elif str(wait_choose).lower() in ['b', 'back', ]: break else: print("操作有误 !!!") return quit_user_system
def admin_management(admin_name, quit_admin_management=False, log_file=None): # 管理员登陆成功后的账号操作 while not quit_admin_management: try: user_database = user_info["user_bank"] except KeyError: user_info["user_bank"] = {} user_database = user_info["user_bank"] if not user_info["admin_bank"].get(admin_name): break print("""中国建都银行 管理中心 [%s]已登陆 =========================================== 开户(1) 修改密码(2) 查询账户(s) 存钱(3) 取钱(4) 额度(5) 解锁(6) 挂失(7) 销户(8) 管理员帐户管理(9) 注销(b) 退出(q) =========================================== """ % admin_name) wait_choose = str(input("请选择操作:")).strip() if wait_choose == "1": get_database = register_account(user_database, log_file=log_file) if type(get_database) == dict: user_info["user_bank"] = get_database update_info(user_info) elif wait_choose == "2": get_database = for_super_admin_change_password(user_database, admin_name, log_file=log_file) if type(get_database) == dict: user_info["user_bank"] = get_database update_info(user_info) elif wait_choose == "3": print("该功能暂未开放") elif wait_choose == "4": print("该功能暂未开放") elif wait_choose.lower() == "s": show_account_info(user_database, admin_name, is_admin=True, log_file=log_file) elif wait_choose == "5": get_database = change_user_credit_line(user_database, admin_name, log_file=log_file) if type(get_database) == dict: user_info['user_bank'] = get_database # 更新数据库信息 update_info(user_info) elif wait_choose == "6": get_database = for_admin_unlock_account(user_database, admin_name, log_file=log_file) if type(get_database) == dict: user_info["user_bank"] = get_database update_info(user_info) elif wait_choose == "7": get_database = for_admin_lock_account(user_database, admin_name, log_file=log_file) if type(get_database) == dict: user_info["user_bank"] = get_database update_info(user_info) elif wait_choose == "8": get_database = delete_account(user_database, admin_name, is_admin=False, log_file=log_file) if type(get_database) == dict: user_info['user_bank'] = get_database # 更新数据库信息 update_info(user_info) elif wait_choose == "9": quit_admin_management = management_admin_account( admin_name, quit_admin_management, log_file=log_file) # 对管理员账号进行操作 elif str(wait_choose).lower() in [ 'q', 'quit', ]: quit_admin_management = True Logger(log_file).write_log(user=admin_name, status=True, event="管理员退出") print("谢谢使用,再见 !") break elif str(wait_choose).lower() in [ 'b', 'back', ]: Logger(log_file).write_log(user=admin_name, status=True, event="管理员注销") break else: print("操作有误 !!!") return quit_admin_management
def admin_management(admin_name, quit_admin_management=False, log_file=None): # 管理员登陆成功后的账号操作 while not quit_admin_management: try: user_database = user_info["user_bank"] except KeyError: user_info["user_bank"] = {} user_database = user_info["user_bank"] if not user_info["admin_bank"].get(admin_name): break print("""中国建都银行 管理中心 [%s]已登陆 =========================================== 开户(1) 修改密码(2) 查询账户(s) 存钱(3) 取钱(4) 额度(5) 解锁(6) 挂失(7) 销户(8) 管理员帐户管理(9) 注销(b) 退出(q) =========================================== """ % admin_name) wait_choose = str(input("请选择操作:")).strip() if wait_choose == "1": get_database = register_account(user_database, log_file=log_file) if type(get_database) == dict: user_info["user_bank"] = get_database update_info(user_info) elif wait_choose == "2": get_database = for_super_admin_change_password(user_database, admin_name, log_file=log_file) if type(get_database) == dict: user_info["user_bank"] = get_database update_info(user_info) elif wait_choose == "3": print("该功能暂未开放") elif wait_choose == "4": print("该功能暂未开放") elif wait_choose.lower() == "s": show_account_info(user_database, admin_name, is_admin=True, log_file=log_file) elif wait_choose == "5": get_database = change_user_credit_line(user_database, admin_name, log_file=log_file) if type(get_database) == dict: user_info['user_bank'] = get_database # 更新数据库信息 update_info(user_info) elif wait_choose == "6": get_database = for_admin_unlock_account(user_database, admin_name, log_file=log_file) if type(get_database) == dict: user_info["user_bank"] = get_database update_info(user_info) elif wait_choose == "7": get_database = for_admin_lock_account(user_database, admin_name, log_file=log_file) if type(get_database) == dict: user_info["user_bank"] = get_database update_info(user_info) elif wait_choose == "8": get_database = delete_account(user_database, admin_name, is_admin=False, log_file=log_file) if type(get_database) == dict: user_info['user_bank'] = get_database # 更新数据库信息 update_info(user_info) elif wait_choose == "9": quit_admin_management = management_admin_account( admin_name, quit_admin_management, log_file=log_file) # 对管理员账号进行操作 elif str(wait_choose).lower() in ['q', 'quit', ]: quit_admin_management = True Logger(log_file).write_log(user=admin_name, status=True, event="管理员退出") print("谢谢使用,再见 !") break elif str(wait_choose).lower() in ['b', 'back', ]: Logger(log_file).write_log(user=admin_name, status=True, event="管理员注销") break else: print("操作有误 !!!") return quit_admin_management
def public_user_system(user, quit_user_system=False, log_file=None): while not quit_user_system: user_database = user_info["user_bank"] print("""欢迎使用 中国建都银行 用户[%s]已登陆 =============================================== 个人信息(1) 修改密码(2) 转账(3) 取现(4) 还款(5) 交易记录(6) 操作日志(7) 账单查询(8) 注销(b) 退出(q) =============================================== """ % user) wait_choose = str(input("请选择操作:")).strip() if wait_choose == "1": show_account_info(user_database, user, is_admin=False, log_file=log_file) elif wait_choose == "2": get_database = for_owner_change_password(user_database, user, log_file=log_file) if type(get_database) == dict: user_info["user_bank"] = get_database update_info(user_info) elif wait_choose == "3": get_database = transfer_cash(user_database, user, log_file=log_file, sold_log=sold_log_file) if type(get_database) == dict: user_info["user_bank"] = get_database update_info(user_info) elif wait_choose == "4": get_database = for_admin_withdraw_money(user_database, user, log_file=log_file, sold_log=sold_log_file) if type(get_database) == dict: user_info["user_bank"] = get_database update_info(user_info) elif wait_choose == "6": search_history_log(user, log_file=log_file, sold_log=sold_log_file, is_sold=True) elif wait_choose == "7": search_history_log(user, log_file=log_file) elif str(wait_choose).lower() in [ 'q', 'quit', ]: quit_user_system = True print("谢谢使用,再见 !") Logger(log_file).write_log(user=user, status=True, event="退出") break elif str(wait_choose).lower() in [ 'b', 'back', ]: break else: print("操作有误 !!!") return quit_user_system