def transfer_accounts(user, acc_log, tra_log): print("********转账********") print("账户额度:%s" % user["quota"]) print("账户余额:%s" % user["balance"]) limit = "0" if float(user["balance"]) >= 0: limit = str(float(user["balance"]) + float(user["quota"]) / 2) if float(user["balance"]) < 0: limit = str((float(user["balance"]) + float(user["quota"])) / 2) print("转账额度:%s" % limit) transfer_num = input("转账金额:") if float(transfer_num) > float(limit): print("\033[31;1m超限!转账失败!\033[0m") else: transfer_to_user_name = input("对方账户:") transfer_to_user = accounts.select(transfer_to_user_name) if transfer_to_user: if transfer_to_user["locked"] == "1": print("\033[31;1m目标账户已被冻结!转账失败!\033[0m") else: user["balance"] = str( float(user["balance"]) - float(transfer_num) * 1.05) accounts.save(user) transfer_to_user["balance"] = str( float(transfer_to_user["balance"]) + float(transfer_num)) accounts.save(transfer_to_user) print("\033[31;1m转账成功!\033[0m") acc_log.info("用户[%s]向用户[%s]转账[%s]" % (user["user_name"], transfer_to_user["user_name"], transfer_num)) tra_log.info("用户[%s]向用户[%s]转账[%s]" % (user["user_name"], transfer_to_user["user_name"], transfer_num)) else: print("\033[31;1m目标账户不存在!转账失败!\033[0m")
def unlock_account(acc_log): print("****解冻账户****") user_name = input("账户名:") user = accounts.select(user_name) if user: if user["locked"] == "0": print("\033[31;1m该账户未被冻结!\033[0m") else: user["locked"] = "0" accounts.save(user) print("\033[31;1m解冻成功!\033[0m") acc_log.info("管理员解除了对[%s]的冻结" % user_name) else: print("\033[31;1m该用户不存在!\033[0m")
def lock_account(acc_log): print("****冻结账户****") user_name = input("账户名:") user = accounts.select(user_name) if user: if user["locked"] == "1": print("\033[31;1m该账户已被冻结!\033[0m") else: user["locked"] = "1" accounts.save(user) print("\033[31;1m冻结成功!\033[0m") acc_log.info("管理员冻结了用户[%s]" % user_name) else: print("\033[31;1m该用户不存在!\033[0m")
def modify_quota(acc_log): print("****更改用户额度****") user_name = input("账户名:") user = accounts.select(user_name) if user: if user["locked"] == "1": print("\033[31;1m该账户已被冻结!\033[0m") else: print("账户原额度:%s" % user["quota"]) modify = input("更改为:") user["quota"] = modify accounts.save(user) print("\033[31;1m修改成功!\033[0m") acc_log.info(u"管理员将[%s]的信用卡额度更改为[%s]" % (user_name, modify)) else: print("\033[31;1m该用户不存在!\033[0m")
def atm_user_login(account_2): #普通用户登录 user_name = input("账号:") user_password = input("密码:") user = accounts.select(user_name) if user: if user["locked"] == "0": if user_password == user["user_password"]: account_2["login"] = "******" account_2["role"] = "user" account_2["data"] = user else: account_2["login"] = "******" account_2["message"] = "密码错误!" else: account_2["login"] = "******" account_2["message"] = "该账号已被冻结!请联系管理员!" else: account_2["login"] = "******" account_2["message"] = "用户不存在!"