设计一个会员卡计费管理系统,根据下面内容自行设计会员个人信息及会员卡信息,至少具有下面 所要求的基本内容,并通过菜单实现相应功能。 (1)新会员登记。(将会员个人信息及此会员的会员卡信息进行录入。) (2)会员信息修改。 (3)会员续费。(会员出示会员卡后,管理人员根据卡号查找到该会员的信息并显示。此时可以 行续费,续费后,提示成功,并显示更新后的信息。) (4)会员消费结算。(会员出示会员卡后,管理人员根据卡号查找到该会员的信息,结算本次费用。提示成功,并显示更新后的信息。)累计消费满1000元,及自动升级为VIP会员。之后每次消费给9折优惠。 (5)会员退卡。(收回会员卡,并将余额退还,删除该会员信息。) 会员卡挂失。(为该会员补办新卡,并将旧卡余额转至新卡。) (9) (7)统计功能:能够按累计消费总额进行排序。在排序的最后一行显示所有会员的缴费总额,以 消费总额。
时间: 2024-03-30 09:38:17 浏览: 145
好的,根据您提供的要求,我可以给您设计一个简单的会员卡计费管理系统。该系统基于 Python 编写,使用文件存储数据。以下是系统的基本功能:
1. 新会员登记:将会员个人信息及会员卡信息进行录入并保存到文件中。
2. 会员信息修改:根据会员卡号查找会员信息,并可修改会员个人信息及会员卡信息。
3. 会员续费:根据会员卡号查找会员信息并显示,进行续费操作后保存信息。
4. 会员消费结算:根据会员卡号查找会员信息并显示,进行结算操作后保存信息。如累计消费满 1000 元,自动升级为 VIP 并享受 9 折优惠。
5. 会员退卡:根据会员卡号查找会员信息并删除。
6. 会员卡挂失:根据会员卡号查找会员信息并进行挂失操作后保存信息,同时为会员补办新卡并将旧卡余额转至新卡。
7. 统计功能:按照累计消费总额排序,并在排序的最后一行显示所有会员的缴费总额及消费总额。
下面是一个简单的代码示例,仅供参考:
```python
# coding: utf-8
import os
import time
VIP_DISCOUNT = 0.9 # VIP 9 折优惠
class Member:
def __init__(self, name, phone, card_no, balance=0.0, total_cost=0.0):
self.name = name
self.phone = phone
self.card_no = card_no
self.balance = balance
self.total_cost = total_cost
def __str__(self):
return "姓名:{},电话:{},会员卡号:{},余额:{:.2f},累计消费:{:.2f}".format(
self.name, self.phone, self.card_no, self.balance, self.total_cost)
class CardMgr:
def __init__(self, filename):
self.filename = filename
self.members = []
self.load()
def load(self):
if not os.path.exists(self.filename):
return
with open(self.filename, 'r', encoding='utf-8') as f:
for line in f:
name, phone, card_no, balance, total_cost = line.strip().split(',')
member = Member(name, phone, card_no, float(balance), float(total_cost))
self.members.append(member)
def save(self):
with open(self.filename, 'w', encoding='utf-8') as f:
for member in self.members:
f.write("{},{},{},{},{}\n".format(
member.name, member.phone, member.card_no, member.balance, member.total_cost))
def add_member(self):
name = input("请输入会员姓名:")
phone = input("请输入会员电话:")
card_no = input("请输入会员卡号:")
balance = float(input("请输入会员余额:"))
member = Member(name, phone, card_no, balance)
self.members.append(member)
self.save()
print("新会员登记成功!")
def modify_member(self):
card_no = input("请输入会员卡号:")
for member in self.members:
if member.card_no == card_no:
print("原始信息:", member)
member.name = input("请输入会员姓名:")
member.phone = input("请输入会员电话:")
member.card_no = input("请输入会员卡号:")
member.balance = float(input("请输入会员余额:"))
self.save()
print("会员信息修改成功!")
break
else:
print("没有找到该会员!")
def renew_member(self):
card_no = input("请输入会员卡号:")
for member in self.members:
if member.card_no == card_no:
print("原始信息:", member)
fee = float(input("请输入续费金额:"))
member.balance += fee
self.save()
print("续费成功!更新后信息:", member)
break
else:
print("没有找到该会员!")
def settle_account(self):
card_no = input("请输入会员卡号:")
for member in self.members:
if member.card_no == card_no:
print("原始信息:", member)
cost = float(input("请输入消费金额:"))
if member.total_cost + cost >= 1000 and member.total_cost < 1000:
print("恭喜您,升级为 VIP 会员!")
member.total_cost += cost
if member.total_cost >= 1000:
member.balance -= cost * VIP_DISCOUNT
else:
member.balance -= cost
self.save()
print("结算成功!更新后信息:", member)
break
else:
print("没有找到该会员!")
def delete_member(self):
card_no = input("请输入会员卡号:")
for member in self.members:
if member.card_no == card_no:
self.members.remove(member)
self.save()
print("会员退卡成功!")
break
else:
print("没有找到该会员!")
def report(self):
members = sorted(self.members, key=lambda x: x.total_cost, reverse=True)
total_cost = sum([member.total_cost for member in members])
print("会员信息如下:")
for member in members:
print(member)
print("所有会员的缴费总额为:{:.2f},消费总额为:{:.2f}".format(
total_cost, sum([member.total_cost for member in members])))
def report_by_total_cost(self):
members = sorted(self.members, key=lambda x: x.total_cost, reverse=True)
total_cost = sum([member.total_cost for member in members])
print("会员信息如下:")
for member in members:
print(member)
print("所有会员的缴费总额为:{:.2f},消费总额为:{:.2f}".format(
total_cost, sum([member.total_cost for member in members])))
if __name__ == '__main__':
card_mgr = CardMgr('members.txt')
while True:
print("""
1. 新会员登记
2. 会员信息修改
3. 会员续费
4. 会员消费结算
5. 会员退卡
6. 会员卡挂失
7. 统计功能
0. 退出
""")
choice = input("请输入功能编号:")
if choice == '1':
card_mgr.add_member()
elif choice == '2':
card_mgr.modify_member()
elif choice == '3':
card_mgr.renew_member()
elif choice == '4':
card_mgr.settle_account()
elif choice == '5':
card_mgr.delete_member()
elif choice == '6':
print("该功能待实现!")
elif choice == '7':
card_mgr.report_by_total_cost()
elif choice == '0':
print("程序已退出!")
break
else:
print("请输入正确的功能编号!")
time.sleep(1)
```
阅读全文