コード例 #1
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def change_user_credit_line(database, admin_name, log_file=None):
    select_user = str(input("请输入要修改信用额度的用户名: ")).strip()
    credit_limit = add_credit_limit()
    current_info = search_account_info(database, select_user)
    if type(current_info) == dict:
        current_credit_limit = database[select_user]["credit_limit"]
        current_available_credit = database[select_user]["available_credit"]
        current_cash_advance_limit = database[select_user][
            "cash_advance_limit"]
        if current_credit_limit == current_available_credit:
            current_available_credit = credit_limit
            current_cash_advance_limit = str(float(credit_limit) / 2)
        get_database = change_account_info(
            database, select_user, {
                "credit_limit": credit_limit,
                "cash_advance_limit": current_cash_advance_limit,
                "available_credit": current_available_credit
            })
        if get_database:
            print("用户额度修改成功,目前该用户额度为[%s]" % credit_limit)
            Logger(log_file).write_log(user=admin_name,
                                       status=True,
                                       event="用户%s额度修改成功,额度已修改为[%s]" %
                                       (select_user, credit_limit))
            return get_database
    else:
        Logger(log_file).write_log(user=admin_name,
                                   status=False,
                                   event="用户%s不存在,修改额度失败" % select_user)
        return False
コード例 #2
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def for_super_admin_change_password(database, admin_name, log_file=None):
    select_user = str(input("请输入要更改的用户名:")).strip()
    account_info = search_account_info(database, select_user)
    if account_info:
        new_password = str(input("请输入新密码:")).strip()
        repeat_password = str(input("请再次输入新密码:")).strip()
        if new_password == repeat_password and new_password != "":
            old_password = account_info['password']
            change_admin_password_check = change_password(
                database, select_user, old_password, new_password)
            if change_admin_password_check:
                print("用户[%s]密码修改成功 !" % select_user)
                Logger(log_file).write_log(user=admin_name,
                                           status=True,
                                           event="用户%s密码修改成功" % select_user)
                return change_admin_password_check
        else:
            if new_password == "":
                print("密码不能为空 !!!")
            else:
                print("两次输入不一致")
            Logger(log_file).write_log(user=admin_name,
                                       status=False,
                                       event="用户%s密码修改失败" % select_user)
            return False
コード例 #3
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def delete_account(database, admin_name, is_admin=False, log_file=None):
    select_user = str(input("请输入要删除的用户名:")).strip()
    delete_check = UserInfo(**database).delete_account(
        select_user)  # 如果返回的不是字典,则说明不存在该用户
    if not is_last_super_admin(delete_check) or (not is_admin and
                                                 type(delete_check) == dict):
        wait_choose = str(input("确认删除[%s]吗 y/n:" % select_user)).strip()
        if wait_choose.lower() in [
                "y",
                "yes",
        ]:
            print("用户[%s]已被删除" % select_user)
            Logger(log_file).write_log(user=admin_name,
                                       status=True,
                                       event="用户%s删除成功" % select_user)
            return delete_check
        else:
            print("操作未改变 !!!")
            return False
    elif type(delete_check) == dict:
        print("管理员[%s]是最后一个具有超级管理权限的账号,操作不允许" % select_user)
        Logger(log_file).write_log(user=admin_name,
                                   status=False,
                                   event="用户%s删除失败" % select_user)
        return False
コード例 #4
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def search_history_log(user_name, log_file, sold_log=None, is_sold=False):
    """
    :param user_name: 操作的用户名
    :param log_file: 银行基本日志文件
    :param sold_log: 银行交易日志文件
    :param is_sold: 是否查询交易日志
    :return:
    """
    start_date = select_date("开始日期", is_sold=is_sold)
    end_date = select_date("结束日期", is_sold=is_sold)
    check_date = get_diff_days(start_date, end_date)
    if is_sold and sold_log:
        Logger(log_file).write_log(user=user_name,
                                   status="True",
                                   event="查询交易记录日志")
        log_file = sold_log
    if check_date and int(check_date) >= 0:
        get_match_list = Logger(log_file).get_match_log(user=user_name,
                                                        start_time=start_date,
                                                        end_time=end_date)
        show_format_log(get_match_list, is_sold=is_sold)
        return True
    else:
        print("日期范围输入有误!!!")
        return False
コード例 #5
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def atm_self_service(quit_atm_self_service=False):  # ATM自助服务系统
    while not quit_atm_self_service:
        print("""欢迎使用    中国建都银行    自助服务系统
        ============================================
        普通客户大众版平台(1)    银行前台专业版管理中心(2)
        返回(b)    退出(q)
        ============================================
        """)
        wait_choose = str(input("请选择操作:")).strip()
        if wait_choose == "1":
            Logger(bank_log_file).write_log(status=True, event="进入普通客户大众版平台")
            quit_atm_self_service = public_login(
                bank_log_file, quit_atm_self_service)  # 进入大众版登陆系统
        elif wait_choose == "2":
            Logger(bank_log_file).write_log(user=None,
                                            status=True,
                                            event="进入银行前台管理页面")
            quit_atm_self_service = admin_bank_system(
                bank_log_file, quit_atm_self_service)  # 进入管理员操作平台
        elif str(wait_choose).lower() in [
                'q',
                'quit',
        ]:
            quit_atm_self_service = True
            print("谢谢使用,再见 !")
            Logger(bank_log_file).write_log(status=True, event="退出")
            break
        elif str(wait_choose).lower() in [
                'b',
                'back',
        ]:
            break
        else:
            print("操作有误 !!!")
    return quit_atm_self_service
コード例 #6
0
ファイル: __init__.py プロジェクト: zengchunyun/_
 def add_info(database,
              is_admin=False,
              log_file=None,
              is_shop_user=False):  # 传入的参数是一个字典
     """
     :param database: 含有用户信息的字典
     :param is_admin: 是否是管理员
     :param log_file: 日志文件名
     :param is_shop_user: 是否商城用户
     :return:
     """
     before = database
     after = register_func(database)  # 得到增加用户后的字典
     if is_shop_user:  # 如果是商城用户注册,直接返回
         return after
     if after:
         database = after
         update_user = set(before).symmetric_difference(
             set(after))  # 把增加的用户提取出来,更新
         add_user_info = add_common_info(is_admin)  # 针对该用户添加额外的补充用户信息
         if len(database) == 1 and is_admin:  # 当系统为第一次使用时,自动把权限提升为超级管理员级别
             add_user_info['level'] = "0"
         print("用户[%s]注册成功 !" % list(update_user)[0])
         Logger(log_file).write_log(user=list(update_user)[0],
                                    status=True,
                                    event="用户注册成功")
         return change_account_info(database,
                                    list(update_user)[0], add_user_info)
     else:
         Logger(log_file).write_log(status=False, event="用户注册失败")
         return False
コード例 #7
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def transfer_cash(database, user_name, log_file, sold_log=None):
    count = 0
    user_database = search_account_info(database, user_name)
    user_money = user_database["credit_limit"]
    import time
    while count < 3:
        select_user = str(input("请输入需要转账的卡号:"))
        if select_user == user_name:
            print("不能给自己转账")
            continue
        get_select_user_database = search_account_info(database, select_user)
        if type(get_select_user_database) == dict:
            current_money = get_select_user_database["credit_limit"]
            money = str(input("请输入需要转账金额:"))
            if not str(money).isdigit():
                print("输入错误, 请重新输入!")
                continue
            if float(money) > float(user_money):
                print("余额不足,请重新输入")
                continue
            while True:
                wait_choose = str(input("是否需要验证对方信息\n\t默认验证\nyes/no: "))
                if wait_choose.lower() in ["n", "no"]:
                    break
                wait_choose = str(input("请输入对方姓名:"))
                if wait_choose == get_select_user_database["cn_name"]:
                    break
                else:
                    print("验证未通过")
            wait_choose = str(
                input("确认转账?\n您将给用户[%s]转账金额为%s元\n请确认 yes/no: " %
                      (select_user, money)))
            if wait_choose.lower() in ["y", "yes"]:
                user_database["credit_limit"] = str(
                    float(user_money) - float(money))
                get_select_user_database["credit_limit"] = str(
                    float(current_money) + float(money))
                current_time = time.strftime("%Y/%m/%d %H:%M:%S",
                                             time.localtime())
                Logger(sold_log).write_log(user=user_name,
                                           status="%s" % money,
                                           event="给用户[%s]转账成功,转账金额为[%s]" %
                                           (select_user, money),
                                           cur_time=current_time)
                Logger(log_file).write_log(
                    user=user_name,
                    status="transfer",
                    event="给用户[%s]转账成功,转账金额为[%s]" % (select_user, money),
                )
                return database
            else:
                print("操作取消 !!")
                break
        count += 1
    return False
コード例 #8
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def for_admin_withdraw_money(database,
                             user_name,
                             log_file,
                             sold_log,
                             is_admin=False):
    count = 0
    if is_admin:
        select_user = str(input("请输入需要取现的用户名: "))
    else:
        select_user = user_name
    get_select_user_db = search_account_info(database, select_user)
    if type(get_select_user_db) == dict:
        while count < 3:
            count += 1
            current_money = get_select_user_db["cash_advance_limit"]
            wait_choose = str(input("请输入取现金额:"))
            try:
                get_money = float(wait_choose)
                total = get_money * 1.05
                print("手续费为金额的%5,实际扣除金额为[{0}]".format(total))
                current_money = float(current_money)
                if current_money < total:
                    print("取现金额不足,请重新输入")
                    continue
                elif get_money % 100 != 0:
                    print("取现金额只能为100整数")
                    continue
                while True:
                    choose = str(input("确认取钱吗? yes/no: "))
                    if choose.lower() in ["y", "yes"]:
                        get_money = total
                        reduce_money = current_money - get_money
                        get_select_user_db["cash_advance_limit"] = reduce_money
                        print("您已取现[%s],剩余可用现金额度[%s]元" %
                              (get_money, reduce_money))
                        Logger(log_file).write_log(
                            user=user_name,
                            status="True",
                            event="取现成功,取现金额[%s]元,剩余[%s]元" %
                            (get_money, reduce_money))
                        Logger(sold_log).write_log(
                            user=user_name,
                            status=get_money,
                            event="取现成功,取现金额[%s]元,剩余[%s]元" %
                            (get_money, reduce_money),
                            date_format="/")
                        return database
                    else:
                        count += 3
                        print("操作取消")
                        break
                else:
                    break
            except KeyError:
                print("输入错误,金额不能是非数字类型")
コード例 #9
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def for_admin_unlock_account(database, admin_name, log_file=None):
    select_user = str(input("请选择需要解锁的用户:")).strip()
    get_database = unlock_account(database, select_user, log_file=log_file)
    if get_database:
        print("用户[%s]解锁成功" % select_user)
        Logger(log_file).write_log(user=admin_name,
                                   status=True,
                                   event="用户%s解锁成功" % select_user)
        return get_database
    else:
        Logger(log_file).write_log(user=admin_name,
                                   status=False,
                                   event="用户%s不存在,解锁失败" % select_user)
        return False
コード例 #10
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def unlock_account(database, user, log_file=None):  # 解锁账户
    import time
    cur_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    Logger(log_file).write_log(user=user, status="unlock", event="用户解锁成功")
    return UserInfo(**database).change_info(user=user,
                                            user_status="2",
                                            status_time=cur_time)
コード例 #11
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def show_account_info(database, user_name, is_admin=False, log_file=None):
    if type(database) != dict:
        Logger(log_file).write_log(user=user_name, status=False, event="查询失败")
        return False
    if is_admin:
        select_user = str(input("请输入要查询的用户信息: ")).strip()
    else:
        select_user = user_name
    get_database = search_account_info(database, select_user)
    if type(get_database) == dict:
        try:
            cn_name = get_database['cn_name']
            en_name = get_database['en_name']
            age = get_database['age']
            mail = get_database['mail']
            birthday = get_database['birthday']
            mobile = get_database['contact']
            company = get_database['company']
            user_status = user_status_define(get_database['user_status'])
            cash_advance_limit = get_database['cash_advance_limit']
            credit_limit = get_database['credit_limit']
            available_credit_limit = get_database['available_credit']
            statement_date = get_database['statement_date']
            payment_due_date = get_database["payment_due_date"]
            new_charges = get_database["new_charges"]
            current_balance = get_database["current_balance"]
            minimum_payment = get_database["minimum_payment"]
        except KeyError:
            pass
        print("""
    用户[%s]信息如下
    账户信息
    ====================================================
    用户名                %s
    中文名                %s
    英文名                %s
    年龄                  %s
    邮箱                  %s
    生日                  %s
    手机号码               %s
    单位全称               %s
    用户状态               %s
    信用额度               ¥%s
    可用额度               ¥%s
    未出账分期本金          ¥%s
    预借现金可用额度         ¥%s
    每月账单日              %s日

    还款信息
    ====================================================
    自动还款              未开通
    本期到期还款日          %s日
    本期账单金额          ¥%s
    本期剩余应还金额       ¥%s
    本期剩余最低还款金额    ¥%s
    ====================================================
    """ % (select_user, select_user, cn_name, en_name, age, mail, birthday,
           mobile, company, user_status, credit_limit, available_credit_limit,
           0, cash_advance_limit, statement_date, payment_due_date,
           new_charges, current_balance, minimum_payment))
コード例 #12
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def for_admin_lock_account(database, admin_name, log_file=None):
    select_user = str(input("请选择需要挂失的用户:")).strip()
    get_database = lock_account(database=database,
                                user=select_user,
                                log_file=log_file,
                                user_status="1")
    if get_database:
        print("用户[%s]挂失成功" % select_user)
        Logger(log_file).write_log(user=admin_name,
                                   status=True,
                                   event="用户%s挂失成功" % select_user)
        return get_database
    else:
        Logger(log_file).write_log(user=admin_name,
                                   status=False,
                                   event="用户%s不存在,挂失失败" % select_user)
        return False
コード例 #13
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def lock_account(database, user, log_file=None, user_status="0"):  # 锁定账户
    get_database = UserInfo(**database).change_info(user,
                                                    user_status=user_status)
    if get_database:
        Logger(log_file).write_log(user=user, status="lock", event="用户已被冻结")
        return get_database
    else:
        return False
コード例 #14
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def change_admin_permission(database, admin_name, log_file=None):  # 更改管理员帐号权限
    if is_super_admin(database, admin_name):
        select_user = str(input("请输入要更改的用户名:")).strip()
        if search_account_info(database, select_user):
            level = add_admin_level()
            wait_choose = str(
                input("确认修改[%s]权限修改为[%s]吗: y/n " %
                      (select_user, level_define(level)))).strip()
            if wait_choose.lower() in [
                    "y",
                    "yes",
            ]:
                change_level_check = change_account_info(
                    database, select_user, {'level': level})
                if change_level_check:
                    if is_last_super_admin(change_level_check):
                        print("管理员[%s]是最后一个具有超级管理权限的帐号,操作不允许" % select_user)
                        Logger(log_file).write_log(user=admin_name,
                                                   status=False,
                                                   event="用户%s权限修改失败" %
                                                   select_user)
                        change_account_info(database, select_user,
                                            {'level': "0"})  # 回退权限
                        return False
                    else:
                        print("管理员[%s]级别已修改为[%s]" %
                              (select_user, level_define(level)))
                        Logger(log_file).write_log(
                            user=admin_name,
                            status=True,
                            event="用户%s权限修改成功,级别已修改为[%s]" %
                            (select_user, level_define(level)))
                        return change_level_check
            else:
                print("操作未改变 !!!")
                return False
    else:
        print("普通管理员[%s]没有权限修改管理员账号信息" % admin_name)
        Logger(log_file).write_log(user=admin_name,
                                   status=False,
                                   event="操作不允许")
        return False
コード例 #15
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def modify_admin_account_info(database,
                              admin_name,
                              is_admin=False,
                              log_file=None):  # 任何管理员都能修改普通信息
    select_user = str(input("请输入要更改的用户名:")).strip()
    if search_account_info(database, select_user):
        common_info = change_common_info(is_admin)
        change_check = change_account_info(database, select_user, common_info)
        if change_check:
            Logger(log_file).write_log(user=admin_name,
                                       status=True,
                                       event="用户%s信息修改成功" % select_user)
            return change_check
コード例 #16
0
ファイル: __init__.py プロジェクト: zengchunyun/_
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
コード例 #17
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def for_owner_change_password(database, user_name, log_file=None):
    old_password = str(input("请输入当前密码:")).strip()
    new_password = str(input("请输入新密码:")).strip()
    repeat_password = str(input("请再次确认新密码:")).strip()
    if new_password == repeat_password and new_password != "":
        change_admin_password_check = change_password(database, user_name,
                                                      old_password,
                                                      new_password)
        if change_admin_password_check:
            print("用户[%s]密码修改成功 !" % user_name)
            Logger(log_file).write_log(user=user_name,
                                       status=False,
                                       event="用户%s密码修改失败" % user_name)
            return change_admin_password_check
    else:
        if new_password == "":
            print("密码不能为空 !!!")
        else:
            print("两次输入不一致 !!!")
        Logger(log_file).write_log(user=user_name,
                                   status=False,
                                   event="用户%s密码修改失败" % user_name)
        return False
コード例 #18
0
ファイル: __init__.py プロジェクト: zengchunyun/_
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
コード例 #19
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def management_admin_account(admin_name,
                             quit_management_account,
                             log_file=None):
    while not quit_management_account:
        admin_database = user_info['admin_bank']
        if not admin_database.get(admin_name):
            break
        print("""中国建都银行    管理中心    [%s]已登陆
        ===========================================
        添加管理账号(1)
        删除管理账号(2)
        更改账号权限(3)
        更改账号信息(4)
        修改管理员密码(5)
        返回(b)  退出(q)
        ===========================================
        """ % admin_name)
        wait_choose = str(input("请选择操作:")).strip()
        if wait_choose == "1":
            get_database = add_admin_account(admin_database,
                                             admin_name,
                                             is_admin=True,
                                             log_file=log_file)
            if type(get_database) == dict:
                user_info['admin_bank'] = get_database  # 更新数据库信息
                update_info(user_info)
        elif wait_choose == "2":
            get_database = delete_account(admin_database,
                                          admin_name,
                                          is_admin=True,
                                          log_file=log_file)
            if type(get_database) == dict:
                user_info['admin_bank'] = get_database  # 更新数据库信息
                update_info(user_info)
        elif wait_choose == "3":
            get_database = change_admin_permission(admin_database,
                                                   admin_name,
                                                   log_file=log_file)
            if type(get_database) == dict:
                user_info['admin_bank'] = get_database  # 更新数据库信息
                update_info(user_info)
        elif wait_choose == "4":
            get_database = modify_admin_account_info(admin_database,
                                                     admin_name,
                                                     is_admin=True,
                                                     log_file=log_file)
            if type(get_database) == dict:
                user_info['admin_bank'] = get_database  # 更新数据库信息
                update_info(user_info)
        elif wait_choose == "5":
            get_database = change_admin_password(admin_database,
                                                 admin_name,
                                                 log_file=log_file)
            if type(get_database) == dict:
                user_info['admin_bank'] = get_database  # 更新数据库信息
                update_info(user_info)
        elif str(wait_choose).lower() in [
                'q',
                'quit',
        ]:
            quit_management_account = True
            Logger(log_file).write_log(user=admin_name,
                                       status=True,
                                       event="管理员退出")
            print("谢谢使用,再见 !")
            break
        elif str(wait_choose).lower() in [
                'b',
                'back',
        ]:
            break
        else:
            print("操作有误 !!!")
    return quit_management_account
コード例 #20
0
ファイル: __init__.py プロジェクト: zengchunyun/_
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
コード例 #21
0
ファイル: __init__.py プロジェクト: zengchunyun/_
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
コード例 #22
0
ファイル: __init__.py プロジェクト: zengchunyun/_
def auth_account(database, is_admin=False, log_file=None):
    user = str(input("请输入用户名:")).strip()
    password = str(input("请输入密码:")).strip()
    import time
    today = time.strftime("%Y-%m-%d", time.localtime())
    start_time = None
    last_login_time = None
    if not is_admin:
        get_database = search_account_info(database, user)
        if type(get_database) == dict:
            if get_database.get("user_status"):
                if get_database["user_status"] == "1":
                    print("该用户已被冻结,请联系工作人员解锁 !!")
                    Logger(log_file).write_log(user=user,
                                               status=False,
                                               event="用户登陆失败")
                    return False
                if get_database.get("status_time"):  # 尝试获取最后一次解锁时间
                    start_time = get_database["status_time"]
                get_match_list = Logger(log_file).get_match_log(
                    user=user, status="login")  # 获取登陆成功的日志
                if get_match_list:
                    last_login = get_match_list[-1]
                    last_login_time = " ".join(
                        last_login.split()[0:2])  # 获取最后一次登陆成功的时间
                if start_time and last_login_time:  # 当既有解锁时间,又有成功登陆时间,则比较大小
                    if start_time < last_login_time:  # 如果登陆时间比解锁时间晚,则登陆时间赋值start_time
                        start_time = last_login_time
                elif last_login_time:  # 否则,如果只有登陆时间,则也赋值给start_time
                    start_time = last_login_time
                if start_time and start_time < today:
                    start_time = today
                if get_database["user_status"] == "0" and Logger(
                        log_file).get_match_count(user=user,
                                                  status=False,
                                                  start_time=start_time) > 2:
                    print("该用户已被锁定,请联系工作人员解锁,或第二天再次尝试!")
                    Logger(log_file).write_log(user=user,
                                               status=False,
                                               event="用户登陆失败")
                    return False
        else:
            return False
    login_check = UserInfo(**database).login(user, password)
    if login_check and is_admin:  # 如果登陆成功,且是管理员身份登陆,则返回当前管理员用户名
        Logger(log_file).write_log(user=user, status=True, event="管理员登陆成功")
        return user
    else:
        if login_check:
            Logger(log_file).write_log(user=user,
                                       status="login",
                                       event="用户登陆成功")
            return user
        else:
            print("用户名或密码错误")
            Logger(log_file).write_log(user=user, status=False, event="用户登陆失败")
            if not is_admin:
                get_database = search_account_info(database, user)
                if type(get_database) == dict:
                    error_count = Logger(log_file).get_match_count(
                        user=user, status=False, start_time=start_time)
                    if error_count > 2:
                        get_database = lock_account(database,
                                                    user,
                                                    log_file=log_file)
                        print("该用户已被锁定,请联系工作人员解锁,或第二天再次尝试!")
                        return get_database
            return False