Esempio n. 1
0
def withdrawal(username):
    """
    用户提现
    :param username:
    :return:
    """
    data = accounts.loadAccount(username)
    balance = int(data['money'])
    card_money = int(data['card_money'])
    print("your balance:%s" % data['money'])
    print("your card_balance:%s" % data['card_money'])
    while True:
        input_money = int(
            input("input the number you want to withdrawal>>:").strip())
        if input_money <= balance:
            balance -= input_money
            card_money += input_money
            data['money'] = balance
            data['card_money'] = card_money
            accounts.keepMes(username, data)  # 更改本地文件数据
            accounts.record(username, "withdrawal", input_money,
                            data['money'])  # 记录流水
            logsFunc.withdrawalLog(username, input_money)
            print("your balance:%s" % data['money'])
            print("your card_balance:%s" % data['card_money'])
            print("success!")
            main.showMenu(username)
            break
        else:
            print("Insufficient balance!")  # 余额不足
            print("your balance:%s" % data['money'])
            print("your card_balance:%s" % data['card_money'])
Esempio n. 2
0
def repay(username):
    data = accounts.loadAccount(username)
    money = int(data['money'])
    card_money = int(data['card_money'])
    if money >= 0:
        print("you needn't to repay!")
    else:
        print("your money:\033[31m%s\033[0m" % data['money'])
        while True:
            input_money = int(
                input("\033[33minput the number you want to repay>>:\033[0m").
                strip())
            if input_money <= card_money:
                card_money -= input_money
                money += input_money
                data['money'] = money
                data['card_money'] = card_money
                logsFunc.repayLog(username, input_money)
                accounts.keepMes(username, data)
                accounts.record(username, "repay", input_money, data['money'])
                print("\033[33msuccess!!\033[0m")
                main.showMenu(username)
                break
            else:
                print("\033[31mInsufficient balance!\033[0m")
                print("your card_balance:%s" % data['card_money'])
Esempio n. 3
0
def shopping(username):
    goods_list = logsFunc.loadGoods()
    print("%5s\t%10s\t%10s" % ("编号", "name", "price"))
    flag = 0
    name = []
    price = []
    shopping_car = []  # 购物车
    spend_money = 0
    for goods in goods_list:
        # print("%5s\t%10s\t%10s" % (flag, goods_list[goods]['name'], goods_list[goods]['price']))
        name.append(goods_list[goods]['name'])
        price.append(int(goods_list[goods]['price']))
        flag += 1
    while True:
        printGoods(goods_list)
        input_num = int(
            input(
                "\033[31minput the number you want to buy(-1 to cancel and -2 to pay)>>:\033[0m"
            ).strip())
        if input_num < len(name) and input_num != -1 and input_num != -2:
            shopping_car.append(input_num)
            spend_money += price[input_num]  # 计算花费信息
            print("\033[33msuccess to add %s!\033[0m" %
                  name[input_num])  # 打印成功添加商品
        elif input_num == -1:
            break
        elif input_num == -2:  # 结账
            if payoff(username, spend_money) == 1:
                print("\033[32msuccess!!\033[0m")
            else:
                print("\033[31mSorry, your credit is running low\033[0m")
            break
        else:
            print("\033[33mInput Error!\033[0m")
    main.showMenu(username)
Esempio n. 4
0
def userSelect(choose):
    print(choose)
    selectd = 0
    while selectd == 0:
        if str(choose) == '1':
            pararm = "4kfengjing/"
            selectd = 1
        elif str(choose) == '2':
            pararm = "4kmeinv/"
            selectd = 1
        elif str(choose) == '3':
            pararm = "4kyouxi/"
            selectd = 1
        elif str(choose) == '4':
            pararm = "4kdongman/"
            selectd = 1
        elif str(choose) == '5':
            pararm = "4kyingshi/"
            selectd = 1
        elif str(choose) == '6':
            pararm = "4kmingxing/"
            selectd = 1
        elif str(choose) == '7':
            pararm = "4kqiche/"
            selectd = 1
        elif str(choose) == '8':
            pararm = "4kdongwu/"
            selectd = 1
        elif str(choose) == '9':
            pararm = "4krenwu/"
            selectd = 1
        elif str(choose) == '10':
            pararm = "4kmeishi/"
            selectd = 1
        elif str(choose) == '11':
            pararm = "4kzongjiao/"
            selectd = 1
        elif str(choose) == '12':
            pararm = "4kbeijing/"
            selectd = 1
        elif str(choose) == '13':
            pararm = "4kbeijing/"
            selectd = 1
            main.showMenu()
        else:
            print("请输入正确选项")
            return userSerach()
    return pararm
Esempio n. 5
0
def music_analysis():
    url = "https://api.toubiec.cn/rand.music"
    select = 0
    print('=' * 20)
    print("1,网易云音乐")
    print("2,腾讯音乐")
    print("3,退出")
    print("=" * 20)
    musicApp = input("请选择要解析的音乐平台>>>>>>:")
    musicType = ''
    while select == 0:
        if str(musicApp) == '1':
            musicType = "netease"
            select = 1
        elif str(musicApp) == '2':
            musicType = "tencent"
            select = 1
        elif str(musicApp) == "3":
            select = 1
            return main.showMenu()
        else:
            print("请选上面有的")
    musicId = input("请输入要解析的音乐id>>>>>>>:")
    print("正在解析.......")
    params = {"type": musicType, "id": musicId}
    res = requests.get(url, params)
    res = res.json()
    return res
Esempio n. 6
0
def transfer(username):
    data = accounts.loadAccount(username)
    while True:
        print("\033[1;31;40minput the username you want to transfer>>:\033[0m",
              end="")
        input_username = input().strip()
        transfer_data = accounts.loadAccount(input_username)
        if transfer_data == 0:
            print("the account is not found")
            break
        else:
            name = transfer_data['name']
            age = transfer_data['age']
            print("\033[31mname:%s age:%s\033[0m" % (name, age))
            transfer_balance = int(transfer_data['money'])
            user_money = int(data['money'])
            input_money = int(input("input the number of money>>:").strip())
            if input_money <= user_money:
                user_money -= input_money
                transfer_balance += input_money
                transfer_data['money'] = transfer_balance
                data['money'] = user_money
                logsFunc.transferLog(username, input_username, input_money)
                accounts.keepMes(username, data)
                accounts.record(username, "transfer to " + str(input_username),
                                input_money, data['money'])  # 记录流水
                accounts.keepMes(input_username, transfer_data)
                accounts.record(input_username,
                                "transfer from " + str(username), input_money,
                                transfer_data['money'])  # 记录流水
                print('\033[33msuccess!!\033[0m')
                main.showMenu(username)
                break
            else:
                print("Insufficient balance!")
                print("your balance:%s" % data['money'])
Esempio n. 7
0
def noteMenu():
    menuList =[
        [
            "读(看看自己都写了什么)","写(记录一下)","退出记事本"
        ],
        [
            "A","B","C"
        ]
    ]
    selectN = 0
    newTable = table.Texttable()
    newTable.add_rows(menuList)
    print(newTable.draw())  
    while selectN==0:
        select = input("请选择记事本操作>>>>:\n")
        if select.lower()=="a":
            noteRead()
        elif select.lower()=="b":
            noteWrite()
        elif select.lower() == "c":
            selectN = 1
            main.showMenu()
        else:
            print('='*20+"请选择有的哦"+'='*20)
Esempio n. 8
0
def record(username):
    with open("../db/transaction/" + str(username) + ".txt", "r") as f:
        for line in f:
            print(line)
    main.showMenu(username)