master
Hhhhzh 2 years ago
parent b1f9f16a38
commit 5c48bc9cf7

@ -0,0 +1,3 @@
# 默认忽略的文件
/shelf/
/workspace.xml

@ -0,0 +1 @@
银行系统.py

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.8 (py)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>

@ -0,0 +1,22 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="E266" />
<option value="E303" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N802" />
<option value="N806" />
<option value="N803" />
</list>
</option>
</inspection_tool>
</profile>
</component>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (py)" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/bankSystem.iml" filepath="$PROJECT_DIR$/.idea/bankSystem.iml" />
</modules>
</component>
</project>

@ -0,0 +1,94 @@
'''
管理员界面
类名View
属性账号密码
行为管理员界面 管理员登陆 系统功能界面 管理员注销
系统功能开户 查询 取款 存储 转账 改密 销户 退出
'''
import check
from check import Check
import time
import tkinter as tk
class Admin(object):
def __init__(self,admin,password):
self.admin = admin
self.password = password
# 管理员界面
def window(self):
print("*-------------------------------------------------------------*")
print("| #### ##### ### ### ## ## ## |")
print("* ## ## ## ## ## ## ## ## ## # ## *")
print("* ## ## ## ## ## # # ## ## ## ## ## *")
print("| #### ## ## ## ## ## ## ## ## # ## |")
print("| ## ## ## ## ## # ## ## ## ### |")
print("| ## ## ##### ## ## ## ## ## |")
print("*-------------------------------------------------------------*")
time.sleep(1)
return
#管理员登录界面
def login(self):
print("*------------------------------------*")
print("| |")
print("| ## ## ## ## |")
print("| ## ## # ## |")
print("* ## ## ## ## ## *")
print("* ## ## ## # ## *")
print("| ## ## ## ### |")
print("| ######### ## ## ## |")
print("| |")
print("*------------------------------------*")
check = Check()
check.userName(self.admin, self.password)
print("*-------------登陆成功---------------*")
print(" 正在跳转到系统功能界面,请稍候... ")
del check
time.sleep(3)
return
# 管理员注销界面
def logout(self):
print("*-------------------------------------------------------------------------------*")
print("| ##### #### ##### ### ### ## ## ## |")
print("* ## ## ## ## ## ## ## ## ## ## ## # ## *")
print("* ## ## ## ## ## ## ## # # ## ## ## ## ## *")
print("| ## ## #### ## ## ## ## ## ## ## ## # ## |")
print("| ## ## ## ## ## ## ## # ## ## ## ### |")
print("| ##### ## ## ##### ## ## ## ## ## |")
print("*-------------------------------------------------------------------------------*")
#确认是否注销
checkt = Check()
if not check.isSure('注销'):
return False
checkt.userName(self.admin,self.password)
print("*-------------注销成功---------------*")
print(" 正在关闭系统,请稍候... ")
del check
time.sleep(3)
return True
#系统功能界面
'''
系统功能开户,查询,取款,存储,转账,销户,挂失,解锁,改密,退出
'''
def funcWindow(self):
print("*---------Welcome To HG Bank---------*")
print("| |")
print("| (1)开户 (2)查询 (3)存款 |")
print("| |")
print("| (4)取款 (5)转账 (6)销户 |")
print("| |")
print("| (7)挂失 (8)解锁 (9)改密 |")
print("| |")
print("| (T)退出 |")
print("| |")
print("*---------Welcome To HG Bank---------*")

@ -0,0 +1,190 @@
'''
提款机
类名ATM
属性
行为开户,查询,取款,存储,转账,销户,挂失,解锁,改密,退出
'''
import check
from check import Check
from card import Card
from readAppendCard import ReadCard, AppendCard
import random
import time
class ATM(object):
# 开户 初始化类属性
def __init__(self):
self.check = Check()
self.readCard = ReadCard()
self.appendCard = AppendCard()
self.cards = self.readCard.read()
def newAccount(self):
# 输入身份证号和手机号
pnum = check.phoneNumInput()
iden = check.identifyInput()
print("正在执行开户程序,请稍候...")
while True:
cardN = str(random.randrange(100000, 10000000))
if cardN[0] == '0':
continue
if not check.isCardNExist(self.cards, cardN):
break
else:
continue
# 初始化卡号密码,卡里的钱,卡的锁定状态
card = Card(cardN, '000000', 0, iden, pnum, 'False')
self.appendCard.append(card)
print("开户成功,您的卡号为%s,密码为%s,卡余额为%d" % (cardN, '888888', 0))
print("请牢记密码,不要把密码泄露给他人。")
# 更新卡号列表
self.cards = self.readCard.read()
return True
# 查询
def checkMoney(self):
card = check.isCardExist(self.cards)
if check.isCardLock(self.cards, card.cardN):
return
print("您的余额为%d元!" % card.cardMoney)
time.sleep(1)
return card.cardMoney
# 存储
def saveMoney(self):
card = check.isCardExist(self.cards)
if check.isCardLock(self.cards, card.cardN):
return
mon = int(input("请输入您要存的钱:"))
index = self.cards.index(card)
self.cards[index].cardMoney += mon
self.writeCard()
print("存款成功!您卡上的余额为%d元!" % self.cards[index].cardMoney)
time.sleep(1)
pass
# 取款
def getMoney(self):
card = check.isCardExist(self.cards)
if check.isCardLock(self.cards, card.cardN):
return
mon = int(input("请输入您要取的钱:"))
index = self.cards.index(card)
if mon > self.cards[index].cardMoney:
print("余额不足,您当前余额为%d元!" % self.cards[index].cardMoney)
time.sleep(1)
return
self.cards[index].cardMoney -= mon
self.writeCard()
print("取款成功!你卡上的余额为%d元!" % self.cards[index].cardMoney)
time.sleep(1)
pass
# 转账
def inMoney(self):
card = check.isCardExist(self.cards)
if check.isCardLock(self.cards, card.cardN):
return
while True:
cardN = input("请输入对方的账号:")
cardOther =check.isCardNExist(self.cards, cardN)
if not cardOther:
print("账号不存在")
if check.isSure("继续转账"):
continue
else:
time.sleep(1)
return
else:
break
index = self.cards.index(card)
while True:
mon = int(input("您当前的余额为%d,请输入要转账的钱:" % self.cards[index].cardMoney))
if mon > self.cards[index].cardMoney:
print("余额不足,您当前余额为%d元!" % self.cards[index].cardMoney)
if check.isSure("继续转账"):
continue
else:
time.sleep(1)
return
else:
self.cards[index].cardMoney -= mon
break
indexOther = self.cards.index(cardOther)
self.cards[indexOther].cardMoney += mon
self.writeCard()
print("转账成功!你卡上的余额为%d元!" % self.cards[index].cardMoney)
time.sleep(1)
pass
# 销户
def DAccount(self):
card = check.isCardInfoSure(self.cards)
if card:
self.cards.remove(card)
self.writeCard()
print("销户成功!")
time.sleep(1)
pass
# 挂失
def hangOutAccount(self):
card = check.isCardInfoSure(self.cards)
if check.isCardLock(self.cards, card.cardN):
return
if card:
index = self.cards.index(card)
self.cards[index].cardLock = "True"
self.writeCard()
print("挂失成功!")
time.sleep(1)
pass
# 解锁
def unlockAccount(self):
card = check.isCardInfoSure(self.cards)
index = self.cards.index(card)
self.cards[index].cardLock = "False"
self.writeCard()
print("解锁成功!")
time.sleep(1)
pass
# 改密
def changePassword(self):
card = check.isCardInfoSure(self.cards)
if check.isCardLock(self.cards, card.cardN):
return
newpassword = input("请输入新密码")
index = self.cards.index(card)
self.cards[index].cardPassword = newpassword
self.writeCard()
print("改密成功!")
time.sleep(1)
pass
# 写入文件
def writeCard(self):
self.appendCard.append('', w='w')
for card in self.cards:
self.appendCard.append(card)
# 退出
def exit(self):
if check.isSure("退出"):
return True
else:
return False
pass

@ -0,0 +1,15 @@
'''
:
类名:Card
属性卡号7位随机 密码 余额 绑定的身份证号 手机号
'''
class Card(object):
def __init__(self, cardN, cardPassword, cardMoney, identityId, phoneNum, cardLock=''):
self.cardN = cardN
self.cardPassword = cardPassword
self.cardMoney = cardMoney
self.identityId = identityId
self.phoneNum = phoneNum
self.cardLock = cardLock

@ -0,0 +1,147 @@
'''
验证类
用户名密码卡号身份证手机号验证
输入确认
'''
def isCardNExist(cards, cardN):
for card in cards:
if cardN == card.cardN:
return card
else:
return False
def isSure(operate):
while True:
res = input("是否确认%s?【yes/no】" % operate)
if res not in ['yes', 'no']:
print("输入有误,请重新输入!")
continue
elif res == 'yes':
return True
else:
return False
def isPhoneNum(phonenum):
if phonenum[0] != '1':
print("输入的手机号开头不为1请重新输入")
return False
elif len(phonenum) != 11:
print("输入的手机号长度不对【11位】请重新输入")
return False
elif not phonenum.isdigit():
print("输入的手机号必须全部是数字,请重新输入!")
return False
else:
return True
def phoneNumInput():
while True:
pnum = input("请输入您的手机号:")
if isPhoneNum(pnum):
return pnum
def identifyInput():
iden = input("请输入您的身份证号:")
return iden
def isCardExist(cards):
cardN = input("请输入账号:")
password = input("请输入密码:")
while True:
for card in cards:
if cardN == card.carN:
if password == card.cardPassword:
return card
else:
password = input("密码有误,请重新输入密码:")
break
else:
cardN = input("账号不存在,请重新输入账号:")
password = input("请输入密码:")
def isCardPasswordSure(newassword, oldpassword):
if newassword == oldpassword:
return True
else:
return False
def isCardInfoSure(cards):
# 卡号和密码是否正确
card = isCardExist(cards)
idenId = identifyInput()
pnum = phoneNumInput()
while True:
if card.identityId == idenId:
if card.phoneNum != pnum:
print("预留手机号输入不对。")
if isSure("继续注销或挂失卡号%s" % card.cardN):
pnum = phoneNumInput()
continue
else:
return False
else:
return card
else:
print("身份证号输入不对。")
if isSure("继续注销或挂失卡号%s" % card.cardN):
idenId = identifyInput()
continue
else:
return False
def isCardLock(cards, cardN):
card = isCardNExist(cards, cardN)
if card != False:
if card.cardLock == "False":
return False
else:
print("此卡已挂失!")
return True
else:
return "卡号不存在"
class Check(object):
def __init__(self):
pass
# 用户验证
def userName(self, admin, password):
"""
:param admin: 用户名
:param password: 密码
:return:
"""
self.admin = admin
self.password = password
adminFlag = False
admin = input("请输入用户名:")
while True:
# 如果用户名输对,但密码输错,那么重新输入时只需输入密码验证即可
if adminFlag:
admin = input("请输入用户名:")
password = input("请输入密码:")
if admin != self.admin:
print("输入的用户名不对,请重新输入!")
adminFlag = True
continue
elif password != self.password:
print("输入的密码不对,请重新输入!")
adminFlag = False
continue
else:
return

@ -0,0 +1,65 @@
from card import Card
import json
# 读
class ReadCard(Card):
def __init__(self, cardN='', cardPassword='', cardMoney=0, identityId='', phoneNum='', cardLock=''):
Card.__init__(self, cardN, cardPassword, cardMoney, identityId, phoneNum, cardLock)
def dict2Card(self, d):
return self.__class__(d["cardN"], d["cardPassword"], d["cardMoney"], d["identityId"], d["phoneNum"],
d["cardLock"])
def read(self):
with open("cardinfo.txt", "r", encoding="utf-8") as fr:
cards = []
for re in fr.readlines():
cards.append(self.dict2Card(eval(re)))
return cards
# 写
class AppendCard(Card):
def __init__(self):
Card.__init__(self, cardN='', cardPassword='', cardMoney=0, identityId='', phoneNum='', cardLock='')
def card2Dict(self, card):
return {"cardN": card.cardN, "cardPassword": card.cardPassword,
"cardMoney": card.cardMoney, "identityId": card.identityId,
"phoneNum": card.phoneNum, "cardLock": card.cardLock
}
def append(self, card, w='a'):
# 清除
if w == 'w':
with open("cardinfo.txt", "w", encoding="utf-8") as fa:
fa.write('')
else:
with open("cardinfo.txt", "a", encoding="utf-8") as fa:
json.dump(card, fa, default=self.card2Dict)
fa.write('\n')
# 删
class Del(object):
def __init__(self):
pass
def del_(self, cardN):
readcard = ReadCard()
cards = readcard.read()
for card in cards:
if cardN == card.cardN:
cards.remove(card)
break
else:
print("卡号不存在,请重新输入!")
return False
appendcard = AppendCard()
appendcard.append('', w='w')
for card in cards:
appendcard.append(card)
return True

@ -0,0 +1,35 @@
from admin import Admin
from atm import ATM
admin = Admin("admin",'123456')
admin.window()
atm = ATM()
admin.login()
while True:
admin.funcWindow()
choice = input("请选择您要办理的业务:")
if choice == '1':
atm.newAccount()
elif choice == '2':
atm.checkMoney()
elif choice == '3':
atm.saveMoney()
elif choice == '4':
atm.getMoney()
elif choice == '5':
atm.inMoney()
elif choice == '6':
atm.DAccount()
elif choice == '7':
atm.hangOutAccount()
elif choice == '8':
atm.unlockAccount()
elif choice == '9':
atm.changePassword()
elif choice == 'T':
if atm.exit():
if admin.logout():
break
else:
print("未有此功能!")
Loading…
Cancel
Save