Пример #1
0
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")
Пример #2
0
def user_change_visibility(username):
	contents = '<p>You do not have permission to do that!</p>'
	if session_check():
		if session_get_auth_level() == 'admin':
			data = accounts.get_account_data(username)
			new_visibility = bottle.request.forms.get('visible')
			data['visible'] = new_visibility == 'visible'
			accounts.save()
			contents = '<p>{}\' Visibility changed to {}.</p>'.format(username, new_visibility)
	return html_framework.format(contents)
Пример #3
0
def user_change_auth_level(username):
	contents = '<p>You do not have permission to do that!</p>'
	if session_check():
		if session_get_auth_level() == 'admin':
			data = accounts.get_account_data(username)
			new_level = bottle.request.forms.get('auth_level')
			data['auth'] = new_level
			accounts.save()
			contents = '<p>{}\' level changed to {}.</p>'.format(username, new_level)
	return html_framework.format(contents)
Пример #4
0
def repayment(user, acc_log, tra_log):
    print("********还款********")
    print("账户额度:%s" % user["quota"])
    print("账户余额:%s" % user["balance"])
    repay = input("还款金额:")
    user["balance"] = str(float(user["balance"]) + float(repay))
    accounts.save(user)
    print("\033[31;1m还款成功!\033[0m")
    acc_log.info("用户[%s]还款[%s]" % (user["user_name"], repay))
    tra_log.info("用户[%s]还款[%s]" % (user["user_name"], repay))
Пример #5
0
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")
Пример #6
0
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")
Пример #7
0
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")
Пример #8
0
def buy(commodity, account, tra_log, mall_log):
    message = "购买成功"
    power = float(account["atm"]["data"]["quota"]) + float(
        account["atm"]["data"]["balance"])
    if power >= float(commodity[1]):
        account["atm"]["data"]["balance"] = str(
            float(account["atm"]["data"]["balance"]) - float(commodity[1]))
        accounts.save(account["atm"]["data"])
        #日志
        tra_log.info("[%s]商城消费[%s]" %
                     (account["atm"]["data"]["user_name"], commodity[1]))
        mall_log.info(
            "[%s]购买了[%s],价格为[%s]" %
            (account["mall"]["data"]["user_name"], commodity[0], commodity[1]))
    else:
        message = "余额不足,购买失败"
    return message
Пример #9
0
def drawing(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)
    drawing_num = input("提款金额:")
    if float(drawing_num) > float(limit):
        print("\033[31;1m超限!提款失败!\033[0m")
    else:
        user["balance"] = str(
            float(user["balance"]) - float(drawing_num) * 1.05)
        accounts.save(user)
        print("\033[31;1m提款成功!\033[0m")
        acc_log.info("用户[%s]提款[%s]" % (user["user_name"], drawing_num))
        tra_log.info("用户[%s]提款[%s]" % (user["user_name"], drawing_num))