Пример #1
0
Файл: job.py Проект: cayamax/ATM
    def wapper(user):
        import shutil
        import os
        from core import cayatools
        while 1:
            new_account = input('输入新的账户名:')
            if new_account in settings.SKIP:
                break

            DB_DIR = 'E:\\PycharmProjects\\py_fullstack\\3.函数\\作业\\ATM\\home'
            tar = '%s\\%s' % (DB_DIR, 'normal')
            new = '%s\\%s%s' % (DB_DIR, 'ATM', new_account)

            if os.path.exists(new):
                print('该用户已存在')
                continue
            else:
                shutil.copytree(tar, new)
                break

        set_info = cayatools.change_caya_value('%s\\%s' %
                                               (new, 'information.txt'))
        set_credit_card = cayatools.change_caya_value(
            '%s\\%s' % (new, 'credit_card_account.txt'))

        set_info('TYPE', 'NORMAL')
        set_info('NAME', new_account)
        set_info('NICK', new_account)
        set_info('LOCK', 3)

        set_credit_card('TOTAL_LIMIT_RMB', 2000)
        set_credit_card('TOTAL_LIMIT_USD', 2000)
        set_credit_card('REPAY_ACCOUNT', new_account)
        print('新增用户成功!密码默认abc123')
Пример #2
0
 def reset_name(self):
     old = input('输入账户密码:')
     if self.psw_match(old):
         name = input('输入新的账户昵称:')
         set_info = cayatools.change_caya_value(self.info_file)
         set_info('NICK', name)
         print('修改成功!')
Пример #3
0
Файл: job.py Проект: cayamax/ATM
    def wapper(user):
        get_info = cayatools.get_line_file(user.credit_file)
        set_value = cayatools.change_caya_value(user.credit_file)

        if word == 'ACCOUNT_DAY':
            print(get_info(word))
            value = input('请输入自动结账的日期:')
        elif word == 'REPAY_ACCOUNT':
            print(get_info(word))
            value = input('请输入自动还款的储蓄账户:')
        elif word == '':
            print(get_info(word))
            value = input('请输入需要修改的值:')
        if value in QUIT:
            return
        else:
            set_value(word, value)
            print('修改成功!')
Пример #4
0
Файл: job.py Проект: cayamax/ATM
    def wapper(user):
        from core import classes
        import os
        print('用户类型:', user.type)
        if user.type != 'ADMIN':
            print('权限不足!')
            return
        else:
            print('权限认证成功!')
            db_dir = settings.DB_DIR
            g = os.walk(db_dir)
            next(g)
            paths = []
            user_tab = []
            for line in g:
                paths.append(line[0])
            for user_path in paths:
                user_tab.append(classes.short_user(user_path))

            line = settings.USER_INFO_FORMAT.format('user name', 'access lock',
                                                    'user type', 'RMB limit',
                                                    'USD limit')
            print(line)
            print('%s' % ('=' * 58))
            for user_short in user_tab:
                if user_short.type == 'ADMIN':
                    continue
                else:
                    line = settings.USER_INFO_FORMAT.format(
                        user_short.name, user_short.lock, user_short.type,
                        user_short.rmb_total_limit, user_short.usd_total_limit)
                    print(line)

            if work_type == 'view':
                input('任意按键继续>>')

            elif work_type in ['freeze user', 'unlock user']:
                while 1:
                    if work_type == 'freeze user':
                        user_name = input('输入你要冻结的用户:')
                        lock = 0
                    elif work_type == 'unlock user':
                        user_name = input('输入你要解锁的用户:')
                        lock = 3

                    if user_name in QUIT:
                        return

                    for user_short in user_tab:
                        if user_short.name == user_name:
                            freeze = cayatools.change_caya_value(
                                user_short.info_file)
                            freeze('LOCK', lock)
                            print('操作成功')
                            return

                    print('用户不存在')

            elif work_type == 'set limit':
                while 1:
                    user_name = input('输入你要设置的用户:')
                    if user_name in QUIT:
                        return

                    currency = input('输入你要设置的货币类型(USD/RMB):')
                    if currency not in ['USD', 'RMB']:
                        print('货币类型输入错误')
                        continue

                    for user_short in user_tab:
                        if user_short.name == user_name:
                            new_total_limit = input('输入新的额度:')
                            set_limit = cayatools.change_caya_value(
                                user_short.credit_file)

                            if currency == 'RMB':
                                old_total_limit = user_short.rmb_total_limit
                                set_limit('TOTAL_LIMIT_RMB', new_total_limit)
                                old_limit = user_short.rmb_current_limit
                                new_limit = int(new_total_limit) - int(
                                    old_total_limit) + int(old_limit)
                                set_limit('CREDIT_LIMIT_RMB', new_limit)
                                print('设置成功!')
                                return

                            elif currency == 'USD':
                                old_total_limit = user_short.usd_total_limit
                                set_limit('TOTAL_LIMIT_USD', new_total_limit)
                                old_limit = user_short.usd_current_limit
                                new_limit = int(new_total_limit) - int(
                                    old_total_limit) + int(old_limit)
                                set_limit('CREDIT_LIMIT_USD', new_limit)
                                print('设置成功!')
                                return

                    print('用户不存在')

            elif work_type == 'reset password':
                while 1:
                    user_name = input('输入你要重置的用户:')
                    for user_short in user_tab:
                        if user_short.name == user_name:
                            user_short.admin_reset_psw()
                            return
                    print('用户不存在')
Пример #5
0
Файл: job.py Проект: cayamax/ATM
        def wapper2(user):
            '''取款'''
            # print(user.saving_file)
            get_baleace = cayatools.get_line_file(user.saving_file)
            change_value = cayatools.change_caya_value(user.saving_file)
            get_info = cayatools.get_line_file(user.credit_file)
            set_credit_card_value = cayatools.change_caya_value(
                user.credit_file)
            log = write_log_file(user.log_file)
            general_log = write_log_file(user.general_log)
            YES = ['YES', 'yes']

            while 1:
                balacne = get_baleace(currency)
                print('您目前的储蓄账户%s余额为:%s元' % (currency, balacne))

                if work == 'draw':
                    draw_now = input('请输入您要取款的金额:')
                    new_balace = int(balacne) - int(draw_now)
                    work_value = draw_now
                    target_user = user.name
                    if new_balace < 0:
                        print('余额不足,请重新输入')
                        continue

                elif work == 'deposit':
                    deposit_now = input('请输入您要存款的金额:')
                    new_balace = int(balacne) + int(deposit_now)
                    work_value = deposit_now
                    target_user = user.name

                elif work == 'transfer':
                    target_user = input('请输入转入账号,核对无误请按ENTER:')
                    transfer_now = input('请输入您要转账的金额:')
                    new_balace = int(balacne) - int(transfer_now)
                    work_value = transfer_now
                    if new_balace < 0:
                        print('余额不足,请重新输入')
                        continue

                elif work == 'repayment':
                    bill_currency = 'CURRENT_BILL_%s' % (currency)
                    credit_card_balace_currency = 'BALANCE_%s' % (currency)

                    bill = get_info(bill_currency)
                    c_balance = get_info(credit_card_balace_currency)
                    print('您的本期%s账单总额为:%s元' % (currency, bill))
                    repay = input('请输入你要还款的金额:')
                    if repay in settings.ALL:
                        repay = bill
                    new_bill = int(bill) - int(repay) if int(bill) > int(
                        repay) else 0
                    new_ccd_balace = int(c_balance) if int(bill) > int(repay) else \
                        int(c_balance) + (int(repay) - int(bill))  # 还多了就计入账户里
                    new_balace = int(balacne) - int(repay)

                    #下面留到自动还款用,主动还款是不会扣除信用卡账户余额的
                    # new_ccd_balace = int(c_balance) - int(repay) if int(repay) < int(c_balance) else 0
                    # new_balace = int(balacne) - (int(repay) - int(c_balance)) \
                    #     if int(repay) > int(c_balance) else int(balacne)

                    if new_balace < 0:
                        print('余额不足')
                        continue

                    set_credit_card_value(bill_currency, new_bill)
                    set_credit_card_value(credit_card_balace_currency,
                                          new_ccd_balace)

                    target_user = user.name
                    ccd_user = '******' % (user.name, 'ccd', currency)
                    work_value = (
                        int(repay) -
                        int(c_balance)) if int(repay) > int(c_balance) else 0

                    log(work, ccd_user, repay, bill, new_bill, user.name)
                    general_log(work, ccd_user, repay, bill, new_bill,
                                user.name)

                #修改文件
                print('请稍候。。。')
                change_value(currency, str(new_balace))

                #记录日志
                target_log = '%s:%s' % (target_user, currency)
                log(work, target_log, work_value, balacne, new_balace,
                    user.name)
                general_log(work, target_log, work_value, balacne, new_balace,
                            user.name)

                time.sleep(5)

                print('您目前的%s余额为:%s元' % (currency, get_baleace(currency)))
                continue_or_not = input('请问是否继续?(继续请输入yes):')
                if continue_or_not not in YES:
                    break
Пример #6
0
import os
import sys

base_dir = os.path.dirname(os.path.dirname(
    os.path.abspath(__file__)))  #输出本项目路径
sys.path.append(base_dir)

# 把本项目目录写入配置文件,本应该是setup文件的工作,首次执行运行以下部分,之后请注释掉
db_dir = '%s\\%s' % (base_dir, 'home')
set_dir = '%s\\%s' % (base_dir, 'config\\settings.py')
from mod import cayatools
cayatools.change_caya_value(set_dir)('DB_DIR', '%r' % db_dir)

from core import main
if __name__ == '__main__':  #当本程序被执行,则…
    main.run()