示例#1
0
def judge(account_id, money):
    account_data = accounts.account_get(account_id)
    if account_data['money'] < money:
        print("账户:%s 余额不足,剩余金额: %s" % (account_id, account_data['money']))
        return False
    else:
        return True
示例#2
0
def transfer(account_id):
    money = input("请输入要转账的金额[b]: ").strip()
    if money == 'b': return
    elif money.isdigit():
        money = int(money)
    else:
        print("输入有误")
        return
    account_id2 = input("请输入转入的账户[b]:").strip()
    if account_id2 == 'b': return
    elif account_id2.isdigit():
        if account_id2 == account_id:
            print("不能给本账户转账")
            return
        elif accounts.account_get(account_id2) is False:
            print(" 账户: %s 不存在" % account_id2)
            return
        else:
            account_id2 = int(account_id2)
        bo = judge(account_id, money)
        if bo:
            compute(account_id, 3, money, account_id2)
            logger.logger(account_id,
                          '转出',
                          '-' + str(money),
                          msg='转入账户%s' % account_id2)
            logger.logger(account_id2,
                          '转入',
                          '+' + str(money),
                          msg='来自%s的转账' % account_id)
        else:
            return False
    else:
        print("输入有误")
示例#3
0
    def wapper(*args, **kwargs):
        times = 0
        while times < 3:
            from core import accounts
            account_id = input("enter your account_id :")
            account_data = accounts.account_get(account_id)
            if account_data is False:

                print("您输入的account_id 不存在!")
                times += 1
                if times == 3: return False
            else:
                if account_data['status'] == 3:
                    print("账号: %s 已锁定,请联系管理员解锁!" % account_id)
                    return False
                password = input("enter your password :"******"登录失败,还可以尝试 %s 次" % (3 - count))
                    accounts.account_modify(account_id, 'status', count)
                    if count == 3:
                        print("账号: %s 已锁定,请联系管理员解锁!" % account_id)
                        return False
示例#4
0
def account_unlock():

    account_id = input("Enter the account_id you want to unlock :")
    if accounts.account_get(account_id) is False:
        print("账号不存在")
        return
    if len(account_id) == 0: return
    flag = accounts.account_modify(account_id, 'status', 0)
    if flag:
        print('解锁成功')
    else:
        print("解锁未成功")
示例#5
0
def account_create():

    account_id = input("create your account_id :").strip()
    if len(account_id) == 0: return
    if accounts.account_get(account_id) is not False:
        print("账号已存在")
        return
    name = input("enter your name :").strip()
    if len(name) == 0: return
    password = input("enter your password :").strip()
    if len(password) == 0: return
    account_sample.make_account(account_id, name, password)
示例#6
0
def compute(account_id, type=None, money=0, account_id2=None):
    dic = {1: withdrawals, 2: refund, 3: transfer, 4: payment_api}
    if type in dic:
        if type == 1:
            account_data1 = accounts.account_get(account_id)
            money = account_data1['money'] - money * 1.05  #利息为5%
            accounts.account_modify(account_id, 'money', money)
        elif type == 2:
            account_data1 = accounts.account_get(account_id)
            money = account_data1['money'] + money
            accounts.account_modify(account_id, 'money', money)
        elif type == 3:
            account_data1 = accounts.account_get(account_id)
            money1 = account_data1['money'] - money
            accounts.account_modify(account_id, 'money', money1)
            account_data2 = accounts.account_get(account_id2)
            money2 = account_data2['money'] + money
            accounts.account_modify(account_id2, 'money', money2)
        elif type == 4:
            account_data = accounts.account_get(account_id)
            money = account_data['money'] - money
            accounts.account_modify(account_id, 'money', money)
示例#7
0
def query(account_id):
    account_data = accounts.account_get(account_id)
    choice = input('''
        账户 ID: %s        额度: %s
        1、 查询账户余额
        2、 查询账单
        [任意键退出]
    ''' % (account_id, account_data['quota']))
    if choice == '1':
        print('\t\t额度为:%s\t可用金额为:%s' %
              (account_data['quota'], account_data['money']))
    if choice == '2':
        print(logger.logger_get(account_id))
    else:
        return