自制银行ATM系统(测试版)

213 阅读5分钟
# coding=utf-8
import time
import random

long_ = "-" * 30
id_car = 10663989
pass_word = str('gf123456')
bank_balance = [3000]
sum_bank = len(bank_balance)
withdrawals = ({
    '1month':{
        '取款时间':20200123,
        '取款金额':400
        },
    '2month':{
        '取款时间':20200225,
        '取款金额':2000
        },
    '3month':{
        '取款时间':20200326,
        '取款金额':1900
    },
    '4month':{
        '取款时间':20200425,
        '取款金额':2000
    },
    '5month':{
        '取款时间':20200526,
        '取款金额':1900
    },
    '6month':{
        '取款时间':20200625,
        '取款金额':2020
    },
    '7month':{
        '取款时间':20200726,
        '取款金额':1900
    },
    '11month':{
        '取款时间':202001126,
        '取款金额':1900
    },
    '12month':{
        '取款时间':20201226,
        '取款金额':1900
    },
})
Transfer_record = ({
    '1month':{
        '取款时间':20200124,
        '取款金额':3200,
        '支付説明': '平安保险银行代扣'

    },
    '2month':{
        '取款时间':20200225,
        '取款金额':2000,
        '支付説明': '银行柜台取款'

    },
    '3month':{
        '取款时间':20200326,
        '取款金额':1900,
        '支付説明': '银行柜台取款'

    },
    '4month':{
        '取款时间':20200425,
        '取款金额':2000,
        '支付説明': '银行柜台取款'

    },
    '5month':{
        '取款时间':20200526,
        '取款金额':1900,
        '支付説明': '银行柜台取款'

    },
    '6month':{
        '取款时间':20200625,
        '取款金额':2020,
        '支付説明': '银行柜台取款'

    },
    '7month':{
        '取款时间':20200726,
        '取款金额':1900,
        '支付説明': '银行柜台取款'

    },
    '11month':{
        '取款时间':202001126,
        '取款金额':1900,
        '支付説明': '银行柜台取款'

    },
    '12month':{
        '取款时间':20201226,
        '取款金额':1900,
        '支付説明': '银行柜台取款'

    }
})

def psd_test(number):
    """校验密码是否正确"""
    if number != str('gf123456'):
        re_enter = str(input("Sorry your incorrect password number ,Please re-enter:"))
        psd_test(re_enter)
    elif number == str('gf123456'):
        return print("Success")
def info_withdraws(number):
    """余额查询"""
    if number <= sum_bank:
        withdrawals_all = sum_bank - number
        print("取款成功,目前余额为:{}".format(withdrawals_all))
    else:
        re_withdrawals = int(input("余额不足,请输入其他金额:"))
        info_withdraws(re_withdrawals)
        return
def info_money(number):
    """存款"""
    if number == 0:
        print("您没有存入金额,或未正确放入纸币,请重新操作,正在开启点钞口……")
        time.sleep(3)
        re_disosit = int(input("请把现金整齐放入点钞口,请勿放入其他杂物:"))
        info_money(re_disosit)
    else:
        bank_balance.append(int(number))
        sum_bank_balance = sum(bank_balance)
        print('存入成功,您当前余额为:{}'.format(sum_bank_balance))
        return
def car_test(number):
    """银行卡号校验"""
    if number != 10663989:
        re_enter = int(input("Sorry your incorrect account number ,Please re-enter:"))
        car_test(re_enter)
    elif number == 10663989:
        return print("Success")
def month_test(list):
    """取款记录处理"""
    if list is None:
        print("抱歉,当月没有取款记录")
    elif list is not None:
        list_len = int(len(list) / 2)
        print("正在查询中,请稍候……"),time.sleep(1)
        time.sleep(1)
        print("查询结果显示当月一共{}笔取款记录".format(list_len))
        for key,value in list.items():
            print(key,value)
        return
def transfer_test(list):
    """流水查询处理"""
    if list is None:
        print("抱歉,当月没有取款记录")
    elif list is not None:
        list_len = int(len(list) / 3)
        print("正在查询中,请稍候……"),time.sleep(1)
        time.sleep(1)
        print("查询结果显示当月一共{}笔取款记录".format(list_len))
        for key,value in list.items():
            print(key,value)
        return


print (long_," Welcome to GF Bank ",long_)
info_car = input("Please input your account:")
car_test(int(info_car))
info_psd = input("Please input your password:")
psd_test(str(info_psd))
print(long_," Welcome to the Service selection page ",long_)
click_choose = int(input("Please choose language:1.Chinese 2.English 3.Other :"))
if click_choose == 1:
    print(long_," 欢迎使用中文操作界面 ",long_)
    choose_server = int(input("请选择需要的服务:1.查询余额 2.现金存款 3.现金取款 4.查询取款记录 5.查询转账记录:"))
    if choose_server == 1:
        print("请稍后,正在查询中……")
        time.sleep(5)
        money = random.randint(0,10000)
        print("查询结果:您的余额为{}".format(money))
        #待优化点击上一步继续使用其他功能
    elif choose_server == 2:
        print("请稍后,正在开启点钞口……")
        time.sleep(3)
        disosit = int(input("请把现金整齐放入点钞口,请勿放入其他杂物:"))
        info_money(disosit)
        #待优化点击上一步继续使用其他功能
    elif choose_server == 3:
        withdrawals = int(input("请输入您的取款金额:"))
        info_withdraws(withdrawals)
        #待优化点击上一步继续使用其他功能
    elif choose_server == 4:
        info_month = int(input("请选择查询月份:"))
        if info_month == 1:
            month = withdrawals.get('1month')
            month_test(month)
        elif info_month == 2:
            month = withdrawals.get('2month')
            month_test(month)
        elif info_month == 3:
            month = withdrawals.get('3month')
            month_test(month)
        elif info_month == 4:
            month = withdrawals.get('4month')
            month_test(month)
        elif info_month == 5:
            month = withdrawals.get('5month')
            month_test(month)
        elif info_month == 6:
            month = withdrawals.get('6month')
            month_test(month)
        elif info_month == 7:
            month = withdrawals.get('7month')
            month_test(month)
        elif info_month == 8:
            month = withdrawals.get('8month')
            month_test(month)
        elif info_month == 9:
            month = withdrawals.get('9month')
            month_test(month)
        elif info_month == 10:
            month = withdrawals.get('10month')
            month_test(month)
        elif info_month == 11:
            month = withdrawals.get('11month')
            month_test(month)
        elif info_month == 12:
            month = withdrawals.get('12month')
            month_test(month)
        #待优化点击上一步继续使用其他功能
    elif choose_server == 5:
        info_month = int(input("请选择查询月份:"))
        if info_month == 1:
            month = withdrawals.get('1month')
            month_test(month)
        elif info_month == 2:
            month = withdrawals.get('2month')
            month_test(month)
        elif info_month == 3:
            month = withdrawals.get('3month')
            month_test(month)
        elif info_month == 4:
            month = withdrawals.get('4month')
            month_test(month)
        elif info_month == 5:
            month = withdrawals.get('5month')
            month_test(month)
        elif info_month == 6:
            month = withdrawals.get('6month')
            month_test(month)
        elif info_month == 7:
            month = withdrawals.get('7month')
            month_test(month)
        elif info_month == 8:
            month = withdrawals.get('8month')
            month_test(month)
        elif info_month == 9:
            month = withdrawals.get('9month')
            month_test(month)
        elif info_month == 10:
            month = withdrawals.get('10month')
            month_test(month)
        elif info_month == 11:
            month = withdrawals.get('11month')
            month_test(month)
        elif info_month == 12:
            month = withdrawals.get('12month')
            month_test(month)
        # 待优化点击上一步继续使用其他功能

if click_choose == 2:
    print(long_," Welcome to the Chinese operation interface ",long_)
    choose_server = int(input(
        "Please select the services you need: 1. Balance query 2. Cash deposit 3.Cash withdrawals 4.Query the withdrawal record 5. Inquiry of transfer record:"))
    if choose_server == 1:
        print("Please wait a moment, in process......")
        time.sleep(5)
        money = random.randint(0, 10000)
        print("Query result: your balance is {}".format(money))
        # 待优化点击上一步继续使用其他功能
    elif choose_server == 2:
        print("Just a moment, please. Opening the counting gate...")
        time.sleep(3)
        disosit = int(input("Please put the cash neatly into the counting slot, do not put other sundry items:"))
        info_money(disosit)
        # 待优化点击上一步继续使用其他功能
    elif choose_server == 3:
        withdrawals = int(input("Please enter your withdrawal amount:"))
        info_withdraws(withdrawals)
        # 待优化点击上一步继续使用其他功能
    elif choose_server == 4:
        info_month = int(input("Please select the month of enquiry:"))
        if info_month == 1:
            month = withdrawals.get('1month')
            month_test(month)
        elif info_month == 2:
            month = withdrawals.get('2month')
            month_test(month)
        elif info_month == 3:
            month = withdrawals.get('3month')
            month_test(month)
        elif info_month == 4:
            month = withdrawals.get('4month')
            month_test(month)
        elif info_month == 5:
            month = withdrawals.get('5month')
            month_test(month)
        elif info_month == 6:
            month = withdrawals.get('6month')
            month_test(month)
        elif info_month == 7:
            month = withdrawals.get('7month')
            month_test(month)
        elif info_month == 8:
            month = withdrawals.get('8month')
            month_test(month)
        elif info_month == 9:
            month = withdrawals.get('9month')
            month_test(month)
        elif info_month == 10:
            month = withdrawals.get('10month')
            month_test(month)
        elif info_month == 11:
            month = withdrawals.get('11month')
            month_test(month)
        elif info_month == 12:
            month = withdrawals.get('12month')
            month_test(month)
        # 待优化点击上一步继续使用其他功能
    elif choose_server == 5:
        info_month = int(input("Please select the month of enquiry:"))
        if info_month == 1:
            month = withdrawals.get('1month')
            month_test(month)
        elif info_month == 2:
            month = withdrawals.get('2month')
            month_test(month)
        elif info_month == 3:
            month = withdrawals.get('3month')
            month_test(month)
        elif info_month == 4:
            month = withdrawals.get('4month')
            month_test(month)
        elif info_month == 5:
            month = withdrawals.get('5month')
            month_test(month)
        elif info_month == 6:
            month = withdrawals.get('6month')
            month_test(month)
        elif info_month == 7:
            month = withdrawals.get('7month')
            month_test(month)
        elif info_month == 8:
            month = withdrawals.get('8month')
            month_test(month)
        elif info_month == 9:
            month = withdrawals.get('9month')
            month_test(month)
        elif info_month == 10:
            month = withdrawals.get('10month')
            month_test(month)
        elif info_month == 11:
            month = withdrawals.get('11month')
            month_test(month)
        elif info_month == 12:
            month = withdrawals.get('12month')
            month_test(month)
    # 待优化点击上一步继续使用其他功能
if choose_server == 3:
    print("Sorry service available for the time being ")