Esempio n. 1
0
def admin_bank_system(log_file, quit_admin_bank=False):  # 银行管理人员操作平台
    while not quit_admin_bank:
        open_register = "首次注册(2)"
        try:
            admin_database = user_info['admin_bank']
        except KeyError:
            user_info['admin_bank'] = {}
            admin_database = user_info['admin_bank']
        if len(admin_database) > 0:
            open_register = False  # 如果系统存在管理员帐号,则不开放这个功能,后续增加管理员帐号只能登陆后添加
            open_login = "******"
        else:
            open_login, open_register = open_register, True
        print("""欢迎进入    中国建都银行    管理平台
        ============================================
        %s
        返回(b)    退出(q)
        ============================================
        """ % open_login)
        wait_choose = str(input("请选择操作:")).strip()
        if wait_choose == "1" and not open_register:
            get_admin = auth_account(admin_database,
                                     is_admin=True,
                                     log_file=log_file)  # 调用登陆模块
            if get_admin:
                quit_admin_bank = admin_management(
                    get_admin, quit_admin_bank, log_file=log_file)  # 进入管理员操作中心
        elif wait_choose == "2" and open_register:  # 只有数据库没有任何用户的情况才会开放这个注册功能
            get_database = register_account(admin_database,
                                            is_admin=True,
                                            log_file=log_file)  # 调用注册模块
            if get_database:
                user_info['admin_bank'] = get_database  # 更新数据库信息
                update_info(user_info)  # 写入数据库
        elif str(wait_choose).lower() in [
                'q',
                'quit',
        ]:
            quit_admin_bank = True
            print("谢谢使用,再见 !")
            Logger(log_file).write_log(status=True, event="退出")
            break
        elif str(wait_choose).lower() in [
                'b',
                'back',
        ]:
            break
        else:
            print("操作有误 !!!")
    return quit_admin_bank
Esempio n. 2
0
def shop_mall(quit_atm):  # 商城购物中心
    new_goods = goods  # 新建一个字典变量
    new_shopping = Shopping  # 新建一个对象
    os.system('clear')
    get_user = None
    global shop_cart_list
    while not quit_atm:
        try:
            user_database = user_info["shop_account"]
        except KeyError:
            user_info["shop_account"] = {}
            user_database = user_info["shop_account"]
        new_shopping(**new_goods).goods_menu(get_user)  # 获取商品的编号列表,第一个参数为显示的编号顺序,不填则默认为1,第二个是一个字典类型数据
        menu_list = list(new_goods.keys())  # 获取商品编号
        choose = str(input('请选择:')).strip()
        choose_list = re.split(',+|\s+', choose)  # 设置分割符,方便用户多选择操作,将用户输入以分隔符提取出来放在一个列表内
        get_match_list = check_map_list(menu_list, choose_list)
        if get_match_list:
            print("添加[%s]件商品到购物车成功" % len(get_match_list))
            shop_cart_list.extend(get_match_list)
            get_new_goods = new_shopping(**new_goods).shop_list(shop_cart_list, print_now=False)
            if get_new_goods:
                update_info(get_new_goods, file_path='./config/goods.py', name="goods = ")
        elif choose.lower() == "s":
            if shop_cart_list:
                new_shopping(**new_goods).shop_list(shop_cart_list)
                quit_atm = shop_cart(quit_atm, shop_cart_list, new_goods, user_name=get_user)
            else:
                print("您的购物车什么也没有哦 ...")
        elif choose.lower() in ['l', 'login', ]:  # 登陆检查
            get_user = auth_account(user_database, log_file=bank_log_file)
            if get_user:
                new_shopping(**new_goods).login_status(get_user)
        elif choose.lower() in ['r', 'register', ]:  # 注册检查
            get_database = register_account(user_database, log_file=bank_log_file, is_shop_user=True)
            if type(get_database) == dict:
                user_info["shop_account"] = get_database
                update_info(user_info)
                print("用户注册成功")
        elif choose.lower() in ['h', 'help', ]:  # 帮助
            help_doc()
        elif str(choose).lower() in ['q', 'quit', ]:
            quit_atm = True
            print("谢谢使用,再见 !")
            break
        elif str(choose).lower() in ['b', 'back', ]:
            break
        else:
            print("操作有误 !!!")
    return quit_atm
Esempio n. 3
0
def public_login(log_file, quit_public_login=False):
    while not quit_public_login:
        try:
            user_database = user_info["user_bank"]
        except KeyError:
            user_info["user_bank"] = {}
            user_database = user_info["user_bank"]
        print("""欢迎进入    中国建都银行    用户中心
        =========================================
        用户登陆(1)
        返回(b)  退出(q)
        =========================================
        """)
        wait_choose = str(input("请选择操作:")).strip()
        if wait_choose == "1":
            get_user = auth_account(user_database, log_file=log_file)
            if type(get_user) == dict:  # 如果有数据返回,且不是True,则该账户被锁定,写入数据
                user_info["user_bank"] = get_user
                update_info(user_info)
            elif get_user:
                try:
                    user_status = user_info["user_bank"][get_user][
                        "user_status"]
                    if user_status == "0":  # 当登陆成功后,重置用户登陆错误状态
                        user_info["user_bank"][get_user]["user_status"] = "2"
                        update_info(user_info)
                except KeyError:
                    pass
                quit_public_login = public_user_system(get_user,
                                                       quit_public_login,
                                                       log_file)
        elif str(wait_choose).lower() in [
                'q',
                'quit',
        ]:
            quit_public_login = True
            print("谢谢使用,再见 !")
            Logger(log_file).write_log(status=True, event="退出")
            break
        elif str(wait_choose).lower() in [
                'b',
                'back',
        ]:
            break
        else:
            print("操作有误 !!!")
    return quit_public_login
Esempio n. 4
0
def admin_bank_system(log_file, quit_admin_bank=False):  # 银行管理人员操作平台
    while not quit_admin_bank:
        open_register = "首次注册(2)"
        try:
            admin_database = user_info['admin_bank']
        except KeyError:
            user_info['admin_bank'] = {}
            admin_database = user_info['admin_bank']
        if len(admin_database) > 0:
            open_register = False  # 如果系统存在管理员帐号,则不开放这个功能,后续增加管理员帐号只能登陆后添加
            open_login = "******"
        else:
            open_login, open_register = open_register, True
        print("""欢迎进入    中国建都银行    管理平台
        ============================================
        %s
        返回(b)    退出(q)
        ============================================
        """ % open_login)
        wait_choose = str(input("请选择操作:")).strip()
        if wait_choose == "1" and not open_register:
            get_admin = auth_account(admin_database, is_admin=True, log_file=log_file)  # 调用登陆模块
            if get_admin:
                quit_admin_bank = admin_management(get_admin, quit_admin_bank, log_file=log_file)  # 进入管理员操作中心
        elif wait_choose == "2" and open_register:  # 只有数据库没有任何用户的情况才会开放这个注册功能
            get_database = register_account(admin_database, is_admin=True, log_file=log_file)  # 调用注册模块
            if get_database:
                user_info['admin_bank'] = get_database  # 更新数据库信息
                update_info(user_info)  # 写入数据库
        elif str(wait_choose).lower() in ['q', 'quit', ]:
            quit_admin_bank = True
            print("谢谢使用,再见 !")
            Logger(log_file).write_log(status=True, event="退出")
            break
        elif str(wait_choose).lower() in ['b', 'back', ]:
            break
        else:
            print("操作有误 !!!")
    return quit_admin_bank
Esempio n. 5
0
def public_login(log_file, quit_public_login=False):
    while not quit_public_login:
        try:
            user_database = user_info["user_bank"]
        except KeyError:
            user_info["user_bank"] = {}
            user_database = user_info["user_bank"]
        print("""欢迎进入    中国建都银行    用户中心
        =========================================
        用户登陆(1)
        返回(b)  退出(q)
        =========================================
        """)
        wait_choose = str(input("请选择操作:")).strip()
        if wait_choose == "1":
            get_user = auth_account(user_database, log_file=log_file)
            if type(get_user) == dict:  # 如果有数据返回,且不是True,则该账户被锁定,写入数据
                user_info["user_bank"] = get_user
                update_info(user_info)
            elif get_user:
                try:
                    user_status = user_info["user_bank"][get_user]["user_status"]
                    if user_status == "0":  # 当登陆成功后,重置用户登陆错误状态
                        user_info["user_bank"][get_user]["user_status"] = "2"
                        update_info(user_info)
                except KeyError:
                    pass
                quit_public_login = public_user_system(get_user, quit_public_login, log_file)
        elif str(wait_choose).lower() in ['q', 'quit', ]:
            quit_public_login = True
            print("谢谢使用,再见 !")
            Logger(log_file).write_log(status=True, event="退出")
            break
        elif str(wait_choose).lower() in ['b', 'back', ]:
            break
        else:
            print("操作有误 !!!")
    return quit_public_login
Esempio n. 6
0
def shop_mall(quit_atm):  # 商城购物中心
    new_goods = goods  # 新建一个字典变量
    new_shopping = Shopping  # 新建一个对象
    os.system('clear')
    get_user = None
    global shop_cart_list
    while not quit_atm:
        try:
            user_database = user_info["shop_account"]
        except KeyError:
            user_info["shop_account"] = {}
            user_database = user_info["shop_account"]
        new_shopping(**new_goods).goods_menu(
            get_user)  # 获取商品的编号列表,第一个参数为显示的编号顺序,不填则默认为1,第二个是一个字典类型数据
        menu_list = list(new_goods.keys())  # 获取商品编号
        choose = str(input('请选择:')).strip()
        choose_list = re.split(',+|\s+',
                               choose)  # 设置分割符,方便用户多选择操作,将用户输入以分隔符提取出来放在一个列表内
        get_match_list = check_map_list(menu_list, choose_list)
        if get_match_list:
            print("添加[%s]件商品到购物车成功" % len(get_match_list))
            shop_cart_list.extend(get_match_list)
            get_new_goods = new_shopping(**new_goods).shop_list(
                shop_cart_list, print_now=False)
            if get_new_goods:
                update_info(get_new_goods,
                            file_path='./config/goods.py',
                            name="goods = ")
        elif choose.lower() == "s":
            if shop_cart_list:
                new_shopping(**new_goods).shop_list(shop_cart_list)
                quit_atm = shop_cart(quit_atm,
                                     shop_cart_list,
                                     new_goods,
                                     user_name=get_user)
            else:
                print("您的购物车什么也没有哦 ...")
        elif choose.lower() in [
                'l',
                'login',
        ]:  # 登陆检查
            get_user = auth_account(user_database, log_file=bank_log_file)
            if get_user:
                new_shopping(**new_goods).login_status(get_user)
        elif choose.lower() in [
                'r',
                'register',
        ]:  # 注册检查
            get_database = register_account(user_database,
                                            log_file=bank_log_file,
                                            is_shop_user=True)
            if type(get_database) == dict:
                user_info["shop_account"] = get_database
                update_info(user_info)
                print("用户注册成功")
        elif choose.lower() in [
                'h',
                'help',
        ]:  # 帮助
            help_doc()
        elif str(choose).lower() in [
                'q',
                'quit',
        ]:
            quit_atm = True
            print("谢谢使用,再见 !")
            break
        elif str(choose).lower() in [
                'b',
                'back',
        ]:
            break
        else:
            print("操作有误 !!!")
    return quit_atm